Results 1 to 6 of 6

Thread: JNDI lookup in Websphere

  1. #1
    Join Date
    Nov 2006
    Posts
    193

    Default JNDI lookup in Websphere

    Hi all,

    I'm struggling with this error. I've included the resource ref in my web.xml and everything deploys cool, when I try do a jee:jndi lookup for my DS, I get the following:

    Caused by: org.springframework.jndi.JndiLookupFailureExceptio n: JndiObjectTargetSource failed to obtain new target object; nested exception is javax.naming.ConfigurationException: A JNDI operation on a "java:" name cannot be completed because the serverruntime is not able to associate the operation's thread with any J2EE application component. This condition can occur when the JNDI client using the "java:" name is not executed on the thread of a server application request. Make sure that a J2EE application does not execute JNDI operations on "java:" names within static code blocks or in threads created by that J2EE application. Such code does not necessarily run on the thread of a server application request and therefore is not supported by JNDI operations on "java:" names. [Root exception is javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".]
    at org.springframework.jndi.JndiObjectTargetSource.ge tTarget(JndiObjectTargetSource.java:138)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:184)
    at $Proxy5.getConnection(Unknown Source)
    at org.springframework.jdbc.datasource.DataSourceUtil s.doGetConnection(DataSourceUtils.java:113)
    at org.springframework.jdbc.datasource.DataSourceUtil s.getConnection(DataSourceUtils.java:79)
    at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:577)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:641)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:670)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:678)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:710)
    at org.appfuse.dao.jdbc.JdbcMessageDao.getNextMessage (JdbcMessageDao.java:64)
    at org.appfuse.service.impl.PersistentMessageAdapterI mpl.removeNext(PersistentMessageAdapterImpl.java:5 6)
    at sun.reflect.GeneratedMethodAccessor38.invoke(Unkno wn Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.springframework.util.MethodInvoker.invoke(Meth odInvoker.java:276)
    at org.springframework.integration.util.NameResolving MethodInvoker.invokeMethod(NameResolvingMethodInvo ker.java:58)
    at org.springframework.integration.message.MethodInvo kingMessageSource.receive(MethodInvokingMessageSou rce.java:84)
    ... 18 more
    Caused by: javax.naming.ConfigurationException: A JNDI operation on a "java:" name cannot be completed because the serverruntime is not able to associate the operation's thread with any J2EE application component. This condition can occur when the JNDI client using the "java:" name is not executed on the thread of a server application request. Make sure that a J2EE application does not execute JNDI operations on "java:" names within static code blocks or in threads created by that J2EE application. Such code does not necessarily run on the thread of a server application request and therefore is not supported by JNDI operations on "java:" names. [Root exception is javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".]
    at com.ibm.ws.naming.java.javaURLContextImpl.throwCon figurationExceptionWithDefaultJavaNS(javaURLContex tImpl.java:416)
    at com.ibm.ws.naming.java.javaURLContextImpl.lookup(j avaURLContextImpl.java:388)
    at com.ibm.ws.naming.java.javaURLContextRoot.lookup(j avaURLContextRoot.java:205)
    at com.ibm.ws.naming.java.javaURLContextRoot.lookup(j avaURLContextRoot.java:145)
    at javax.naming.InitialContext.lookup(InitialContext. java:351)
    at org.springframework.jndi.JndiTemplate$1.doInContex t(JndiTemplate.java:155)
    at org.springframework.jndi.JndiTemplate.execute(Jndi Template.java:88)
    at org.springframework.jndi.JndiTemplate.lookup(JndiT emplate.java:153)
    at org.springframework.jndi.JndiTemplate.lookup(JndiT emplate.java:178)
    at org.springframework.jndi.JndiLocatorSupport.lookup (JndiLocatorSupport.java:95)
    at org.springframework.jndi.JndiObjectLocator.lookup( JndiObjectLocator.java:105)
    at org.springframework.jndi.JndiObjectTargetSource.ge tTarget(JndiObjectTargetSource.java:131)
    ... 35 more
    Caused by: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".
    at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInt ernal(NameSpace.java:1767)
    at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal( NameSpace.java:1083)
    at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpac e.java:991)
    at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(Ur lContextImpl.java:1263)
    at com.ibm.ws.naming.java.javaURLContextImpl.lookup(j avaURLContextImpl.java:384)
    ... 45 more
    [5/14/09 16:49:30:895 SAST] 0000005d javaURLContex E NMSV0310E: A JNDI operation on a "java:" name cannot be completed because the server runtime is not able to associate the operation's thread with any J2EE application component. This condition can occur when the JNDI client using the "java:" name is not executed on the thread of a server application request. Make sure that a J2EE application does not execute JNDI operations on "java:" names within static code blocks or in threads created by that J2EE application. Such code does not necessarily run on the thread of a server application request and therefore is not supported by JNDI operations on "java:" names. Exception stack trace:
    javax.naming.ConfigurationException [Root exception is javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".]
    at com.ibm.ws.naming.java.javaURLContextImpl.throwCon figurationExceptionWithDefaultJavaNS(javaURLContex tImpl.java:411)

  2. #2
    Join Date
    Feb 2007
    Posts
    102

    Default

    It seems to be a configuration error. You have to post you datasource bean config..
    but for now make sure to config your spring datasource in this way:
    Code:
    <jee:jndi-lookup id="dataSource" jndi-name="jdbc/yourname" resource-ref="true" />
    ..and, obviously, make sure that a datasource is configured in websphere!

    Hope it may help you

  3. #3
    Join Date
    Nov 2006
    Posts
    193

    Default

    Hi Ghed,
    I really appreciate the response.
    Here is my ref in web.xml

    <resource-ref id="ResourceRef_eeBridgeXADS">
    <description>
    </description>
    <res-ref-name>jdbc/eeBridgeXADS</res-ref-name>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>

    =======================================

    here is my spring context.xml jndi lookup

    ======================================

    <jee:jndi-lookup id="dataSource"
    jndi-name="jdbc/eeBridgeXADS"
    resource-ref="true">
    </jee:jndi-lookup>

  4. #4
    Join Date
    Feb 2007
    Posts
    102

    Default

    Mmm...
    1. have you set correctly data source from websphere console or file?
    2. try to remove <res-sharing-scope>Shareable</res-sharing-scope>

    Hope it helps

  5. #5
    Join Date
    Nov 2006
    Posts
    193

    Default

    Hi Ghed,

    Thanx bery much for your ideas and responses. I finally sorted my WAS resource issues. MAN! What an effort!

    Heres my resources config steps:

    In web.xml I have:
    ==============

    <resource-ref id="ResourceRef_eeBridgeXADS">
    <description>
    </description>
    <res-ref-name>jdbc/eeBridgeXADS</res-ref-name>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
    <res-type>javax.sql.DataSource</res-type>
    </resource-ref>
    <resource-ref id="ResourceRef_eeBridgeXAQConFact">
    <description>
    </description>
    <res-ref-name>jms/eeBridgeQConFact</res-ref-name>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
    <res-type>javax.jms.QueueConnectionFactory</res-type>
    </resource-ref>

    In WAS I have DS and Q Conn Factory configured with jndi names like:
    ================================================== ===
    eeBridgeConFact
    eeBridgeXADS

    When I deploy the webapp, WAS asks me to map the resources in the web.xml to the appserver jndi names.

    My Spring Int context file has the resources declared as such:
    ===============================================

    <jee:jndi-lookup id="dataSource"
    jndi-name="java:comp/env/jdbc/eeBridgeXADS"
    resource-ref="true">
    </jee:jndi-lookup>

    <jee:jndi-lookup id="connectionFactoryMQ"
    jndi-name="java:comp/env/jms/eeBridgeQConFact"
    resource-ref="true">
    </jee:jndi-lookup>

  6. #6
    Join Date
    Feb 2007
    Posts
    102

    Default

    Glad to hear your news!
    Enjoy now!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •