Problem lookingup datasource with JNDI in JBoss EAP 6.4.

Latest response

Hi,

we are currently in JBoss EAP 5.1.2 and are migrating to JBoss EAP 6.4.

I am facing serious problem in datasource lookup with JNDI from spring application context xml.
from management console, I have tested the datasource connection and it is success.

in application-context.xml.

<jee:jndi-lookup id="dataSourceCMC" jndi-name="java:jboss/datasources/CmcDS" />

in standalone-full.xml

            <datasource jta="true" jndi-name="java:jboss/datasources/CmcDS" pool-name="CmcDS" enabled="true" use-ccm="true" statistics-enabled="true">
                <connection-url>jdbc:oracle:thin:@cmcdevdb:1521:CMC</connection-url>
                <driver-class>oracle.jdbc.OracleDriver</driver-class>
                <driver>Oracle11g</driver>
                <pool>
                    <min-pool-size>0</min-pool-size>
                    <max-pool-size>10</max-pool-size>
                    <prefill>true</prefill>
                    <use-strict-min>true</use-strict-min>
                </pool>
                <security>
                    <user-name>cmc</user-name>
                    <password>cmc123</password>
                </security>
                <validation>
                    <check-valid-connection-sql>SELECT 1 FROM DUAL</check-valid-connection-sql>
                    <validate-on-match>true</validate-on-match>
                    <background-validation>false</background-validation>
                </validation>
                <statement>
                    <prepared-statement-cache-size>10</prepared-statement-cache-size>
                    <share-prepared-statements>false</share-prepared-statements>
                </statement>
            </datasource>

when deploying the application, I am getting the error below.
Can someone please help me to resolve, I tried a lot in JBoss forum but couldn't get any solution for this.

Thank you in advance...

21:44:59,216 ERROR [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 62) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceCMC': Invocation of init method failed; nested exception is javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) [org.springframework.context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) [org.springframework.context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276) [org.springframework.web-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197) [org.springframework.web-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) [org.springframework.web-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3339) [jbossweb-7.5.17.Final-redhat-1.jar:7.5.17.Final-redhat-1]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3780) [jbossweb-7.5.17.Final-redhat-1.jar:7.5.17.Final-redhat-1]
at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:163) [jboss-as-web-7.5.10.Final-redhat-2.jar:7.5.10.Final-redhat-2]
at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:61) [jboss-as-web-7.5.10.Final-redhat-2.jar:7.5.10.Final-redhat-2]
at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:96) [jboss-as-web-7.5.10.Final-redhat-2.jar:7.5.10.Final-redhat-2]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_79]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_79]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_79]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_79]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_79]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1678) [jnp-client.jar:]
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1795) [jnp-client.jar:]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:693) [jnp-client.jar:]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686) [jnp-client.jar:]
at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_79]
at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_79]
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154) [org.springframework.context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87) [org.springframework.context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152) [org.springframework.context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178) [org.springframework.context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95) [org.springframework.context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105) [org.springframework.context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201) [org.springframework.context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187) [org.springframework.context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
... 23 more
Caused by: java.net.SocketTimeoutException: Receive timed out
at java.net.TwoStacksPlainDatagramSocketImpl.receive0(Native Method) [rt.jar:1.7.0_79]
at java.net.TwoStacksPlainDatagramSocketImpl.receive(TwoStacksPlainDatagramSocketImpl.java:114) [rt.jar:1.7.0_79]
at java.net.DatagramSocket.receive(DatagramSocket.java:816) [rt.jar:1.7.0_79]
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1647) [jnp-client.jar:]
... 38 more

Amarender Adupa's picture

Responses

Hi,

Try adding the jndi environment details to the configuration file:

<bean>  
......  
<property name="jndiEnvironment">  
 <props>  
 <!-- JBoss JNDI environment entries -->  
 <prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>  
 <prop key="java.naming.provider.url">jnp://localhost:1099</prop>  
 </props>  
</property>  
</bean>  

Regards, Anup

Could you tell where are you doing the lookup? If you are using EAP 6 why do you have org.jnp.interfaces.NamingContext. in your stack trace?

Thanks for the response. I could somehow resolve that issue by updating the jboss-client.jar from the EAP\bin\client provided by JBoss 6.4. Now I am not getting any connection time out, but now after the successful deployment, I am getting another runtime error as below. this is JAX-WS webservice and the SOAPHandler is giving the problem.

java.lang.ClassCastException: org.apache.cxf.jaxws.context.WrappedMessageContext cannot be cast to javax.xml.ws.handler.soap.SOAPMessageContext

can someone please help me on this.

jboss-client.jar is a jar for JMS and EJB clients. I'm not sure what it is doing ?

Could you describe what you are trying to achieve?

Thanks @Tom Ross, Actually the application consists of Spring, Hibernate, JAX WS and JMS, this is currently working good in JBoss 5.1.2. I am migrating the application to JBoss 6.4. As part of this upgrade activity I was initially getting exceptions while deployment; related to JMS dependancy, later I could resolve it by placing jboss-client correct version into the spring module and later I was getting connection timeout with data source, I made adjusted some jar dependancies (removed jnp-client.jar and some other old jar references), finally I am able to deploy the application.

when I am running the request from SOAPUI, I am getting a Runtime error while handling the SOAP Message. I am not using cxf, but somehow it is referencing and causing ClassCastException.

java.lang.ClassCastException: org.apache.cxf.jaxws.context.WrappedMessageContext cannot be cast to javax.xml.ws.handler.soap.SOAPMessageContext

Was this helpful?

We appreciate your feedback. Leave a comment if you would like to provide more detail.
It looks like we have some work to do. Leave a comment to let us know how we could improve.