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 ?
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.
>
>