users@jersey.java.net

Re: [Jersey] REST call hanging in com.sun.jersey.server.impl.managedbeans.ManagedBeanComponentProviderFactoryInitilizer.java line 56 code

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 18 Dec 2009 10:41:57 +0100

Hi Mahesh,

First time i have seen this type of error.

Are you using Tomcat?

Does it only happen when you redeploy? i.e. is there any detectable
pattern to when things hang?

I am wondering if this is a bug in Tomcat, perhaps you can search for
any such issues on Tomcat forums?

Note that Jersey does not close any InitialContext instances it
creates, perhaps that also does not help? And, depending on what
version of Jersey you are using a few InitialContext instances will be
created.

Paul.


On Dec 17, 2009, at 10:49 PM, Mahesh Venkat wrote:

> Hi,
>
> I am using Jersey 1.4.1 with Jersey Spring Servlet.
>
> Quite frequently the servlet initialization call is hanging in the
> javax.naming.InitialContext.lookup(InitialContext.java:392 call
> invoked from
> com
> .sun
> .jersey
> .server
> .impl.managedbeans.ManagedBeanComponentProviderFactoryInitilizer in
> line #56
>
> It hangs for two hours in the first REST call after recycling the
> servlet engine. In the subsequent calls there is no issue.
>
> I initially suspected jaxb_impl library mismatch. However this
> isn't the case here.
>
> Surprisingly it has already located all my Provider classes and
> Resource classes ahead of this call.
>
>
> Here is the thread dump.
>
> "http-127.0.0.1-8080-1" daemon prio=6 tid=0x06e05400 nid=0xf1c
> runnable [0x044bf000]\par
> java.lang.Thread.State: RUNNABLE\par
> at java.net.SocketInputStream.socketRead0(Native Method)\par
> at java.net.SocketInputStream.read(SocketInputStream.java:
> 129)\par
> at java.io.BufferedInputStream.fill(BufferedInputStream.java:
> 218)\par
> at
> java.io.BufferedInputStream.read1(BufferedInputStream.java:258)\par
> at java.io.BufferedInputStream.read(BufferedInputStream.java:
> 317)\par
> - locked <0x35b2ddd0> (a java.io.BufferedInputStream)\par
> at java.io.ObjectInputStream
> $PeekInputStream.read(ObjectInputStream.java:2266)\par
> at java.io.ObjectInputStream
> $PeekInputStream.readFully(ObjectInputStream.java:2279)\par
> at java.io.ObjectInputStream
> $BlockDataInputStream.readShort(ObjectInputStream.java:\par
> at
> java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:
> 780)\par
> at java.io.ObjectInputStream.<init>(ObjectInputStream.java:
> 280)\par
> at
> org.jnp.interfaces.NamingContext.getServer(NamingContext.java:255)\par
> at
> org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1533)\par
> at
> org.jnp.interfaces.NamingContext.lookup(NamingContext.java:634)\par
> at
> org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)\par
> at javax.naming.InitialContext.lookup(InitialContext.java:
> 392)\par
> at
> com
> .sun
> .jersey
> .server
> .impl
> .managedbeans.ManagedBeanComponentProviderFactoryInitilizer.java:
> 56\par
> at
> com
> .sun
> .jersey
> .spi.container.servlet.WebComponent.configure(WebComponent.java:49\par
> at com.sun.jersey.spi.container.servlet.ServletContainer
> $InternalWebComponent.confi\par
> at
> com
> .sun
> .jersey.spi.container.servlet.WebComponent.load(WebComponent.java:
> 520)\par
> at
> com
> .sun
> .jersey.spi.container.servlet.WebComponent.init(WebComponent.java:
> 199)\par
> at
> com
> .sun
> .jersey
> .spi.container.servlet.ServletContainer.init(ServletContainer.java\par
> at
> com
> .sun
> .jersey
> .spi.container.servlet.ServletContainer.init(ServletContainer.java\par
> at javax.servlet.GenericServlet.init(GenericServlet.java:
> 212)\par
> at
> org
> .apache
> .catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:
> 1161)\par
> - locked <0x19ba4bb8> (a
> org.apache.catalina.core.StandardWrapper)\par
> at
> org
> .apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:
> 806)\par
> - locked <0x19ba4bb8> (a
> org.apache.catalina.core.StandardWrapper)\par
> at
> org
> .apache
> .catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
> 1\par
> at
> org
> .apache
> .catalina.core.StandardContextValve.invoke(StandardContextValve.java:
> 1\par
> at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke
> (SecurityAssociatio\par
> at
> org
> .jboss
> .web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:
> 84)\par
> at
> org
> .apache
> .catalina.core.StandardHostValve.invoke(StandardHostValve.java:
> 127)\par
> at
> org
> .apache
> .catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
> 102)\par
> at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke
> (CachedConnectionVa\par
> at
> org
> .apache
> .catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
> 109\par
> at
> org
> .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
> 262)\par
> at
> org
> .apache.coyote.http11.Http11Processor.process(Http11Processor.java:
> 844)\par
> at org.apache.coyote.http11.Http11Protocol
> $Http11ConnectionHandler.process(Http11Pr\par
> at org.apache.tomcat.util.net.JIoEndpoint
> $Worker.run(JIoEndpoint.java:446)\par
> at java.lang.Thread.run(Thread.java:619)\par
>
> From the Jersey server source code it is hanging in the following
> line:
>
> /**
> *
> * @author Paul.Sandoz_at_Sun.Com
> */
> public final class ManagedBeanComponentProviderFactoryInitilizer {
> private static final Logger LOGGER = Logger.getLogger(
>
> ManagedBeanComponentProviderFactoryInitilizer.class.getName());
>
> public static void initialize(ResourceConfig rc) {
> try {
> Object injectionMgr = new InitialContext().
>
> lookup
> ("com.sun.enterprise.container.common.spi.util.InjectionManager");
>
> My web.xml has the following configuration:
>
> <servlet>
> <servlet-name>JerseySpringRestServlet</servlet-name>
> <servlet-
> class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</
> servlet-class>
> <init-param>
> <param-
> name>com.sun.jersey.config.property.resourceConfigClass</param-name>
> <param-
> value>com.sun.jersey.api.core.PackagesResourceConfig</param-value>
> </init-param>
> <init-param>
> <param-
> name>com.sun.jersey.config.property.packages</param-name>
> <param-
> value>com.yodlee.rest;com.yodlee.app.account</param-value>
> </init-param>
> <init-param>
> <param-name>javax.ws.rs.Application</param-name>
> <param-
> value>com.yodlee.web.YodleeRestApplication</param-value>
> </init-param>
> </servlet>
>
> The Application.java code is
> public class YodleeRestApplication extends PackagesResourceConfig {
> public YodleeRestApplication() {
> super("com.yodlee.app.account;com.yodlee.rest");
> }
>
> } // YodleeRestApplication
>
>
> Any clues?
>
>
> Regards
> --Mahesh