[jboss-user] [JNDI/Naming/Network] - Data Source JNDI lookup fails in a WAR

avyo do-not-reply at jboss.com
Thu Jul 10 08:10:51 EDT 2008


Hi All,

I'm running my app on jboss 4.2.0, using a MSSql as a database ans spring.

My Data source:TestDB-ds.xml 

   <local-tx-datasource>
      <jndi-name>TestDB</jndi-name>
	  <connection-url> jdbc:sqlserver://muzicall01;database=muzicall_dev</connection-url>
      <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
      <user-name>xxx</user-name>
      <p assword>xxx</p assword>
  </local-tx-datasource>


The JNDI lookup in spring:
<jee:jndi-lookup id="dataSource" jndi-name="java:TestDB"/>

In a regular EAR deployment it is working just find but when I moved to a WAR I got javax.naming.NameNotFoundException

Follow my JNDI tree:
java: Namespace

  +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
  +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
  +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
  +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
  +- comp (class: javax.naming.Context)
  +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
  +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
  +- jaas (class: javax.naming.Context)
  |   +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
  |   +- jbossmq (class: org.jboss.security.plugins.SecurityDomainContext)
  |   +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext)
  +- comp.original (class: javax.namingMain.Context)
  +- timedCacheFactory (class: javax.naming.Context)
Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy cannot be cast to javax.naming.NamingEnumeration
  +- TestDB (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
  +- TransactionPropagationContextExporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
  +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
  +- Mail (class: javax.mail.Session)
  +- comp.ejb3 (class: javax.naming.Context)
  |   NonContext: null
  +- TransactionPropagationContextImporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
  +- TransactionManager (class: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate)

I made a small test - in a servlet I inserted those two rows:
((Object)context.lookup("java:SecurityProxyFactory")).getClass().getName();

((Object)context.lookup("java:TestDB")).getClass().getName();

Both JNDI names are from the same level for the first one I got the right class and for the second I dont the name not found.

Any idea why I can find the DS an EAR deployment and not on a WAR one. 
You help will be appreciated. 


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4163581#4163581

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4163581



More information about the jboss-user mailing list