|
Problem(Abstract) |
When looking up a datasource using indirect lookup via a
resource reference, getting NameNotFoundException. The following logs are
likely to appear in the SystemErr.log
[5/18/06 15:07:28:407 EDT] 0000001c SystemErr R
javax.naming.NameNotFoundException: Name "comp/env/MetaDataSource1" not
found in context "java:".
at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1094)
at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:990)
at
com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1263)
at
com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:201)
at
com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:142)
at javax.naming.InitialContext.lookup(InitialContext.java:361)
at org.myorg.zff.dataAccess.AffDataSourceMgr.getDataSource(Unknown
Source)
at org.myorg.zff.dataAccess.MetadataDataSource.getConnection(Unknown
Source)
at org.myorg.zff.domain.metadata2.DatasetBuilder.getDataset(Unknown
Source)
at org.myorg.zff.domain.metadata2.DatasetFactory.getDataset(Unknown
Source)
at org.myorg.zff.domain.metadata2.DatasetFactory.createObject(Unknown
Source)
at org.myorg.zff.persistence.PersistentFactory.getPersistent(Unknown
Source)
at org.myorg.zff.persistence.PersistentFactory.getPersistent(Unknown
Source)
at org.myorg.szff.controller.navigation.SaffServlet.init(Unknown Source)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:274)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:1398)
at
com.ibm.wsspi.webcontainer.extension.WebExtensionProcessor.createServletWrapper(WebExtensionProcessor.java:86)
at
com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:755)
at
com.ibm.ws.webcontainer.webapp.WebApp.initializeTargetMappings(WebApp.java:498)
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:387)
at
com.ibm.ws.webcontainer.webapp.WebGroup.addWebApplication(WebGroup.java:114)
at
com.ibm.ws.webcontainer.VirtualHost.addWebApplication(VirtualHost.java:127)
at com.ibm.ws.webcontainer.WebContainer.addWebApp(WebContainer.java:854)
at
com.ibm.ws.webcontainer.WebContainer.addWebApplication(WebContainer.java:807)
at
com.ibm.ws.runtime.component.WebContainerImpl.install(WebContainerImpl.java:167)
at
com.ibm.ws.runtime.component.WebContainerImpl.start(WebContainerImpl.java:391)
at
com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1204)
at
com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1054)
at
com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:539)
at
com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:750)
at
com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:868)
at
com.ibm.ws.runtime.component.ApplicationMgrImpl$AppInitializer.run(ApplicationMgrImpl.java:1979)
at
com.ibm.ws.runtime.component.ComponentImpl$_AsynchInitializer.run(ComponentImpl.java:304)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1455)
The datasource was defined and could be seen in the dumpNameSpace as well
as in the resources.xml at the server level where the datasource was bound
to. |
|
|
|
Cause |
The lookup is done inside the Servlet.init method and the
servlet has the property load-on-startup enable (which can be seen
in the web.xml under the WEB-INF folder of the application war file). When
the Web container starts and calls the init method, Naming service is not
started yet, which causes the NameNotFoundException |
|
|
Resolving the
problem |
Disable load-on-startup on the servlet, or do the
lookup outside of the Servlet.init method. |
|
|
|
|
Cross Reference information |
Segment |
Product |
Component |
Platform |
Version |
Edition |
Application Servers |
Runtimes for Java Technology |
Java SDK |
|
|
|
|
|
|