2 Replies Latest reply on Aug 4, 2009 4:45 AM by diegomansua

    Can't access java namespace

      Hi. I have deployed an old version of JForum, and I've declared its datasource like this:

       <xa-datasource-property name="ServerName">localhost</xa-datasource-property>
       <xa-datasource-property name="PortNumber">5432</xa-datasource-property>
       <xa-datasource-property name="DatabaseName">forum</xa-datasource-property>

      When JForum tries to get the datasource reference, it gets a NameNotFoundException. The code is like this:

      Context context = new InitialContext();
      this.ds = (DataSource)context.lookup(SystemGlobals.getValue(ConfigKeys.DATABASE_DATASOURCE_NAME));

      Where the value returned by SystemGlobals.getValue(ConfigKeys.DATABASE_DATASOURCE_NAME) is "java:forum".

      If I access the JNDIView mbean from the JMX console, I can see the datasource correctly bound:

      java: Namespace
       +- forum (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)

      I also tried using a reference bound to the comp/env context of this app, using this inside jboss-web.xml:

      <?xml version="1.0" encoding="UTF-8"?>

      And this inside web.xml:


      And again, it shows in JNDIView but I always get a NameNotFoundException when performing the lookup java:/comp/env/jdbc/forum:

      java:comp namespace of the forum.war application:
       +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
       +- env (class: org.jnp.interfaces.NamingContext)
       | +- jdbc (class: org.jnp.interfaces.NamingContext)
       | | +- forum[link -> java:forum] (class: javax.naming.LinkRef)

      The only way I can make it work is by setting use-java-context to false in the datasource declaration, so the datasource is bound to the global context, and JForum can see it, but I'd like to avoid this.

      With a newer JForum version, this doesn't happen, but I think the JNDI lookup code is exactly the same, and any of the apps have JNDI specific configuration.

      Thanks in advance