[jboss-user] [JNDI/Naming/Network] - Can't access java namespace
diegomansua
do-not-reply at jboss.com
Tue Aug 4 04:15:32 EDT 2009
Hi. I have deployed an old version of JForum, and I've declared its datasource like this:
| <xa-datasource>
| <jndi-name>forum</jndi-name>
| <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
| <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>
| <user-name>test</user-name>
| <password>test</password>
| <transaction-isolation>TRANSACTION_SERIALIZABLE</transaction-isolation>
| <min-pool-size>1</min-pool-size>
| <max-pool-size>10</max-pool-size>
| <blocking-timeout-millis>5000</blocking-timeout-millis>
| <idle-timeout-minutes>15</idle-timeout-minutes>
| <security-domain/>
| <application-managed-security/>
| </xa-datasource>
|
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"?>
| <jboss-web>
| <resource-ref>
| <res-ref-name>jdbc/forum</res-ref-name>
| <jndi-name>java:forum</jndi-name>
| </resource-ref>
| </jboss-web>
|
And this inside web.xml:
| <resource-ref>
| <description>Hibernate</description>
| <res-ref-name>jdbc/forum</res-ref-name>
| <res-type>javax.sql.DataSource</res-type>
| <res-auth>Container</res-auth>
| </resource-ref>
|
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
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4247770#4247770
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4247770
More information about the jboss-user
mailing list