users@jersey.java.net

Re: [Jersey] Jersey on app engine

From: Erdinc Yilmazel <erdinc_at_yilmazel.com>
Date: Thu, 9 Apr 2009 12:08:56 +0100

I pulled the latest code from the trunk and deployed the application
to appengine servers. It didn't deploy successfully again since, the
NoClassDefFoundError was not caught by jersey in getContext method of
WebComponent class. So I added Error in the catch clause and rebuilt
jersey, and deployed my app again. This time it is complaining about
some other reflection/class loader issue which I have no idea about.

Here is the latest stacktrace:

java.lang.IllegalArgumentException: interface
javax.servlet.http.HttpServletRequest is not visible from class loader
        at java.lang.reflect.Proxy.getProxyClass(Unknown Source)
        at java.lang.reflect.Proxy.newProxyInstance(Unknown Source)
        at com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:382)
        at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:235)
        at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:448)
        at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:169)
        at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:281)
        at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:599)
        at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:99)

Maybe I should ask this in GAEJ mailing list...

Erdinc


On Thu, Apr 9, 2009 at 10:15 AM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
> I have committed a fix to the trunk, trapping Exception. Might take a couple
> of hours for the jars to make their way to the repo. Might be quicker to
> build from source if you want to verify.
>
> Paul.
>
> On Apr 9, 2009, at 11:02 AM, Paul Sandoz wrote:
>
>>
>> On Apr 9, 2009, at 11:00 AM, Erdinc Yilmazel wrote:
>>
>>> Yesterday I was trying to deploy to the development server on my local
>>> machine since my app engine java account was not approved yet. Today I
>>> uploaded the application and getting the same exception as dbaran.
>>>
>>> Here is my stack trace:
>>>
>>> java.lang.NoClassDefFoundError: javax.naming.InitialContext is a
>>> restricted class. Please see the Google App Engine developer's guide
>>> for more details.
>>>        at
>>> com.google.apphosting.runtime.security.shared.stub.javax.naming.InitialContext.<clinit>(InitialContext.java)
>>>        at
>>> com.sun.jersey.spi.container.servlet.WebComponent.getContext(WebComponent.java:674)
>>>        at
>>> com.sun.jersey.spi.container.servlet.WebComponent.configureJndiResources(WebComponent.java:649)
>>>        at
>>> com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:379)
>>>        at
>>> com.sun.jersey.spi.container.servlet.ServletContainer.configure(ServletContainer.java:461)
>>>        at
>>> com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:432)
>>>        at
>>> com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:167)
>>>        at
>>> com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:323)
>>>      ..
>>>
>>> Paul is it possible to make this initial context lookups conditional ?
>>> Or as you said before, can you catch Exception instead of
>>> NamingException ?
>>>
>>
>> Yes,  will fix it today.
>>
>> Paul.
>>
>>> Erdinc
>>> .
>>>
>>> On Thu, Apr 9, 2009 at 9:20 AM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
>>>>
>>>> On Apr 9, 2009, at 10:12 AM, dbaran wrote:
>>>>
>>>> I'm using the last stable, 1.0.2
>>>>
>>>> It seems that the javax.naming.InitialContext class is not in the JRE
>>>> classes white list of AppEngine java runtime.
>>>> But I don't understand why my code needs this class, thereas your code
>>>> not.
>>>> Perhaps I've to configure more in my web.xml?
>>>>
>>>> No.
>>>> Jersey checks to see if there are any interfaces registered and if so
>>>> attempts to look up instances for those objects in JNDI. An
>>>> InitialContext
>>>> is created before the check for any interfaces, so that creation occurs
>>>> regardless of configuration.  I can fix the code so that this error does
>>>> not
>>>> occur.
>>>> I do not understand why others are not getting the same error as you.
>>>> Paul.
>>>>
>>>>
>>>>
>>>> 2009/4/9 Paul Sandoz (via Nabble) <ml-user%2B51078-502935899@...>
>>>>>
>>>>> Hi,
>>>>>
>>>>> What version are you using? 1.0.2?
>>>>>
>>>>> The code path to get an instance of InitialContext  not conditionally
>>>>> executed, so it seems to work for some.
>>>>>
>>>>> This is the code in 1.0.3-SNAPSHOT:
>>>>>
>>>>>    private javax.naming.Context getContext() {
>>>>>        try {
>>>>>            return new InitialContext();
>>>>>        } catch (NamingException ex) {
>>>>>            return null;
>>>>>        }
>>>>>    }
>>>>>
>>>>> I could change that to catch Exception instead.
>>>>>
>>>>> Paul.
>>>>>
>>>>> On Apr 9, 2009, at 9:05 AM, dbaran wrote:
>>>>>
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I'm newbe on Jersey, but I try to deploy a simple class to try
>>>>>> Jersey on the AppEngine, and when I try to access to my REST
>>>>>> resource, I've a server error, with this log in the AppEngine admin
>>>>>> console :
>>>>>>
>>>>>> Uncaught exception from servlet
>>>>>> java.lang.NoClassDefFoundError: javax.naming.InitialContext is a
>>>>>> restricted class. Please see the Google App Engine developer's guide
>>>>>> for more details.
>>>>>> at
>>>>>> com
>>>>>> .google
>>>>>> .apphosting
>>>>>> .runtime
>>>>>> .security
>>>>>> .shared.stub.javax.naming.InitialContext.<clinit>(InitialContext.java)
>>>>>> at
>>>>>> com
>>>>>> .sun
>>>>>> .jersey
>>>>>> .spi.container.servlet.WebComponent.getContext(WebComponent.java:674)
>>>>>> at
>>>>>> com
>>>>>> .sun
>>>>>> .jersey
>>>>>> .spi
>>>>>> .container
>>>>>> .servlet.WebComponent.configureJndiResources(WebComponent.java:649)
>>>>>> at
>>>>>> com
>>>>>> .sun
>>>>>> .jersey
>>>>>> .spi.container.servlet.WebComponent.configure(WebComponent.java:379)
>>>>>> at
>>>>>> com
>>>>>> .sun
>>>>>> .jersey
>>>>>> .spi
>>>>>> .container.servlet.ServletContainer.configure(ServletContainer.java:
>>>>>> 461)
>>>>>> at
>>>>>> com
>>>>>> .sun
>>>>>> .jersey.spi.container.servlet.WebComponent.load(WebComponent.java:432)
>>>>>> at
>>>>>> com
>>>>>> .sun
>>>>>> .jersey.spi.container.servlet.WebComponent.init(WebComponent.java:167)
>>>>>> at
>>>>>> com
>>>>>> .sun
>>>>>> .jersey
>>>>>> .spi.container.servlet.ServletContainer.init(ServletContainer.java:
>>>>>> 197)
>>>>>> at
>>>>>> org
>>>>>> .mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:
>>>>>> 433)
>>>>>> at
>>>>>> org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:
>>>>>> 256)
>>>>>> at
>>>>>> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
>>>>>> 40)
>>>>>> at
>>>>>> org
>>>>>> .mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:
>>>>>> 612)
>>>>>> at org.mortbay.jetty.servlet.Context.startContext(Context.java:139)
>>>>>> at
>>>>>> org
>>>>>> .mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:
>>>>>> 1218)
>>>>>> at
>>>>>> org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:
>>>>>> 500)
>>>>>> at
>>>>>> org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
>>>>>> at
>>>>>> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
>>>>>> 40)
>>>>>> at
>>>>>> com
>>>>>> .google
>>>>>> .apphosting
>>>>>> .runtime
>>>>>> .jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:
>>>>>> 190)
>>>>>> at
>>>>>> com
>>>>>> .google
>>>>>> .apphosting
>>>>>> .runtime
>>>>>> .jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:167)
>>>>>> at
>>>>>> com
>>>>>> .google
>>>>>> .apphosting
>>>>>> .runtime
>>>>>> .jetty
>>>>>> .JettyServletEngineAdapter
>>>>>> .serviceRequest(JettyServletEngineAdapter.java:113)
>>>>>> at
>>>>>> com
>>>>>> .google
>>>>>> .apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:235)
>>>>>> at com.google.apphosting.base.RuntimePb$EvaluationRuntime
>>>>>> $6.handleBlockingRequest(RuntimePb.java:4547)
>>>>>> at com.google.apphosting.base.RuntimePb$EvaluationRuntime
>>>>>> $6.handleBlockingRequest(RuntimePb.java:4545)
>>>>>> at
>>>>>> com
>>>>>> .google
>>>>>> .net
>>>>>> .rpc
>>>>>> .impl
>>>>>> .BlockingApplicationHandler
>>>>>> .handleRequest(BlockingApplicationHandler.java:24)
>>>>>> at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:
>>>>>> 359)
>>>>>> at com.google.net.rpc.impl.Server$2.run(Server.java:792)
>>>>>> at
>>>>>> com
>>>>>> .google
>>>>>> .tracing.LocalTraceSpanRunnable.run(LocalTraceSpanRunnable.java:56)
>>>>>> at
>>>>>> com
>>>>>> .google
>>>>>> .tracing
>>>>>> .LocalTraceSpanBuilder
>>>>>> .internalContinueSpan(LocalTraceSpanBuilder.java:489)
>>>>>> at com.google.net.rpc.impl.Server.startRpc(Server.java:748)
>>>>>> at com.google.net.rpc.impl.Server.processRequest(Server.java:340)
>>>>>> at
>>>>>> com
>>>>>> .google
>>>>>> .net.rpc.impl.ServerConnection.messageReceived(ServerConnection.java:
>>>>>> 422)
>>>>>> at
>>>>>> com
>>>>>> .google.net.rpc.impl.RpcConnection.parseMessages(RpcConnection.java:
>>>>>> 319)
>>>>>> at
>>>>>> com
>>>>>> .google.net.rpc.impl.RpcConnection.dataReceived(RpcConnection.java:
>>>>>> 290)
>>>>>> at com.google.net.async.Connection.handleReadEvent(Connection.java:
>>>>>> 419)
>>>>>> at
>>>>>> com
>>>>>> .google
>>>>>> .net.async.EventDispatcher.processNetworkEvents(EventDispatcher.java:
>>>>>> 733)
>>>>>> at
>>>>>> com
>>>>>> .google.net.async.EventDispatcher.internalLoop(EventDispatcher.java:
>>>>>> 207)
>>>>>> at com.google.net.async.EventDispatcher.loop(EventDispatcher.java:
>>>>>> 101)
>>>>>> at
>>>>>> com.google.net.rpc.RpcService.runUntilServerShutdown(RpcService.java:
>>>>>> 249)
>>>>>> at com.google.apphosting.runtime.JavaRuntime
>>>>>> $RpcRunnable.run(JavaRuntime.java:373)
>>>>>> at java.lang.Thread.run(Unknown Source)
>>>>>>
>>>>>>
>>>>>> I've only initialized and mapped the ServletContainer in the
>>>>>> web.xml, like this:
>>>>>>
>>>>>>
>>>>>> <servlet>
>>>>>> <servlet-name>Jersey</servlet-name>
>>>>>> <servlet-
>>>>>> class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-
>>>>>> class>
>>>>>> <init-param>
>>>>>>  <param-name>com.sun.jersey.config.property.packages</param-name>
>>>>>>  <param-value>my.package</param-value>
>>>>>> </init-param>
>>>>>> <load-on-startup>1</load-on-startup>
>>>>>> </servlet>
>>>>>>
>>>>>> <servlet-mapping>
>>>>>> <servlet-name>Jersey</servlet-name>
>>>>>> <url-pattern>/*</url-pattern>
>>>>>> </servlet-mapping>
>>>>>>
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>>
>>>>>> Thanks for pointing that Paul.
>>>>>>
>>>>>>> BTW in your web.xml you have two types of Jersey configuration in the
>>>>>>> init-params. The following will take precedence:
>>>>>>>
>>>>>>>>   <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.joovie.webapp.pages</param-value>
>>>>>>>>   </init-param>
>>>>>>>
>>>>>>>>   <init-param>
>>>>>>>>      <param-name>javax.ws.rs.Application</param-name>
>>>>>>>>      <param-value>Joovie</param-value>
>>>>>>>>   </init-param>
>>>>>>>
>>>>>>>
>>>>>>> over the specific application class "Joovie" you have declared:
>>>>>>>
>>>>>>>>   <init-param>
>>>>>>>>      <param-name>javax.ws.rs.Application</param-name>
>>>>>>>>      <param-value>Joovie</param-value>
>>>>>>>>   </init-param>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@...
>>>>>> For additional commands, e-mail: users-help@...
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://n2.nabble.com/Jersey-on-app-engine-tp2604278p2609679.html
>>>>>> Sent from the Jersey mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@...
>>>>>> For additional commands, e-mail: users-help@...
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@...
>>>>> For additional commands, e-mail: users-help@...
>>>>>
>>>>
>>>>
>>>> ________________________________
>>>> View this message in context: Re: [Jersey] Jersey on app engine
>>>> Sent from the Jersey mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>