You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Simon Conrad-Armes <si...@merant.com> on 2003/04/11 09:34:49 UTC
Embedded Catalina - Error loading JAR files from WEB-INF/lib
Hi,
I am running org.apache.catalina.startup.Embedded inside my Java app and
I cannot figure out why I am getting these errors. Hope someone finds
this interesting enough to make suggestions. Has anybody had better
success with embedding catalina ion their application? I would like to
hear about your setup.
My specs:
OS=WinXP
Tomcat=4.1.24
JDK=1.3.1
The following is the error I get. There is some mention of this on
newgroups and lists but I have yet to see an explanation. As far as I
can tell the naming resources (maybe something connected to
WARDirContext) is not getting initialized properly and the contained
resource in DirContextURLConnection is null
Creating engine
Creating host '' with appBase 'C:/proj/proto.war'
Creating context '' with docBase 'C:/proj/proto.war'
Adding engine (org.apache.catalina.core.StandardEngine/1.0)
Creating connector for address='127.0.0.1' port='8082' secure='false'
Adding connector (org.apache.coyote.tomcat4.CoyoteConnector2/1.0)
Creating context '/myaxis' with docBase 'C:\proj\output\myaxis.war'
Starting embedded server
Apache Tomcat/4.1.24
StandardContext[/myaxis]: Starting
StandardContext[/myaxis]: Processing start(), current available=false
StandardContext[/myaxis]: Configuring default Resources
StandardContext[/myaxis]: Configuring privileged default Loader
StandardContext[/myaxis]: Configuring default Manager
StandardContext[/myaxis]: Processing standard container startup
WebappLoader[/myaxis]: Deploying class repositories to work directory
C:\proj\work\_\_\myaxis
WebappLoader[/myaxis]: Deploy JAR /WEB-INF/lib/activation.jar to
C:\proj\work\_\_\myaxis\WEB-INF\lib\activation.jar
WebappLoader[/myaxis]: Deploy JAR /WEB-INF/lib/axis-ant.jar to
C:\proj\work\_\_\myaxis\WEB-INF\lib\axis-ant.jar
WebappLoader[/myaxis]: Deploy JAR /WEB-INF/lib/axis.jar to
C:\proj\work\_\_\myaxis\WEB-INF\lib\axis.jar
WebappLoader[/myaxis]: Deploy JAR /WEB-INF/lib/commons-discovery.jar to
C:\proj\work\_\_\myaxis\WEB-INF\lib\commons-discovery.jar
WebappLoader[/myaxis]: Deploy JAR /WEB-INF/lib/myaxis.jar to
C:\proj\work\_\_\myaxis\WEB-INF\lib\myaxis.jar
WebappLoader[/myaxis]: Deploy JAR /WEB-INF/lib/jaxrpc.jar to
C:\proj\work\_\_\myaxis\WEB-INF\lib\jaxrpc.jar
WebappLoader[/myaxis]: Deploy JAR /WEB-INF/lib/saaj.jar to
C:\proj\work\_\_\myaxis\WEB-INF\lib\saaj.jar
WebappLoader[/myaxis]: Deploy JAR /WEB-INF/lib/wsdl4j.jar to
C:\proj\work\_\_\myaxis\WEB-INF\lib\wsdl4j.jar
WebappLoader[/myaxis]: Deploy JAR /WEB-INF/lib/xalan.jar to
C:\proj\work\_\_\myaxis\WEB-INF\lib\xalan.jar
WebappLoader[/myaxis]: Deploy JAR /WEB-INF/lib/xercesImpl.jar to
C:\proj\work\_\_\myaxis\WEB-INF\lib\xercesImpl.jar
WebappLoader[/myaxis]: Deploy JAR /WEB-INF/lib/xmlParserAPIs.jar to
C:\proj\work\_\_\myaxis\WEB-INF\lib\xmlParserAPIs.jar
ContextConfig[/myaxis]: ContextConfig: Processing START
StandardContext[/myaxis]: Setting deployment descriptor public ID to
'-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN'
StandardContext[/myaxis]: Setting deployment descriptor public ID to
'-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN'
ContextConfig[/myaxis]: Accumulating TLD resource paths
ContextConfig[/myaxis]: Scanning <taglib> elements in web.xml
ContextConfig[/myaxis]: Scanning TLDs in /WEB-INF subdirectory
ContextConfig[/myaxis]: Scanning JARs in /WEB-INF/lib subdirectory
ContextConfig[/myaxis]: Adding path '/WEB-INF/lib/activation.jar'
ContextConfig[/myaxis]: Adding path '/WEB-INF/lib/axis-ant.jar'
ContextConfig[/myaxis]: Adding path '/WEB-INF/lib/axis.jar'
ContextConfig[/myaxis]: Adding path '/WEB-INF/lib/commons-discovery.jar'
ContextConfig[/myaxis]: Adding path '/WEB-INF/lib/myaxis.jar'
ContextConfig[/myaxis]: Adding path '/WEB-INF/lib/jaxrpc.jar'
ContextConfig[/myaxis]: Adding path '/WEB-INF/lib/saaj.jar'
ContextConfig[/myaxis]: Adding path '/WEB-INF/lib/wsdl4j.jar'
ContextConfig[/myaxis]: Adding path '/WEB-INF/lib/xalan.jar'
ContextConfig[/myaxis]: Adding path '/WEB-INF/lib/xercesImpl.jar'
ContextConfig[/myaxis]: Adding path '/WEB-INF/lib/xmlParserAPIs.jar'
ContextConfig[/myaxis]: Scanning JAR at resource path
'/WEB-INF/lib/commons-discovery.jar'
ContextConfig[/myaxis] Exception processing JAR at resource path
/WEB-INF/lib/commons-discovery.jar
javax.servlet.ServletException: Exception processing JAR at resource
path /WEB-INF/lib/commons-discovery.jar
at
org.apache.catalina.startup.ContextConfig.tldScanJar(ContextConfig.java:930)
at
org.apache.catalina.startup.ContextConfig.tldScan(ContextConfig.java:868)
at
org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:647)
at
org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:243)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:166)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:3567)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
at
org.apache.catalina.core.StandardHost.start(StandardHost.java:738)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347)
at org.apache.catalina.startup.Embedded.start(Embedded.java:994)
[lines snipped]
----- Root Cause -----
java.io.FileNotFoundException
at
org.apache.naming.resources.DirContextURLConnection.getInputStream(DirContextURLConnection.java:344)
at sun.net.www.protocol.jar.URLJarFile.retrieve(URLJarFile.java:126)
at
sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:34)
at
sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:76)
at
sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:83)
at
sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:67)
at
org.apache.catalina.startup.ContextConfig.tldScanJar(ContextConfig.java:906)
at
org.apache.catalina.startup.ContextConfig.tldScan(ContextConfig.java:868)
at
org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:647)
at
org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:243)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:166)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:3567)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
at
org.apache.catalina.core.StandardHost.start(StandardHost.java:738)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347)
at org.apache.catalina.startup.Embedded.start(Embedded.java:994)
[lines snipped]
ContextConfig[/myaxis]: Pipline Configuration:
ContextConfig[/myaxis]: org.apache.catalina.core.StandardContextValve/1.0
ContextConfig[/myaxis]: ======================
ContextConfig[/myaxis]: Marking this application unavailable due to
previous error(s)
NamingContextListener[/null//myaxis]: Creating JNDI naming context
NamingContextListener[/null//myaxis]: Resource parameters for
UserTransaction = null
StandardManager[/myaxis]: Seeding random number generator class
java.security.SecureRandom
StandardManager[/myaxis]: Seeding of random number generator has been
completed
StandardContext[/myaxis]: Context startup failed due to previous errors
StandardContext[/myaxis]: Stopping
StandardContext[/myaxis]: Stopping filters
StandardContext[/myaxis]: Processing standard container shutdown
ContextConfig[/myaxis]: ContextConfig: Processing STOP
StandardContext[/myaxis]: Sending application stop events
StandardContext[/myaxis]: Stopping complete
So far it has been a bit tricky getting the class loaders to work
properly, but I think I have that down. Of course, If I have missed
anything anyone can point to that might explain things.
* My application gets loaded in the system app classloader.
* Then I have my URLClassLoader which loads the catalina JARs (see
below)
* Then the WebappClassloader with my app.
bin/bootstrap.jar
common/activation.jar
common/ant.jar
common/commons-collections.jar
common/commons-dbcp.jar
common/commons-logging-api.jar
common/commons-pool.jar
common/jasper-compiler.jar
common/jasper-runtime.jar
common/jdbc2_0-stdext.jar
common/jndi.jar
common/jta.jar
common/log4j-1.2.4.jar
common/mail.jar
common/naming-common.jar
common/naming-factory.jar
common/naming-resources.jar
common/servlet.jar
server/catalina-ant.jar
server/catalina.jar
server/commons-beanutils.jar
server/commons-digester.jar
server/commons-fileupload-1.0-beta-1.jar
server/commons-logging.jar
server/commons-modeler.jar
server/jaas.jar
server/jakarta-regexp-1.2.jar
server/mx4j-jmx.jar
server/servlets-common.jar
server/servlets-default.jar
server/servlets-invoker.jar
server/servlets-manager.jar
server/servlets-webdav.jar
server/tomcat-coyote.jar
server/tomcat-http11.jar
server/tomcat-jk.jar
server/tomcat-jk2.jar
server/tomcat-util.jar
server/tomcat-warp.jar
The war file I am trying to load basically contains Apaxhe AXIS (1.1RC2)
and a few custom classes. The full list is:
/WEB-INF/lib/activation.jar
/WEB-INF/lib/axis-ant.jar
/WEB-INF/lib/axis.jar
/WEB-INF/lib/commons-discovery.jar
/WEB-INF/lib/myaxis.jar <=
/WEB-INF/lib/jaxrpc.jar
/WEB-INF/lib/saaj.jar
/WEB-INF/lib/wsdl4j.jar
/WEB-INF/lib/xalan.jar
/WEB-INF/lib/xercesImpl.jar
/WEB-INF/lib/xmlParserAPIs.jar
The embedded catalina is run from a URLClassLoader where I have added
all the JAR files in the Tomcat distro. The startup code is like so:
embeddedCatalina.setLogger(new SystemOutLogger());
embeddedCatalina.setDebug(5); //FIXME should be in config
// Create an engine
engine = embeddedCatalina.createEngine();
System.setProperty("catalina.home",
server.getServerContext().getServerPath());
host = embeddedCatalina.createHost(hostname, "C:/path/");
engine.addChild(host);
engine.setDefaultHost(host.getName());
context = embeddedCatalina.createContext("",
config.getRootApplication().toString());
host.addChild(context);
embeddedCatalina.addEngine(engine);
connector = embeddedCatalina.createConnector(address, port, false);
embeddedCatalina.addConnector(connector);
context = embeddedCatalina.createContext(contextPath, webapp);
host.addChild(context);
embeddedCatalina.start();
I am pretty sure I have not missed anything from the setup.