tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject Re: Tomcat 7.0.11 embedded does not load context.xml [SEC=UNCLASSIFIED]
Date Tue, 14 Jun 2011 11:07:34 GMT
On 14/06/2011 05:14, Fraser, James wrote:
> UNCLASSIFIED 
> 
> Hi, 
> 
> I am trying to embed Tomcat 7.0.11 into my standard web application.
> This web application defines some Resource elements in
> META-INF/context.xml - yet, Tomcat is not loading this file.

addWebapp should return a Context object. You'll need to call
setConfigFile() on that Context object.

Mark

> 
>         tomcat = new Tomcat();
>         tomcat.setBaseDir(".");
>         tomcat.setPort(8084);
>         tomcat.addWebapp("/", System.getProperty("user.dir") +
> "/build/web");
>         tomcat.setHostname("localhost");
>         tomcat.enableNaming();
>         tomcat.start(); 
> 
> Causes the following error: 
> 
> javax.naming.NamingException: Cannot create resource instance
>         at
> org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceE
> nvFactory.java:117)
>         at
> javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
>         at
> org.apache.naming.NamingContext.lookup(NamingContext.java:826)
>         at
> org.apache.naming.NamingContext.lookup(NamingContext.java:145)
>         at
> org.apache.naming.NamingContext.lookup(NamingContext.java:814)
>         at
> org.apache.naming.NamingContext.lookup(NamingContext.java:159)
>         at
> dsto.adiib.ws.harmoniser.AdiibHarmoniser.<init>(AdiibHarmoniser.java:113
> )
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
>         at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorA
> ccessorImpl.java:39)
>         at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCons
> tructorAccessorImpl.java:27)
>         at
> java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>         at java.lang.Class.newInstance0(Class.java:355)
>         at java.lang.Class.newInstance(Class.java:308)
>         at
> com.sun.xml.ws.api.server.InstanceResolver.createNewInstance(InstanceRes
> olver.java:215)
>         at
> com.sun.xml.ws.api.server.InstanceResolver.createDefault(InstanceResolve
> r.java:180)
>         at
> com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.jav
> a:123)
>         at
> com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:505)
>         at
> com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(D
> eploymentDescriptorParser.java:253)
>         at
> com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(Deploymen
> tDescriptorParser.java:147)
>         at
> com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextIn
> itialized(WSServletContextListener.java:124)
> 
>         at
> org.apache.catalina.core.StandardContext.listenerStart(StandardContext.j
> ava:4681)
>         at
> org.apache.catalina.core.StandardContext$1.call(StandardContext.java:518
> 4)
>         at
> org.apache.catalina.core.StandardContext$1.call(StandardContext.java:517
> 9)
>         at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecuto
> r.java:886)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.ja
> va:908)
>         at java.lang.Thread.run(Thread.java:662) 
> 
> Line 113 of AdiibHarmoniser is like so: 
> 
> HarmoniserImplConfigBean harmoniserImplConfigBean =
> (HarmoniserImplConfigBean)envCtx.lookup(beanName); 
> 
> This essentially loads some external beans for me. 
> 
> My context.xml looks like so: 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <Context antiJARLocking="true" path="/AdiibHarmoniser">
>   <Resource auth="Container" csdTypeComparatorValue="VIDEO"
> csdViewDataModel="NSIL_VIDEO_VIEW" dibTextPath="//video"
> factory="org.apache.naming.factory.BeanFactory" harmonise="true"
> harmoniserClassName="dsto.adiib.ws.harmoniser.FmvHarmoniser"
> name="bean/FmvFactory" subscriptionId="adiibFmvHarmoniser"
> type="dsto.adiib.ws.harmoniser.HarmoniserImplConfigBean"/>
> 
>   <Resource auth="Container" csdTypeComparatorValue="IMAGERY"
> csdViewDataModel="NSIL_IMAGERY_VIEW" dibTextPath="//nitf"
> factory="org.apache.naming.factory.BeanFactory" harmonise="true"
> harmoniserClassName="dsto.adiib.ws.harmoniser.NitfHarmoniser"
> name="bean/NitfFactory" subscriptionId="adiibNitfHarmoniser"
> type="dsto.adiib.ws.harmoniser.HarmoniserImplConfigBean"/>
> 
> </Context> 
> 
> Using normal Tomcat (non embedded) everything works fine. I found a post
> similar to my problem here:
> http://stackoverflow.com/questions/5238451/jndi-jdbc-data-source-in-embe
> dded-tomcat-7, yet this caused a followon exception.
> 
> java.lang.NoSuchMethodError:
> org.apache.catalina.Context.setConfigFile(Ljava/lang/String;)V 
> 
> Any ideas? 
> 
> Kind Regards, 
> 
> James 
> 
> IMPORTANT: This email remains the property of the Department of Defence
> and is subject to the jurisdiction of section 70 of the Crimes Act 1914.
> If you have received this email in error, you are requested to contact
> the sender and delete the email. 
> 
> 
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message