java.lang.NoClassDefFoundError:无法在 Jboss 5.0 EAP 上初始化类 org.apache.poi.POIXMLDocument [英] java.lang.NoClassDefFoundError: Could not initialize class org.apache.poi.POIXMLDocument on Jboss 5.0 EAP

查看:37
本文介绍了java.lang.NoClassDefFoundError:无法在 Jboss 5.0 EAP 上初始化类 org.apache.poi.POIXMLDocument的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Jboss 5.0 EAP 中出现以下异常,但在 JBoss 5.1 GA 中运行良好.

Getting following exception in Jboss 5.0 EAP but it work fine in JBoss 5.1 GA.

我们使用的是 POI 3.7 并且包含的​​ jars

we are using POI 3.7 and jars included are

  • poi-3.7.jar
  • poi-ooxml-schemas.jar
  • poi-ooxml.jar

堆栈跟踪是

ERROR [org.apache.catalina.core.ContainerBase.[jboss.ueb].[localhost].[fesbcon-Fig].[Faces Servlet]]
    3;13;44.4g3pM (http-0.0.0.0-8280-1) Servlet.service() -For servlet Faces Servlet threu exception
    java.lang.NoClassDe-FFoundError: Could not initialize class org.apache.poi.POIXMLDocument
    at org.apache.poi.ss.usermodel.HorkbookFactory.create(HorkbookFactory.java:62)
    at com.-Ferguson.esb.con-Fig.controller.AssociationsExcelUploadController.submit(Unknoun Source)
    at sun.re-Flect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.re-Flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.re-Flect.DelegatingMethodAccessorImpl.invoke(Delegating?ethodAccessorImpl.java:25)
    at java.lang.re-Flect.Method.invoke(Method.java:597)
    at org.apache.my-Faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
    at org.apache.my-Faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)

请建议如何在 JBoss 5.0 EAP 中解决此问题

Please Advise how to solve this issue in JBoss 5.0 EAP

推荐答案

看起来您的应用程序正在抛出您所看到的异常,因为在 JBoss 5.0 下运行时不存在 Apache XMLBeans JAR 或类.似乎 Apache POI 正在尝试加载类 org.apache.xmlbeans.XMLOptions 但它找不到这个类.

It looks like you're application is throwing the exception you're seeing because an Apache XMLBeans JAR or class is not present when running under JBoss 5.0. It seems Apache POI is trying to load the class org.apache.xmlbeans.XMLOptions but it cannot find this class.

消息Could not initialize class SomeClass表明JVM已经两次尝试加载和静态初始化类SomeClass失败.在这种情况下,有问题的类是 org.apache.poi.POIXMLDocument.

The message Could not initialize class SomeClass indicates that the JVM has twice tried and failed to load and statically initialize the class SomeClass. In this case, the class in question is org.apache.poi.POIXMLDocument.

类的静态初始化包括静态初始化其超类、为所有 static 字段赋值和运行所有 static 初始化块.POIXMLDocument 类有一些 static String 常量,不会引起任何问题,但没有静态初始化程序.然而,它是 POIXMLDocumentPart,它是Object的子类,具有如下静态初始化代码:

Static initialization for a class consists of statically initializing its superclass, assigning values to all static fields and running all static initializer blocks. The POIXMLDocument class has a few static String constants, which won't cause any problem, but no static initializer. It is however a subclass of POIXMLDocumentPart, which is a subclass of Object and which has the following static initialization code:

    private static POILogger logger = POILogFactory.getLogger(POIXMLDocumentPart.class);

    public static final XmlOptions DEFAULT_XML_OPTIONS;
    static {
        DEFAULT_XML_OPTIONS = new XmlOptions();
        DEFAULT_XML_OPTIONS.setSaveOuter();
        DEFAULT_XML_OPTIONS.setUseDefaultNamespace();
        DEFAULT_XML_OPTIONS.setSaveAggressiveNamespaces();
    }

如果 JVM 无法加载所有 POILoggerPOILogFactoryXmlOptions 类,则此静态初始化将失败.

This static initialization will fail if the JVM cannot load all of the POILogger, POILogFactory and XmlOptions classes.

POILoggerPOILogFactory 类都是从 org.apache.poi.util.POILogFactory 包中导入的,两个类都包含在 poi-3.7.jar 中,所以它们不是这里的问题.因此,通过消除,似乎必须缺少 XmlOptions 类,import 来自 org.apache.xmlbeans.XmlOptions.

The POILogger and POILogFactory classes are both imported from the package org.apache.poi.util.POILogFactory, and both classes are contained within poi-3.7.jar, so they're not the problem here. So, by elimination, it seems the XmlOptions class, imported from org.apache.xmlbeans.XmlOptions, must be missing.

我在 xmlbeans-2.6.0.ziplib 文件夹中的 xbean.jar 中找到了这个 XMLOptions 可从镜像之一下载此处.

I found this XMLOptions class within xbean.jar contained within the lib folder of xmlbeans-2.6.0.zip downloadable from one of the mirrors here.

在我看来,添加这个 JAR 可能会解决 JBoss 5.0 EAP 上的问题.但是,我知道您说您的应用程序在 JBoss 5.1 GA 中运行良好,这对我来说意味着 JBoss 5.1 GA 包含此 JAR 的副本,而 5.0 EAP 则没有.因此,我不确定解决此问题的最佳方法是什么.我会犹豫是否将这个 XMLBeans JAR 添加到您的应用程序中,因为这样做可能会导致在 JBoss 5.1 下运行它时出现问题.不过,我不知道是否有一种方法可以向 JBoss 5.0 添加额外的库"JAR - 也许这值得一看?

It seems likely to me that adding this JAR will fix the problem on JBoss 5.0 EAP. However, I'm aware you said your application works fine in JBoss 5.1 GA, which implies to me that JBoss 5.1 GA contains a copy of this JAR whereas 5.0 EAP doesn't. As a result I'm not sure what the best way to fix this problem is. I'd be hesitant to add this XMLBeans JAR to your application as doing so may cause issues when you run it under JBoss 5.1. I don't know whether there's a way of adding extra 'library' JARs to JBoss 5.0, though - perhaps that's worth looking at?

这篇关于java.lang.NoClassDefFoundError:无法在 Jboss 5.0 EAP 上初始化类 org.apache.poi.POIXMLDocument的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆