Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Glassfish 3.1.2上部署包含应用程序客户端的ear会引发异常_Java_Glassfish_Glassfish 3_Ear_Application Client - Fatal编程技术网

Java 在Glassfish 3.1.2上部署包含应用程序客户端的ear会引发异常

Java 在Glassfish 3.1.2上部署包含应用程序客户端的ear会引发异常,java,glassfish,glassfish-3,ear,application-client,Java,Glassfish,Glassfish 3,Ear,Application Client,我问这个问题只是为了我能自己回答,因为这两天我都快发疯了,其他人不应该像我一样痛苦 部署我的ear时,会出现如下异常: Exception while invoking class org.glassfish.appclient.server.core.AppClientServerApplication start method org.jvnet.hk2.component.ComponentException: injection failed on org.glassfish.appc

我问这个问题只是为了我能自己回答,因为这两天我都快发疯了,其他人不应该像我一样痛苦

部署我的ear时,会出现如下异常:


Exception while invoking class org.glassfish.appclient.server.core.AppClientServerApplication start method
org.jvnet.hk2.component.ComponentException: injection failed on org.glassfish.appclient.server.core.jws.JavaWebStartInfo.dch with class org.glassfish.appclient.server.core.jws.DeveloperContentHandler
    at org.jvnet.hk2.component.InjectionManager.error_injectionException(InjectionManager.java:284)
    at org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:161)
    at org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:93)
.
.
Caused by: org.jvnet.hk2.component.ComponentException: Failed to create class org.glassfish.appclient.server.core.jws.DeveloperContentHandler
.
.
Caused by: java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V
.
.

Exception while loading the app : injection failed on org.glassfish.appclient.server.core.jws.JavaWebStartInfo.dch with class org.glassfish.appclient.server.core.jws.DeveloperContentHandler
org.jvnet.hk2.component.ComponentException: Failed to create class org.glassfish.appclient.server.core.jws.DeveloperContentHandler
    at com.sun.hk2.component.ConstructorCreator.create(ConstructorCreator.java:71)
    at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:80)
.
.
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.glassfish.appclient.server.core.jws.DeveloperContentHandler
或者有时像这样:


Exception while invoking class org.glassfish.appclient.server.core.AppClientServerApplication start method
org.jvnet.hk2.component.ComponentException: injection failed on org.glassfish.appclient.server.core.jws.JavaWebStartInfo.dch with class org.glassfish.appclient.server.core.jws.DeveloperContentHandler
    at org.jvnet.hk2.component.InjectionManager.error_injectionException(InjectionManager.java:284)
    at org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:161)
    at org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:93)
.
.
Caused by: org.jvnet.hk2.component.ComponentException: Failed to create class org.glassfish.appclient.server.core.jws.DeveloperContentHandler
.
.
Caused by: java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V
.
.

Exception while loading the app : injection failed on org.glassfish.appclient.server.core.jws.JavaWebStartInfo.dch with class org.glassfish.appclient.server.core.jws.DeveloperContentHandler
org.jvnet.hk2.component.ComponentException: Failed to create class org.glassfish.appclient.server.core.jws.DeveloperContentHandler
    at com.sun.hk2.component.ConstructorCreator.create(ConstructorCreator.java:71)
    at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:80)
.
.
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.glassfish.appclient.server.core.jws.DeveloperContentHandler

这个bug令人费解,因为在一台机器上运行良好的ear文件可能无法在另一台机器上部署,服务器可能会被问题“感染”,并拒绝部署以前运行良好的ear。清除缓存和生成的文件并不能让它消失。

经过数小时的摆弄,我想我找到了答案-问题是由于ear lib文件夹中包含xerxes impl jar文件。我怀疑,通过某些类加载的奇怪之处,它正在取代服务器自己的xml解析器。这就解释了奇怪的感染问题,因为在服务器重新启动之前,类路径问题不会消失。这个问题可能会在任何xml解析器中表现出来,但我还没有检查


要解决此问题,请关闭glassfish,确保正在部署的ear中没有xerces,然后重新启动glassfish并部署新的clean ear文件。它应该会起作用。对我来说是这样的。如果做不到这一点,我认为你唯一的办法就是献血。

JDK定义了javax.xml.parsers.DocumentBuilderFactory接口,并提供了一个默认实现。服务提供者可以通过设置系统属性“javax.xml.parsers.DocumentBuilderFactory”来替换实现类。部署xerces时,它使用此属性提供自己的实现

javax.xml.parsers.DocumentBuilderFactory中的片段:

   public static DocumentBuilderFactory newInstance() {
    try {
        return (DocumentBuilderFactory) FactoryFinder.find(
            /* The default property name according to the JAXP spec */
            "javax.xml.parsers.DocumentBuilderFactory",
            /* The fallback implementation class name */
            "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
    } catch (FactoryFinder.ConfigurationError e) {
        throw new FactoryConfigurationError(e.getException(),
                                            e.getMessage());
    }

}
所有这些都适用于javax.xml.parsers.SAXParserFactory

选择解析器实现

如果未指定其他工厂类,则使用默认的SAXParserFactory类。要使用来自不同制造商的解析器,可以更改指向它的environment>变量的值。可以从命令行执行此操作:

java-Djavax.xml.parsers.SAXParserFactory=yourFactoryHere[…]

指定的工厂名称必须是完全限定的类名(包括所有包前缀>)。有关更多信息,请参阅>SAXParserFactory类的newInstance()方法中的文档


我相信,如果我们不在耳朵里放依赖罐,而是用glassfish([…]/ext或类似产品)提供,glassfish要求的献血数量会下降。但这当然可能只是统计数据和安慰剂。