4

我在 Glassfish 3.1.2 上部署了一个 Rest Web 服务。我偶尔会得到一个特殊的例外。

[#|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"]->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)

我的 Web 服务在处理后在服务器上编组一个 xml。xml 包含在标签中设置的时间

GregorianCalendar gc = (GregorianCalendar) GregorianCalendar
            .getInstance();
globalContextObj.setDateOfCreation(DatatypeFactory.newInstance()
                        .newXMLGregorianCalendar(gc));

jaxb xml 对象是类的私有成员 var,将访问修饰符从 static 更改为 none 不会影响异常。我读到了WEB9031由类加载器无法加载 TimeZone 类库引起的异常。Glassfish 文档建议,在部署时,我们必须在控制台中提及公共库。但我没有公共图书馆。我认为异常中提到的 java.util.timezone 类正在被卸载或类似的东西。

如果有人有任何解决此问题的想法,请告诉我!!

4

2 回答 2

0

根据Oracle的说法,WEB9031的原因和解决方法是:

原因:此问题通常表明 Web 应用程序的类加载器已被缓存,并且正在尝试让它加载资源,即使与该类加载器相关联的 Web 应用程序已被取消部署

解决方案:确保与您的 Web 应用程序关联的类加载器没有被缓存并在您的 Web 应用程序的生命周期之后使用

由于您的问题似乎是零星的,因此听起来可能是缓存问题。java.util.TimeZone但就个人而言,我认为当 Glassfish 本身是 Java 应用程序的服务器时,没有必要要求 Glassfish 用户在 Glassfish 的类路径中放置一个标准 Java 类 ( )!从控制台启动域时提及包含的类的建议java.util.TimeZone可能只会起作用,因为它将库添加回类路径。

尝试停止并再次启动域以刷新缓存。

我面临着类似的问题,重新启动域似乎对我不起作用。我只是想我会建议你,因为听起来你没有尝试过。

于 2014-06-02T14:32:18.093 回答
0

执行以下步骤

  1. 取消部署 glassfish 服务器中部署的所有应用程序。

  2. 停止 glassfish 服务器。

  3. 清除 glassfish 缓存。(清除以下文件夹内容

    • $GLASSFISH_HOME/glassfish/domains/domain1/generated/*

    • $GLASSFISH_HOME/glassfish/domains/domain1/osgi-cache/*

    • $GLASSFISH_HOME/glassfish/domains/domain1/applications/*

  4. 现在重新启动 glassfish 服务器。

于 2017-08-10T05:50:34.737 回答