javax.naming.ConfigurationException after migratin

2020-04-10 06:15发布

问题:

I am migrating my application from java 1.5 and WAS 6.1 to java 1.7 and WAS 8.5 I am getting the following exception.

[8/20/12 12:01:00:286 EDT] 0000006b SystemErr     R org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxxDa
taSource' defined in class path resource [applicationContext-datasources.xml]: Invocation of init method failed; nested exception is javax.naming
.ConfigurationException: NamingManager.getURLContext cannot find the factory for this scheme: java
[8/20/12 12:01:00:286 EDT] 0000006b SystemErr     R     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBe
an(AbstractAutowireCapableBeanFactory.java:1338)
[8/20/12 12:01:00:286 EDT] 0000006b SystemErr     R     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean
(AbstractAutowireCapableBeanFactory.java:473)
[8/20/12 12:01:00:286 EDT] 0000006b SystemErr     R     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(Abstra
ctAutowireCapableBeanFactory.java:409)
[8/20/12 12:01:00:286 EDT] 0000006b SystemErr     R     at java.security.AccessController.doPrivileged(AccessController.java:252)
[8/20/12 12:01:00:286 EDT] 0000006b SystemErr     R     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(A
bstractAutowireCapableBeanFactory.java:380)
[8/20/12 12:01:00:286 EDT] 0000006b SystemErr     R     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFac
tory.java:264)
[8/20/12 12:01:00:286 EDT] 0000006b SystemErr     R     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(Defau
ltSingletonBeanRegistry.java:222)
[8/20/12 12:01:00:286 EDT] 0000006b SystemErr     R     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFacto
ry.java:261)
[8/20/12 12:01:00:287 EDT] 0000006b SystemErr     R     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory
.java:185)
[8/20/12 12:01:00:287 EDT] 0000006b SystemErr     R     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory
.java:164)
[8/20/12 12:01:00:287 EDT] 0000006b SystemErr     R     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingle
tons(DefaultListableBeanFactory.java:423)
[8/20/12 12:01:00:287 EDT] 0000006b SystemErr     R     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitializ
ation(AbstractApplicationContext.java:728)
[8/20/12 12:01:00:287 EDT] 0000006b SystemErr     R     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicatio
nContext.java:380)
[8/20/12 12:01:00:287 EDT] 0000006b SystemErr     R     at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.j
ava:255)
[8/20/12 12:01:00:287 EDT] 0000006b SystemErr     R     at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.jav
a:199)
[8/20/12 12:01:00:287 EDT] 0000006b SystemErr     R     at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderLis
tener.java:45)
[8/20/12 12:01:00:287 EDT] 0000006b SystemErr     R     at scv.cais.cms.jdr.webservice.context.ScvContextLoaderListener.contextInitialized(ScvContex
tLoaderListener.java:21)
[8/20/12 12:01:00:287 EDT] 0000006b SystemErr     R     at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1651)
[8/20/12 12:01:00:287 EDT] 0000006b SystemErr     R     at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:414)
[8/20/12 12:01:00:287 EDT] 0000006b SystemErr     R     at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88)
[8/20/12 12:01:00:287 EDT] 0000006b SystemErr     R     at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:169)
[8/20/12 12:01:00:287 EDT] 0000006b SystemErr     R     at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:746)
[8/20/12 12:01:00:287 EDT] 0000006b SystemErr     R     at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:634)
[8/20/12 12:01:00:287 EDT] 0000006b SystemErr     R     at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:424)
[8/20/12 12:01:00:287 EDT] 0000006b SystemErr     R     at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:718)
[8/20/12 12:01:00:287 EDT] 0000006b SystemErr     R     at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1170)
[8/20/12 12:01:00:288 EDT] 0000006b SystemErr     R     at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedAppl
icationImpl.java:1370)
[8/20/12 12:01:00:288 EDT] 0000006b SystemErr     R     at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:638)
[8/20/12 12:01:00:288 EDT] 0000006b SystemErr     R     at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:9
68)
[8/20/12 12:01:00:288 EDT] 0000006b SystemErr     R     at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:
769)
[8/20/12 12:01:00:288 EDT] 0000006b SystemErr     R     at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplicationDynamically(ApplicationMg
rImpl.java:1364)
[8/20/12 12:01:00:288 EDT] 0000006b SystemErr     R     at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2169)
[8/20/12 12:01:00:288 EDT] 0000006b SystemErr     R     at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:445
)
[8/20/12 12:01:00:288 EDT] 0000006b SystemErr     R     at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
[8/20/12 12:01:00:288 EDT] 0000006b SystemErr     R     at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:388
)
[8/20/12 12:01:00:288 EDT] 0000006b SystemErr     R     at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.jav
a:116)
[8/20/12 12:01:00:288 EDT] 0000006b SystemErr     R     at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$1.run(CompositionUnitMgrImpl.java:663
)
[8/20/12 12:01:00:288 EDT] 0000006b SystemErr     R     at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5339)
[8/20/12 12:01:00:288 EDT] 0000006b SystemErr     R     at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5555)
[8/20/12 12:01:00:288 EDT] 0000006b SystemErr     R     at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
[8/20/12 12:01:00:288 EDT] 0000006b SystemErr     R     at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitM
grImpl.java:677)
[8/20/12 12:01:00:288 EDT] 0000006b SystemErr     R     at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitM
grImpl.java:621)
[8/20/12 12:01:00:288 EDT] 0000006b SystemErr     R     at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:
1256)
[8/20/12 12:01:00:288 EDT] 0000006b SystemErr     R     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at java.lang.reflect.Method.invoke(Method.java:613)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:67)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at java.lang.reflect.Method.invoke(Method.java:613)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1196)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:1060)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerIntercepto
r.java:831)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:803)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1335)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:1228)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at com.ibm.ws.management.application.AppManagementImpl._startApplication(AppManagementImpl.j
ava:1482)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at com.ibm.ws.management.application.AppManagementImpl.startApplication(AppManagementImpl.ja
va:1371)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at com.ibm.ws.management.application.AppManagementImpl.startApplication(AppManagementImpl.ja
va:1320)
[8/20/12 12:01:00:289 EDT] 0000006b SystemErr     R     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[8/20/12 12:01:00:290 EDT] 0000006b SystemErr     R     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88)
[8/20/12 12:01:00:290 EDT] 0000006b SystemErr     R     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
[8/20/12 12:01:00:290 EDT] 0000006b SystemErr     R     at java.lang.reflect.Method.invoke(Method.java:613)
[8/20/12 12:01:00:290 EDT] 0000006b SystemErr     R     at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:67)
[8/20/12 12:01:00:290 EDT] 0000006b SystemErr     R     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[8/20/12 12:01:00:290 EDT] 0000006b SystemErr     R     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88)
[8/20/12 12:01:00:290 EDT] 0000006b SystemErr     R     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
[8/20/12 12:01:00:290 EDT] 0000006b SystemErr     R     at java.lang.reflect.Method.invoke(Method.java:613)
[8/20/12 12:01:00:290 EDT] 0000006b SystemErr     R     at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
[8/20/12 12:01:00:290 EDT] 0000006b SystemErr     R     at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1196)
[8/20/12 12:01:00:290 EDT] 0000006b SystemErr     R     at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:1060)
[8/20/12 12:01:00:290 EDT] 0000006b SystemErr     R     at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerIntercepto
r.java:831)
[8/20/12 12:01:00:290 EDT] 0000006b SystemErr     R     at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:803)
[8/20/12 12:01:00:290 EDT] 0000006b SystemErr     R     at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1335)
[8/20/12 12:01:00:290 EDT] 0000006b SystemErr     R     at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
[8/20/12 12:01:00:290 EDT] 0000006b SystemErr     R     at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:1228)
[8/20/12 12:01:00:290 EDT] 0000006b SystemErr     R     at com.ibm.ws.management.remote.AdminServiceForwarder.invoke(AdminServiceForwarder.java:346)
[8/20/12 12:01:00:290 EDT] 0000006b SystemErr     R     at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1458)
[8/20/12 12:01:00:291 EDT] 0000006b SystemErr     R     at javax.management.remote.rmi.RMIConnectionImpl.access$200(RMIConnectionImpl.java:100)
[8/20/12 12:01:00:291 EDT] 0000006b SystemErr     R     at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.j
ava:1303)
[8/20/12 12:01:00:291 EDT] 0000006b SystemErr     R     at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.jav
a:1391)
[8/20/12 12:01:00:291 EDT] 0000006b SystemErr     R     at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:823)
[8/20/12 12:01:00:291 EDT] 0000006b SystemErr     R     at javax.management.remote.rmi._RMIConnectionImpl_Tie.invoke(Unknown Source)
[8/20/12 12:01:00:291 EDT] 0000006b SystemErr     R     at javax.management.remote.rmi._RMIConnectionImpl_Tie._invoke(Unknown Source)
[8/20/12 12:01:00:291 EDT] 0000006b SystemErr     R     at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:669)
[8/20/12 12:01:00:291 EDT] 0000006b SystemErr     R     at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:523)
[8/20/12 12:01:00:291 EDT] 0000006b SystemErr     R     at com.ibm.rmi.iiop.ORB.process(ORB.java:523)
[8/20/12 12:01:00:291 EDT] 0000006b SystemErr     R     at com.ibm.CORBA.iiop.ORB.process(ORB.java:1575)
[8/20/12 12:01:00:291 EDT] 0000006b SystemErr     R     at com.ibm.rmi.iiop.Connection.doRequestWork(Connection.java:2992)
[8/20/12 12:01:00:291 EDT] 0000006b SystemErr     R     at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2875)
[8/20/12 12:01:00:291 EDT] 0000006b SystemErr     R     at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:64)
[8/20/12 12:01:00:291 EDT] 0000006b SystemErr     R     at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:118)
[8/20/12 12:01:00:291 EDT] 0000006b SystemErr     R     at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1783)
[8/20/12 12:01:00:291 EDT] 0000006b SystemErr     R Caused by: javax.naming.ConfigurationException: NamingManager.getURLContext cannot find the f
actory for this scheme: java
[8/20/12 12:01:00:291 EDT] 0000006b SystemErr     R     at com.ibm.ws.naming.util.Helpers.checkForUrlContext(Helpers.java:1631)
[8/20/12 12:01:00:291 EDT] 0000006b SystemErr     R     at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:160)
[8/20/12 12:01:00:292 EDT] 0000006b SystemErr     R     at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:179)
[8/20/12 12:01:00:292 EDT] 0000006b SystemErr     R     at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161)
[8/20/12 12:01:00:292 EDT] 0000006b SystemErr     R     at javax.naming.InitialContext.lookup(InitialContext.java:422)
[8/20/12 12:01:00:292 EDT] 0000006b SystemErr     R     at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155)
[8/20/12 12:01:00:292 EDT] 0000006b SystemErr     R     at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:88)
[8/20/12 12:01:00:292 EDT] 0000006b SystemErr     R     at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:153)
[8/20/12 12:01:00:292 EDT] 0000006b SystemErr     R     at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
[8/20/12 12:01:00:292 EDT] 0000006b SystemErr     R     at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
[8/20/12 12:01:00:292 EDT] 0000006b SystemErr     R     at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
[8/20/12 12:01:00:292 EDT] 0000006b SystemErr     R     at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.j
ava:200)
[8/20/12 12:01:00:292 EDT] 0000006b SystemErr     R     at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.j
ava:186)
[8/20/12 12:01:00:292 EDT] 0000006b SystemErr     R     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMe
thods(AbstractAutowireCapableBeanFactory.java:1369)
[8/20/12 12:01:00:292 EDT] 0000006b SystemErr     R     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBe
an(AbstractAutowireCapableBeanFactory.java:1335)
[8/20/12 12:01:00:292 EDT] 0000006b SystemErr     R     ... 96 more

I don't get this error when I use java 1.6

Here is the web.xml snippet I used for resource binding

  <resource-ref id="xxx-data-source">
            <description>XXX Datasource</description>
            <res-ref-name>jdbc/xxxDatasource</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
            <res-sharing-scope>Shareable</res-sharing-scope>
        </resource-ref>

I am able to bypass this error when I remove the java: comp/env prefix from my datasource name

for example: I am using

jdbc.jdr.datasource=jdbc/XxxDatasource

instaead of

jdbc.jdr.datasource=java:comp/env/jdbc/XxxDatasource

But I cannot remove this from all the places(in some jars).

did anyone face this issue before?

Thanks

回答1:

Even if the answer comes late I hope that it helps someonoe.

I also faced the problem of an

javax.naming.ConfigurationException: NamingManager.getURLContext cannot find the factory for this scheme: java

and in my case it arised because I used version 3.0 in my web.xml and an ibm-web-bnd.xmi descriptor.

When I used an ibm-web-bnd.xml descriptor instead it worked.

So for me it seems that you should use

  • for web-app version <= 2.4 a ibm-bnd-web.xmi descriptor
  • for web-app version >= 2.5 a ibm-bnd-web.xml descriptor

I also wrote a blog about my experience with this problem

https://www.link-intersystems.com/blog/2014/06/15/how-to-fix-ibm-websphere-jndi-exception-cannot-find-the-factory-for-this-scheme-java/