1 Reply Latest reply on Jul 7, 2005 2:44 PM by Amir Mistric

    JNDI issues from Sun Appserver 8.1 to JBoss 4.03

    Amir Mistric Newbie

      Hi

      I have an application that works on Sun's Java System Application Server Platform Edition 8.1 but when I try to deploy it JBoss I am getting some errors regarding the lookup of JNDI resources.

      First I created -ds.xml resource file and deployed it.

      <datasources>
       <local-tx-datasource>
       <jndi-name>jdbc/ecardDB</jndi-name>
       <connection-url>jdbc:jtds:sqlserver://webdev.nemours.org:1433/ecard</connection-url>
       <driver-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</driver-class>
       <user-name>user</user-name>
       <password>pass</password>
      
       <connection-property name="ProgName">jTDS - org.nemours.webapp.ecard</connection-property>
       <connection-property name="AppName">jTDS - org.nemours.webapp.ecard</connection-property>
       <connection-property name="Description">AIDHC eCards db pool</connection-property>
      
       <metadata>
       <type-mapping>MS SQLSERVER2000</type-mapping>
       </metadata>
       </local-tx-datasource>
      
      </datasources>


      This part worked fine and I can see this name via jmx-console JNDI MBean.
      Here is the output:
      java: Namespace
      
       +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
       +- DefaultDS (class: javax.sql.DataSource)
       +- 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)
       +- jdbc (class: org.jnp.interfaces.NamingContext)
       | +- ecardDB (class: javax.sql.DataSource)
       +- jaas (class: javax.naming.Context)
       | +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext)
       | +- jmx-console (class: org.jboss.security.plugins.SecurityDomainContext)
       | +- jbossmq (class: org.jboss.security.plugins.SecurityDomainContext)
       | +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
       +- timedCacheFactory (class: javax.naming.Context)
      Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy
       +- TransactionPropagationContextExporter (class: org.jboss.tm.TransactionPropagationContextFactory)
       +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
       +- Mail (class: javax.mail.Session)
       +- TransactionPropagationContextImporter (class: org.jboss.tm.TransactionPropagationContextImporter)
       +- TransactionManager (class: org.jboss.tm.TxManager)
      
      
      Global JNDI Namespace
      
       +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
       +- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
       +- UserTransactionSessionFactory (proxy: $Proxy11 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
       +- HTTPConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
       +- console (class: org.jnp.interfaces.NamingContext)
       | +- PluginManager (proxy: $Proxy37 implements interface org.jboss.console.manager.PluginManagerMBean)
       +- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
       +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)
       +- HTTPXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
       +- topic (class: org.jnp.interfaces.NamingContext)
       | +- testDurableTopic (class: org.jboss.mq.SpyTopic)
       | +- testTopic (class: org.jboss.mq.SpyTopic)
       | +- securedTopic (class: org.jboss.mq.SpyTopic)
       +- queue (class: org.jnp.interfaces.NamingContext)
       | +- A (class: org.jboss.mq.SpyQueue)
       | +- testQueue (class: org.jboss.mq.SpyQueue)
       | +- ex (class: org.jboss.mq.SpyQueue)
       | +- DLQ (class: org.jboss.mq.SpyQueue)
       | +- D (class: org.jboss.mq.SpyQueue)
       | +- C (class: org.jboss.mq.SpyQueue)
       | +- B (class: org.jboss.mq.SpyQueue)
       +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
       +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
       +- jmx (class: org.jnp.interfaces.NamingContext)
       | +- invoker (class: org.jnp.interfaces.NamingContext)
       | | +- RMIAdaptor (proxy: $Proxy36 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
       | +- rmi (class: org.jnp.interfaces.NamingContext)
       | | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
       +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
       +- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
       +- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
      
      



      The problem is that I have some environment strings that I use in my app via web.xml....Here is my web.xml part that refers to them...
       <resource-ref>
       <res-ref-name>jdbc/ecardDB</res-ref-name>
       <res-type>javax.sql.ConnectionPoolDataSource</res-type>
       <res-auth>Container</res-auth>
       <res-sharing-scope>Shareable</res-sharing-scope>
       </resource-ref>
      
       <!-- string entry pointing to JDBC resource -->
       <env-entry>
       <description>Conflict Of Interest DataSource Name</description>
       <env-entry-name>ecard/dao/ECardDataSource</env-entry-name>
       <env-entry-type>java.lang.String</env-entry-type>
       <env-entry-value>java:comp/env/jdbc/ecardDB</env-entry-value>
       </env-entry>
      
       <!-- string entries pointing to implementation classes for DAOFactory -->
       <env-entry>
       <description>Category DAO Implementation Class</description>
       <env-entry-name>ecard/dao/CategoryDAOClass</env-entry-name>
       <env-entry-type>java.lang.String</env-entry-type>
       <env-entry-value>org.nemours.webapp.ecard.dao.MsSqlCategoryDAO</env-entry-value>
       </env-entry>
       <env-entry>
       <description>ECard DAO Implementation Class</description>
       <env-entry-name>ecard/dao/ECardDAOClass</env-entry-name>
       <env-entry-type>java.lang.String</env-entry-type>
       <env-entry-value>org.nemours.webapp.ecard.dao.MsSqlECardDAO</env-entry-value>
       </env-entry>
      


      Here is also my jboss-web.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss-web PUBLIC
       "-//JBoss//DTD Web Application 2.4//EN"
       "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
      <jboss-web>
       <context-root>/ecards</context-root>
       <resource-ref>
       <res-ref-name>jdbc/ecardDB</res-ref-name>
       <jndi-name>jdbc/ecardDB</jndi-name>
       </resource-ref>
      </jboss-web>
      



      When I try to deploy the app I get the following error:
      2005-07-07 10:32:03,312 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/ecards]] Exception sending context initialized event to listener instance of class org.nemours.webapp.ecard.controller.ECardContextListener
      org.nemours.webapp.ecard.model.CategoryException: Failure to retrieve Category data
       at org.nemours.webapp.ecard.model.CategoryFacade.getCategory(CategoryFacade.java:41)
      skip...
      skip...
      skip...
      Caused by: org.nemours.common.util.UtilsException: DBUtils: Failure while creating DB connection :
      org.nemours.common.pattern.blueprints.servicelocator.ServiceLocatorException: javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: jdbc not bound]
       at org.nemours.common.util.DBUtils.createConnection(DBUtils.java:95)
       at org.nemours.webapp.ecard.dao.MsSqlCategoryDAO.selectCategory(MsSqlCategoryDAO.java:61)
       at org.nemours.webapp.ecard.model.CategoryFacade.getCategory(CategoryFacade.java:39)
      


      Ok so I can tell that the root problem is the JNDI lookup..
      On Sun's server this worked fine and I didn't have to do anything else.
      Is there anything additional I have to configure on JBoss in order for this to work?



      Any help is appreciated...

      Amir

        • 1. Re: JNDI issues from Sun Appserver 8.1 to JBoss 4.03
          Amir Mistric Newbie

          Ok

          I was able to figure out what the issue was.
          In jboss-web.xml you have to use prefix java: so it should look like this:

          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE jboss-web PUBLIC
           "-//JBoss//DTD Web Application 2.4//EN"
           "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
          <jboss-web>
           <context-root>/ecards</context-root>
           <resource-ref>
           <res-ref-name>jdbc/ecardDB</res-ref-name>
           <res-type>javax.sql.DataSource</res-type>
           <jndi-name>java:jdbc/ecardDB</jndi-name>
           </resource-ref>
          </jboss-web>


          This has resolved my problem...

          Regards