Hi,
Sorry to keep replying to my own question but I gathered two stack traces from
each of the calls to init that may be useful:
On startup (and this is the servlet also used by the post):
at
org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
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(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
On calling get (this is the one that fails and has no init-param information):
at
org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
at
org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:857)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:136)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Cheers,
Stuart
On 17 Oct 2012, at 09:15, Stuart Broad wrote:
> Hi,
>
> I wanted to add that I am accessing the servlet via a javascript request from
> Apache HTTP. As such I am setting the following in the header of the POST
> response:
>
> resp.setHeader( "Access-Control-Allow-Origin", mAllowedHost );
>
> Just wanted to mention this just in case it had anything to do with the
> init/param problem I am seeing.
>
> Cheers,
>
> Stuart
>
> On 16 Oct 2012, at 18:06, Stuart Broad wrote:
>
>>
>> Hi all,
>>
>> I am not sure why but my servlet init method is getting called more than
>> once and I am not sure why. Any help would be much appreciated.
>>
>> My web.xml is as follows:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <web-app>
>> <servlet>
>> <servlet-name>myserlvet</servlet-name>
>> <servlet-class>MyServlet</servlet-class>
>> <async-supported>true</async-supported>
>> <init-param>
>> <param-name>example</param-name>
>> <param-value>value</param-value>
>> </init-param>
>> <load-on-startup>1</load-on-startup>
>> </servlet>
>>
>> <servlet-mapping>
>> <servlet-name>myservlet</servlet-name>
>> <url-pattern>/poll</url-pattern>
>> <url-pattern>/run</url-pattern>
>> <url-pattern>/stop</url-pattern>
>> </servlet-mapping>
>> <listener>
>> <listener-class>MySessionListener</listener-class>
>> </listener>
>> </web-app>
>>
>> I am accessing over HTTPS. The initial POST seems to work ok:
>>
>> 0:0:0:0:0:0:0:1%0 - - [16/Oct/2012:16:53:54 +0100] "POST /myservlet/run
>> HTTP/1.1" 200 34
>>
>> But then this is followed by a GET which fails:
>>
>> 0:0:0:0:0:0:0:1%0 - - [16/Oct/2012:16:53:54 +0100] "GET
>> /myservlet/poll?_dc=1350402834770 HTTP/1.1" 500 2312
>>
>> The reason the GET fails is because the creation of the Servlet fails. This
>> is the second time the servlet init is called and for the second time the
>> init parameters are null (so it fails to be created). If I could figure out
>> why the init params are null the second time around I could probably come up
>> with a work around BUT my preference is to figure out why the init method is
>> being called twice.
>>
>> I bit more information:
>>
>> Tomcat version: apache-tomcat-7.0.29
>> Mac OS X 10.7.5
>>
>> Cheers,
>>
>> Stuart
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]