title: glassfish Rest WEB9031 Exception
body: <p>I have a Rest Web service deployed on Glassfish 3.1.2. I sporadically get a particular exception on it.</p>
  
  <pre><code>[#|2012-12-20T10:48:33.796+0530|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=28;_ThreadName=Thread-2;|StandardWrapperValve[Jersey REST Service]: PWC1406: Servlet.service() for servlet Jersey REST Service threw exception
  org.codehaus.jackson.map.JsonMappingException: WEB9031: WebappClassLoader unable to load resource [java.util.TimeZone], because it has not yet been started, or was already stopped (through reference chain: spreadsheet.Exceldatalist["globalContext"]-&gt;spreadsheet.GlobalContext["dateOfCreation"])
      at org.codehaus.jackson.map.JsonMappingException.wrapWithPath(JsonMappingException.java:218)
      at org.codehaus.jackson.map.JsonMappingException.wrapWithPath(JsonMappingException.java:183)
      at org.codehaus.jackson.map.ser.std.SerializerBase.wrapAndThrow(SerializerBase.java:140)
      at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:158)
      at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112)
      at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446)
      at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150)
      at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112)
      at org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.java:610)
      at org.codehaus.jackson.map.ser.StdSerializerProvider.serializeValue(StdSerializerProvider.java:256)
      at org.codehaus.jackson.map.ObjectMapper.writeValue(ObjectMapper.java:1604)
      at org.codehaus.jackson.jaxrs.JacksonJsonProvider.writeTo(JacksonJsonProvider.java:558)
      at com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy.writeTo(JacksonProviderProxy.java:160)
      at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:306)
      at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1437)
      at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
      at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
      at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
      at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
      at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
      at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:619)
  Caused by: java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load resource [java.util.TimeZone], because it has not yet been started, or was already stopped
      at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1401)
      at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
      at java.lang.Class.getDeclaredMethods0(Native Method)
      at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
      at java.lang.Class.getDeclaredMethods(Class.java:1791)
      at org.codehaus.jackson.map.introspect.AnnotatedClass._addMemberMethods(AnnotatedClass.java:620)
      at org.codehaus.jackson.map.introspect.AnnotatedClass.resolveMemberMethods(AnnotatedClass.java:408)
      at org.codehaus.jackson.map.introspect.BasicClassIntrospector.classWithCreators(BasicClassIntrospector.java:185)
      at org.codehaus.jackson.map.introspect.BasicClassIntrospector.collectProperties(BasicClassIntrospector.java:157)
      at org.codehaus.jackson.map.introspect.BasicClassIntrospector.forSerialization(BasicClassIntrospector.java:96)
      at org.codehaus.jackson.map.introspect.BasicClassIntrospector.forSerialization(BasicClassIntrospector.java:16)
      at org.codehaus.jackson.map.SerializationConfig.introspect(SerializationConfig.java:974)
      at org.codehaus.jackson.map.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:251)
      at org.codehaus.jackson.map.ser.StdSerializerProvider._createUntypedSerializer(StdSerializerProvider.java:782)
      at org.codehaus.jackson.map.ser.StdSerializerProvider._createAndCacheUntypedSerializer(StdSerializerProvider.java:735)
      at org.codehaus.jackson.map.ser.StdSerializerProvider.findValueSerializer(StdSerializerProvider.java:344)
      at org.codehaus.jackson.map.ser.impl.PropertySerializerMap.findAndAddSerializer(PropertySerializerMap.java:39)
      at org.codehaus.jackson.map.ser.BeanPropertyWriter._findAndAddDynamic(BeanPropertyWriter.java:463)
      at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:441)
      at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150)
  </code></pre>
  
  <p>My Web service marshals an xml on the server after processing. The xml contains a time set in a tag</p>
  
  <pre><code>GregorianCalendar gc = (GregorianCalendar) GregorianCalendar
              .getInstance();
  globalContextObj.setDateOfCreation(DatatypeFactory.newInstance()
                          .newXMLGregorianCalendar(gc));
  </code></pre>
  
  <p>The jaxb xml object is private member var of the class, changing the access modifier from static to none is not affecting the exception. I read about the <code>WEB9031</code> exception that it is caused by the classloader not being able to load the TimeZone class library. Glassfish documentation suggests that while deploying we must mention the common libraries in the console. But I have no common libraries. I think that the java.util.timezone class mentioned in the exception is getting unloaded or something like that. </p>
  
  <p>If anyone has any idea to resolve this please let me know!!</p>