Hi Arul,
Can you send the code of your class? You may have an error in the
static block of code, from the JavaDoc of
java.lang.ExceptionInInitializerError:
Signals that an unexpected exception has occurred in a static
initializer. An ExceptionInInitializerError is thrown to
indicate that an exception occurred during evaluation of a static
initializer or the initializer for a static variable.
and Jersey cannot instantiate the class because the error occured. If
you notice the stack trace Jersey is just calling Class.newInstance().
I suspect that you keep seeing the error because your resource class
is still hanging around and has not been cleaned up or that Jetty is
running in some continuous deployment mode.
BTW if you are using the @Singleton annotation then you may be able
to do your initialization in the constructor rather than the static
block.
Paul.
On Apr 23, 2008, at 8:07 PM, Arul Dhesiaseelan wrote:
> Hi,
>
> I have a singleton resource which has a static initializer block
> where I do some house keeping. I am using Jersey 0.7.
>
> When I try to start the server, I am getting the following error. I
> tried removing the singleton and even then I see the same error.
>
> Am I violating the resource contract? Please clarify.
>
> 2008-04-23 11:39:10.528::WARN: failed Jersey Web Application
> java.lang.ExceptionInInitializerError
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0
> (Native Method)
>
> at sun.reflect.NativeConstructorAccessorImpl.newInstance
> (NativeConstruct
> orAccessorImpl.java:39)
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance
> (DelegatingC
> onstructorAccessorImpl.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.ws.rest.impl.application.WebApplicationImpl
> $DefaultComponentP
> rovider.getInstance(WebApplicationImpl.java:293)
> at com.sun.ws.rest.impl.resource.SingletonProvider.init
> (SingletonProvide
> r.java:44)
> at
> com.sun.ws.rest.spi.resource.ResourceProviderFactory.createProvider(R
> esourceProviderFactory.java:115)
> at com.sun.ws.rest.impl.model.ResourceClass.<init>
> (ResourceClass.java:85
> )
> at
> com.sun.ws.rest.impl.application.WebApplicationImpl.newResourceClass(
> WebApplicationImpl.java:214)
> at
> com.sun.ws.rest.impl.application.WebApplicationImpl.getResourceClass(
> WebApplicationImpl.java:188)
> at
> com.sun.ws.rest.impl.application.WebApplicationImpl.processRootResour
> ces(WebApplicationImpl.java:480)
> at
> com.sun.ws.rest.impl.application.WebApplicationImpl.initiate(WebAppli
> cationImpl.java:370)
> at
> com.sun.ws.rest.impl.application.WebApplicationImpl.initiate(WebAppli
> cationImpl.java:318)
> at
> com.sun.ws.rest.spi.container.servlet.ServletContainer.initiate(Servl
> etContainer.java:392)
> at
> com.sun.ws.rest.spi.container.servlet.ServletContainer.load(ServletCo
> ntainer.java:306)
> at
> com.sun.ws.rest.spi.container.servlet.ServletContainer.init(ServletCo
> ntainer.java:119)
> at org.mortbay.jetty.servlet.ServletHolder.initServlet
> (ServletHolder.jav
> a:433)
> at org.mortbay.jetty.servlet.ServletHolder.doStart
> (ServletHolder.java:25
> 6)
> at org.mortbay.component.AbstractLifeCycle.start
> (AbstractLifeCycle.java:
> 39)
> at org.mortbay.jetty.servlet.ServletHandler.initialize
> (ServletHandler.ja
> va:612)
> at org.mortbay.jetty.servlet.Context.startContext
> (Context.java:139)
> at org.mortbay.jetty.webapp.WebAppContext.startContext
> (WebAppContext.jav
> a:1220)
> at org.mortbay.jetty.handler.ContextHandler.doStart
> (ContextHandler.java:
> 510)
> at org.mortbay.jetty.webapp.WebAppContext.doStart
> (WebAppContext.java:448
> )
> at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart
> (Jetty6Plug
> inWebAppContext.java:110)
> at org.mortbay.component.AbstractLifeCycle.start
> (AbstractLifeCycle.java:
> 39)
> at org.mortbay.jetty.handler.HandlerCollection.doStart
> (HandlerCollection
> .java:152)
> at org.mortbay.jetty.handler.ContextHandlerCollection.doStart
> (ContextHan
> dlerCollection.java:156)
> at org.mortbay.component.AbstractLifeCycle.start
> (AbstractLifeCycle.java:
> 39)
> at org.mortbay.jetty.handler.HandlerCollection.doStart
> (HandlerCollection
> .java:152)
> at org.mortbay.component.AbstractLifeCycle.start
> (AbstractLifeCycle.java:
> 39)
> at org.mortbay.jetty.handler.HandlerWrapper.doStart
> (HandlerWrapper.java:
> 130)
> at org.mortbay.jetty.Server.doStart(Server.java:222)
> at org.mortbay.component.AbstractLifeCycle.start
> (AbstractLifeCycle.java:
> 39)
> at org.mortbay.jetty.plugin.Jetty6PluginServer.start
> (Jetty6PluginServer.
> java:132)
> at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty
> (AbstractJettyMo
> jo.java:357)
> at org.mortbay.jetty.plugin.AbstractJettyMojo.execute
> (AbstractJettyMojo.
> java:293)
> at org.mortbay.jetty.plugin.Jetty6RunWar.execute
> (Jetty6RunWar.java:67)
> at org.apache.maven.plugin.DefaultPluginManager.executeMojo
> (DefaultPlugi
> nManager.java:447)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
> ultLifecycleExecutor.java:539)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandalone
> Goal(DefaultLifecycleExecutor.java:493)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
> ltLifecycleExecutor.java:463)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
> dleFailures(DefaultLifecycleExecutor.java:311)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
> ts(DefaultLifecycleExecutor.java:278)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
> fecycleExecutor.java:143)
> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:
> 333)
> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
> at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke
> (NativeMethodAccessorImpl.
> java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke
> (DelegatingMethodAcces
> sorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.codehaus.classworlds.Launcher.launchEnhanced
> (Launcher.java:315)
> at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
> at org.codehaus.classworlds.Launcher.mainWithExitCode
> (Launcher.java:430)
>
> at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
>
>
> Thank you,
> Arul
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>