-1

我想知道为什么我会收到 ExceptionInInitializerError?

平台:

  • 视窗;
  • 玻璃鱼 3.1.2.2;
  • 记事本++;
  • Cometd java库;
  • 码头图书馆;
  • Javac 命令行;

我正在逐步建立一个cometd Web 应用程序。经过一些调试后,我意识到码头:HttpClient 类导致 ExceptionInInitializerError,有人可以告诉我这是为什么吗?

我所做的是我去评论代码行,直到我发现问题发生在哪里。

这是发生错误的 CometD_Client 类:

import java.util.*;
import java.net.URL;
import org.cometd.bayeux.*;
import org.cometd.bayeux.client.*;
import org.cometd.server.*;
import org.cometd.client.*;
import org.cometd.common.*;
import org.cometd.client.transport.*;
import org.eclipse.jetty.client.*;

import javax.swing.*;

public class CometD_Client
{
    private String CurrentDate;

    private String BayeuxServerURL$;

    private HttpClient JettyHttpClient;

    private Map<String, Object> TransportOptions;

    private ClientTransport C_Transport;

    private BayeuxClient C_Session;

    private boolean HandIsShaken£ = false;

    DayTimePanel Panel;


    public CometD_Client(String BayeuxServerURL$, DayTimePanel Panel)
    {
        this.BayeuxServerURL$ = BayeuxServerURL$;
        this.Panel = Panel;

        // Create (and eventually set up) Jetty's HttpClient;
        JettyHttpClient = new HttpClient();

        /*
        try
        {
            JettyHttpClient.start();
        }
        catch(Exception E) {}
        /*
        */

        // Prepare the transport;
        //TransportOptions = new HashMap<String, Object>();

        //ClientTransport C_Transport = 
        //  LongPollingTransport.create(TransportOptions, 
        //                              JettyHttpClient  );

        //C_Session = new BayeuxClient(BayeuxServerURL$, C_Transport);

        //C_Session.handshake();

        //HandIsShaken£ = 
        //  C_Session.waitFor(1000, BayeuxClient.State.CONNECTED);

        if(HandIsShaken£)
        {
            // TO DO: Output that the handshake had succeed;
        }
        else
        {
            // TO DO: Output that the handshake had failed;
        }


        /*
        C_Session.getChannel(Channel.META_HANDSHAKE).addListener
        (
         new ClientSessionChannel.MessageListener()
         {
            @Override
            public void onMessage(ClientSessionChannel ThisMetaChanel,
                                  Message msg)
            {
                // TO DO: Output msg to check it out;

                C_Session.getChannel("/my/channel").subscribe
                (
                 new ClientSessionChannel.MessageListener()
                 {
                    @Override
                    public void onMessage(ClientSessionChannel ThisChanel,
                                          Message msg)
                    {
                        CurrentDate = msg.getJSON();

                        OutputCurrentDate();
                    }
                 }
                );
            }
         }
        );
        /*
        */
    }

    public boolean GetIfHandIsShaken£()
    {
        return HandIsShaken£;
    }

    public String GetCurrentDate()
    {
        return CurrentDate;
    }

    /*
    private void OutputCurrentDate()
    {
        Panel.GetJTF().setText(CurrentDate);
    }
    /*
    */
}

编辑:应用asadmin generate-jvm-report --type=thread这是我得到的日志:

<?xml version='1.0' encoding='UTF-8'?>
<hotspot_log version='160 1' process='4732' time_ms='1364843903652'>
<vm_version>
<name>
Java HotSpot(TM) Client VM
</name>
<release>
23.1-b03
</release>
<info>
Java HotSpot(TM) Client VM (23.1-b03) for windows-x86 JRE (1.7.0_05-b06), built on Jun 27 2012 00:51:27 by &quot;java_re&quot; with unknown MS VC++:1600
</info>
</vm_version>
<vm_arguments>
<args>
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9009 -XX:+UnlockDiagnosticVMOptions -XX:PermSize=64m -XX:MaxPermSize=192m -XX:NewRatio=2 -XX:+LogVMOutput -XX:LogFile=C:\glassfish3\glassfish\domains\domain1/logs/jvm.log -Xmx512m -javaagent:C:/glassfish3/glassfish/lib/monitor/flashlight-agent.jar -Dosgi.shell.telnet.maxconn=1 -Dfelix.fileinstall.disableConfigSave=false -Djdbc.drivers=org.apache.derby.jdbc.ClientDriver -Dfelix.fileinstall.dir=C:\glassfish3\glassfish/modules/autostart/ -Djavax.net.ssl.keyStore=C:\glassfish3\glassfish\domains\domain1/config/keystore.jks -Dosgi.shell.telnet.port=6666 -Djava.security.policy=C:\glassfish3\glassfish\domains\domain1/config/server.policy -Djava.awt.headless=true -Dfelix.fileinstall.log.level=2 -Dfelix.fileinstall.poll=5000 -Dcom.sun.aas.instanceRoot=C:\glassfish3\glassfish\domains\domain1 -Dosgi.shell.telnet.ip=127.0.0.1 -Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory -Djava.endorsed.dirs=C:\glassfish3\glassfish/modules/endorsed;C:\glassfish3\glassfish/lib/endorsed -Dcom.sun.aas.installRoot=C:\glassfish3\glassfish -Dfelix.fileinstall.bundles.startTransient=true -Djava.ext.dirs=C:\Program Files\Java\jdk1.7.0_05/lib/ext;C:\Program Files\Java\jdk1.7.0_05/jre/lib/ext;C:\glassfish3\glassfish\domains\domain1/lib/ext -Dfelix.fileinstall.bundles.new.start=true -Djavax.net.ssl.trustStore=C:\glassfish3\glassfish\domains\domain1/config/cacerts.jks -Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as -Djava.security.auth.login.config=C:\glassfish3\glassfish\domains\domain1/config/login.conf -DANTLR_USE_DIRECT_CLASS_LOADING=true -Dgosh.args=--nointeractive -Djava.library.path=C:/glassfish3/glassfish/lib;C:/Program Files/Java/jdk1.7.0_05/bin;C:/WINDOWS/Sun/Java/bin;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/system32/wbem;C:/Sun/AppServer/bin;C:/glassfish3/bin;C:/glassfish3;C:/glassfish3/ant/bin;C:/glassfish3/glassfish/bin;C:/Sun/AppServer/jdk/bin;C:/Program Files/Ant/bin;C:/Sun/AppServer/lib;C:/Program Files/Flex_SDK/bin;C:/CometD/samples/client_server_API/web 
</args>
<command>
com.sun.enterprise.glassfish.bootstrap.ASMain -domainname domain1 -asadmin-args --host,,,localhost,,,--port,,,4848,,,--secure=false,,,--terse=false,,,--echo=false,,,--interactive=true,,,start-domain,,,--verbose=false,,,--debug=false,,,--domaindir,,,C:\glassfish3\glassfish\domains,,,domain1 -instancename server -verbose false -debug false -asadmin-classpath C:/glassfish3/glassfish/modules/admin-cli.jar -asadmin-classname com.sun.enterprise.admin.cli.AsadminMain -upgrade false -type DAS -domaindir C:/glassfish3/glassfish/domains/domain1 -read-stdin true
</command>
<launcher>
SUN_STANDARD
</launcher>
<properties>
java.vm.specification.name=Java Virtual Machine Specification
java.vm.version=23.1-b03
java.vm.name=Java HotSpot(TM) Client VM
java.vm.info=mixed mode, sharing
java.ext.dirs=C:\Program Files\Java\jdk1.7.0_05/lib/ext;C:\Program Files\Java\jdk1.7.0_05/jre/lib/ext;C:\glassfish3\glassfish\domains\domain1/lib/ext
java.endorsed.dirs=C:\glassfish3\glassfish/modules/endorsed;C:\glassfish3\glassfish/lib/endorsed
sun.boot.library.path=C:\Program Files\Java\jdk1.7.0_05\jre\bin
java.library.path=C:/glassfish3/glassfish/lib;C:/Program Files/Java/jdk1.7.0_05/bin;C:/WINDOWS/Sun/Java/bin;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/system32/wbem;C:/Sun/AppServer/bin;C:/glassfish3/bin;C:/glassfish3;C:/glassfish3/ant/bin;C:/glassfish3/glassfish/bin;C:/Sun/AppServer/jdk/bin;C:/Program Files/Ant/bin;C:/Sun/AppServer/lib;C:/Program Files/Flex_SDK/bin;C:/CometD/samples/client_server_API/web
java.home=C:\Program Files\Java\jdk1.7.0_05\jre
java.class.path=C:/glassfish3/glassfish/modules/glassfish.jar
sun.boot.class.path=C:\glassfish3\glassfish/modules/endorsed\javax.annotation.jar;C:\glassfish3\glassfish/modules/endorsed\jaxb-api-osgi.jar;C:\glassfish3\glassfish/modules/endorsed\webservices-api-osgi.jar;C:\Program Files\Java\jdk1.7.0_05\jre\lib\resources.jar;C:\Program Files\Java\jdk1.7.0_05\jre\lib\rt.jar;C:\Program Files\Java\jdk1.7.0_05\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.7.0_05\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.7.0_05\jre\lib\jce.jar;C:\Program Files\Java\jdk1.7.0_05\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.7.0_05\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.7.0_05\jre\classes
java.vm.specification.vendor=Oracle Corporation
java.vm.specification.version=1.7
java.vm.vendor=Oracle Corporation
osgi.shell.telnet.maxconn=1
felix.fileinstall.disableConfigSave=false
jdbc.drivers=org.apache.derby.jdbc.ClientDriver
felix.fileinstall.dir=C:\glassfish3\glassfish/modules/autostart/
javax.net.ssl.keyStore=C:\glassfish3\glassfish\domains\domain1/config/keystore.jks
osgi.shell.telnet.port=6666
java.security.policy=C:\glassfish3\glassfish\domains\domain1/config/server.policy
java.awt.headless=true
felix.fileinstall.log.level=2
felix.fileinstall.poll=5000
com.sun.aas.instanceRoot=C:\glassfish3\glassfish\domains\domain1
osgi.shell.telnet.ip=127.0.0.1
com.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory
com.sun.aas.installRoot=C:\glassfish3\glassfish
felix.fileinstall.bundles.startTransient=true
felix.fileinstall.bundles.new.start=true
javax.net.ssl.trustStore=C:\glassfish3\glassfish\domains\domain1/config/cacerts.jks
com.sun.enterprise.security.httpsOutboundKeyAlias=s1as
java.security.auth.login.config=C:\glassfish3\glassfish\domains\domain1/config/login.conf
ANTLR_USE_DIRECT_CLASS_LOADING=true
gosh.args=--nointeractive
sun.java.command=com.sun.enterprise.glassfish.bootstrap.ASMain -domainname domain1 -asadmin-args --host,,,localhost,,,--port,,,4848,,,--secure=false,,,--terse=false,,,--echo=false,,,--interactive=true,,,start-domain,,,--verbose=false,,,--debug=false,,,--domaindir,,,C:\glassfish3\glassfish\domains,,,domain1 -instancename server -verbose false -debug false -asadmin-classpath C:/glassfish3/glassfish/modules/admin-cli.jar -asadmin-classname com.sun.enterprise.admin.cli.AsadminMain -upgrade false -type DAS -domaindir C:/glassfish3/glassfish/domains/domain1 -read-stdin true
sun.java.launcher=SUN_STANDARD
</properties>
</vm_arguments>
<tty>
<writer thread='2068'/>
<dependency_failed type='leaf_type' ctxk='java/io/BufferedReader' witness='java/io/LineNumberReader' stamp='0.997'/>
<dependency_failed type='leaf_type' ctxk='java/util/jar/JarFile' witness='sun/net/www/protocol/jar/URLJarFile' stamp='1.229'/>
<writer thread='4180'/>
<dependency_failed type='unique_concrete_method' ctxk='java/util/Properties' x='java/util/Hashtable put (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;' witness='java/security/Provider' stamp='1.733'/>
<writer thread='3972'/>
<dependency_failed type='leaf_type' ctxk='org/apache/felix/framework/wiring/BundleRequirementImpl' witness='org/apache/felix/framework/resolver/HostedRequirement' stamp='16.176'/>
<dependency_failed type='leaf_type' ctxk='java/io/ObjectInputStream' witness='com/sun/hk2/component/AbstractInhabitantImpl$1' stamp='17.178'/>
<dependency_failed type='leaf_type' ctxk='java/io/ObjectInputStream' witness='com/sun/hk2/component/AbstractInhabitantImpl$1' stamp='17.178'/>
<dependency_failed type='leaf_type' ctxk='java/io/ObjectInputStream' witness='com/sun/hk2/component/AbstractInhabitantImpl$1' stamp='17.178'/>
<dependency_failed type='leaf_type' ctxk='java/io/ObjectInputStream' witness='com/sun/hk2/component/AbstractInhabitantImpl$1' stamp='17.178'/>
<dependency_failed type='leaf_type' ctxk='java/io/ObjectInputStream' witness='com/sun/hk2/component/AbstractInhabitantImpl$1' stamp='17.178'/>
<dependency_failed type='leaf_type' ctxk='java/io/ObjectInputStream' witness='com/sun/hk2/component/AbstractInhabitantImpl$1' stamp='17.178'/>
<dependency_failed type='leaf_type' ctxk='java/io/ObjectInputStream' witness='com/sun/hk2/component/AbstractInhabitantImpl$1' stamp='17.178'/>
<writer thread='2068'/>
<dependency_failed type='leaf_type' ctxk='org/jvnet/hk2/component/MultiMap' witness='org/glassfish/api/admin/ParameterMap' stamp='20.496'/>
<dependency_failed type='leaf_type' ctxk='org/jvnet/hk2/component/MultiMap' witness='org/glassfish/api/admin/ParameterMap' stamp='20.496'/>
<dependency_failed type='leaf_type' ctxk='org/jvnet/hk2/component/MultiMap' witness='org/glassfish/api/admin/ParameterMap' stamp='20.496'/>
<dependency_failed type='leaf_type' ctxk='org/jvnet/hk2/component/MultiMap' witness='org/glassfish/api/admin/ParameterMap' stamp='20.496'/>
<dependency_failed type='leaf_type' ctxk='org/jvnet/hk2/component/MultiMap' witness='org/glassfish/api/admin/ParameterMap' stamp='20.496'/>
<dependency_failed type='leaf_type' ctxk='org/jvnet/hk2/component/MultiMap' witness='org/glassfish/api/admin/ParameterMap' stamp='20.496'/>
<dependency_failed type='leaf_type' ctxk='org/jvnet/hk2/component/MultiMap' witness='org/glassfish/api/admin/ParameterMap' stamp='20.496'/>
<dependency_failed type='leaf_type' ctxk='org/jvnet/hk2/component/MultiMap' witness='org/glassfish/api/admin/ParameterMap' stamp='20.496'/>
<dependency_failed type='leaf_type' ctxk='java/util/WeakHashMap' witness='com/sun/jmx/mbeanserver/MBeanIntrospector$PerInterfaceMap' stamp='21.229'/>
<dependency_failed type='leaf_type' ctxk='java/util/WeakHashMap' witness='com/sun/jmx/mbeanserver/MBeanIntrospector$PerInterfaceMap' stamp='21.230'/>
<dependency_failed type='unique_concrete_method' ctxk='java/io/IOException' x='java/lang/Throwable getMessage ()Ljava/lang/String;' witness='java/rmi/RemoteException' stamp='21.605'/>
<dependency_failed type='leaf_type' ctxk='java/io/ByteArrayOutputStream' witness='com/sun/common/util/logging/LoggingOutputStream' stamp='22.522'/>
<dependency_failed type='leaf_type' ctxk='java/io/ByteArrayOutputStream' witness='com/sun/common/util/logging/LoggingOutputStream' stamp='22.523'/>
<dependency_failed type='leaf_type' ctxk='java/io/ByteArrayOutputStream' witness='com/sun/common/util/logging/LoggingOutputStream' stamp='22.523'/>
<dependency_failed type='leaf_type' ctxk='java/io/ByteArrayOutputStream' witness='com/sun/common/util/logging/LoggingOutputStream' stamp='22.523'/>
<dependency_failed type='leaf_type' ctxk='java/io/ByteArrayOutputStream' witness='com/sun/common/util/logging/LoggingOutputStream' stamp='22.523'/>
<dependency_failed type='leaf_type' ctxk='java/util/ArrayList' witness='com/sun/enterprise/config/serverbeans/Applications$Duck$1' stamp='25.477'/>
<dependency_failed type='leaf_type' ctxk='java/util/ArrayList' witness='com/sun/enterprise/config/serverbeans/Applications$Duck$1' stamp='25.477'/>
<dependency_failed type='leaf_type' ctxk='java/util/ArrayList' witness='com/sun/enterprise/config/serverbeans/Applications$Duck$1' stamp='25.477'/>
<dependency_failed type='leaf_type' ctxk='java/util/ArrayList' witness='com/sun/enterprise/config/serverbeans/Applications$Duck$1' stamp='25.477'/>
<dependency_failed type='leaf_type' ctxk='java/util/ArrayList' witness='com/sun/enterprise/config/serverbeans/Applications$Duck$1' stamp='25.477'/>
<dependency_failed type='leaf_type' ctxk='java/util/ArrayList' witness='com/sun/enterprise/config/serverbeans/Applications$Duck$1' stamp='25.477'/>
<dependency_failed type='leaf_type' ctxk='java/util/ArrayList' witness='com/sun/enterprise/config/serverbeans/Applications$Duck$1' stamp='25.477'/>
<dependency_failed type='leaf_type' ctxk='java/util/ArrayList' witness='com/sun/enterprise/config/serverbeans/Applications$Duck$1' stamp='25.478'/>
<dependency_failed type='leaf_type' ctxk='java/util/ArrayList' witness='com/sun/enterprise/config/serverbeans/Applications$Duck$1' stamp='25.478'/>
<dependency_failed type='leaf_type' ctxk='java/util/ArrayList' witness='com/sun/enterprise/config/serverbeans/Applications$Duck$1' stamp='25.478'/>
<dependency_failed type='leaf_type' ctxk='java/util/ArrayList' witness='com/sun/enterprise/config/serverbeans/Applications$Duck$1' stamp='25.478'/>
<dependency_failed type='leaf_type' ctxk='java/util/ArrayList$Itr' witness='java/util/ArrayList$ListItr' stamp='26.987'/>
<dependency_failed type='leaf_type' ctxk='java/util/ArrayList$Itr' witness='java/util/ArrayList$ListItr' stamp='26.987'/>
<dependency_failed type='leaf_type' ctxk='java/util/ArrayList$Itr' witness='java/util/ArrayList$ListItr' stamp='26.987'/>
<dependency_failed type='unique_concrete_method' x='java/lang/SecurityManager checkPropertyAccess (Ljava/lang/String;)V' witness='com/sun/enterprise/security/J2EESecurityManager' stamp='27.822'/>
<dependency_failed type='unique_concrete_method' x='java/lang/SecurityManager checkPackageAccess (Ljava/lang/String;)V' witness='com/sun/enterprise/security/J2EESecurityManager' stamp='27.822'/>
<dependency_failed type='unique_concrete_method' x='java/lang/ThreadLocal get ()Ljava/lang/Object;' witness='org/glassfish/web/admin/monitor/HttpServiceStatsProvider$1' stamp='30.803'/>
<dependency_failed type='unique_concrete_method' x='java/lang/ThreadLocal get ()Ljava/lang/Object;' witness='org/glassfish/web/admin/monitor/HttpServiceStatsProvider$1' stamp='30.803'/>
<dependency_failed type='unique_concrete_method' x='java/lang/ThreadLocal get ()Ljava/lang/Object;' witness='org/glassfish/web/admin/monitor/HttpServiceStatsProvider$1' stamp='30.803'/>
<dependency_failed type='unique_concrete_method' x='java/lang/ThreadLocal get ()Ljava/lang/Object;' witness='org/glassfish/web/admin/monitor/HttpServiceStatsProvider$1' stamp='30.803'/>
<dependency_failed type='unique_concrete_method' x='java/lang/ThreadLocal get ()Ljava/lang/Object;' witness='org/glassfish/web/admin/monitor/HttpServiceStatsProvider$1' stamp='30.803'/>
<dependency_failed type='unique_concrete_method' x='java/lang/ThreadLocal get ()Ljava/lang/Object;' witness='org/glassfish/web/admin/monitor/HttpServiceStatsProvider$1' stamp='30.803'/>
<dependency_failed type='unique_concrete_method' x='java/lang/ThreadLocal get ()Ljava/lang/Object;' witness='org/glassfish/web/admin/monitor/HttpServiceStatsProvider$1' stamp='30.803'/>
<dependency_failed type='unique_concrete_method' x='java/lang/ThreadLocal get ()Ljava/lang/Object;' witness='org/glassfish/web/admin/monitor/HttpServiceStatsProvider$1' stamp='30.803'/>
<dependency_failed type='unique_concrete_method' x='java/lang/ThreadLocal get ()Ljava/lang/Object;' witness='org/glassfish/web/admin/monitor/HttpServiceStatsProvider$1' stamp='30.803'/>
<dependency_failed type='leaf_type' ctxk='java/util/logging/Level' witness='com/sun/enterprise/util/logging/IASLevel' stamp='30.959'/>
<dependency_failed type='unique_concrete_method' x='java/util/ArrayList add (Ljava/lang/Object;)Z' witness='javax/management/AttributeList' stamp='33.034'/>
<dependency_failed type='unique_concrete_method' x='java/util/ArrayList add (Ljava/lang/Object;)Z' witness='javax/management/AttributeList' stamp='33.035'/>
<dependency_failed type='unique_concrete_method' ctxk='org/w3c/dom/Node' x='com/sun/org/apache/xerces/internal/dom/NodeImpl appendChild (Lorg/w3c/dom/Node;)Lorg/w3c/dom/Node;' witness='org/w3c/dom/Node' stamp='34.497'/>
<dependency_failed type='leaf_type' ctxk='com/sun/org/apache/xerces/internal/util/NamespaceSupport' witness='com/sun/org/apache/xerces/internal/impl/xs/SchemaNamespaceSupport' stamp='34.567'/>
<dependency_failed type='unique_concrete_method' ctxk='org/w3c/dom/NamedNodeMap' x='com/sun/org/apache/xerces/internal/dom/NamedNodeMapImpl getLength ()I' witness='org/w3c/dom/NamedNodeMap' stamp='34.568'/>
<dependency_failed type='leaf_type' ctxk='com/sun/org/apache/xerces/internal/xni/QName' witness='com/sun/org/apache/xerces/internal/impl/dv/xs/QNameDV$XQName' stamp='34.836'/>
<dependency_failed type='leaf_type' ctxk='com/sun/org/apache/xerces/internal/xni/QName' witness='com/sun/org/apache/xerces/internal/impl/dv/xs/QNameDV$XQName' stamp='34.836'/>
<dependency_failed type='leaf_type' ctxk='com/sun/org/apache/xerces/internal/xni/QName' witness='com/sun/org/apache/xerces/internal/impl/dv/xs/QNameDV$XQName' stamp='34.836'/>
<dependency_failed type='leaf_typ

如果有帮助,这是我的部署描述符,web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0">

    <servlet>
        <servlet-name>cometd</servlet-name>
        <servlet-class>org.cometd.server.CometdServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
        <async-supported>true</async-supported>
        <init-param>
            <param-name>timeout</param-name>
            <param-value>60000</param-value>
        </init-param>
        <init-param>
            <param-name>logLevel</param-name>
            <param-value>3</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>cometd</servlet-name>
        <url-pattern>/cometd/*</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>configuration</servlet-name>
        <servlet-class>CometDServletInitializer</servlet-class>
        <async-supported>true</async-supported>
    </servlet>

</web-app>

很抱歉寻求帮助来调试我的代码,但我已经尝试了好几天,但 ExceptionInInitializerError 仍然让我感到困惑。

4

1 回答 1

2

jetty-client api 在 jetty-8 和 jetty-9 之间发生了巨大变化,因此如果您将 cometd-2 与 jetty-9 客户端 api 一起使用,那么这可能是您的问题。Cometd-3 将支持新的 jetty-9 jetty-client api。我怀疑您应该能够在您的 web 应用程序中使用 jetty-8 jetty-client 依赖项,并根据需要部署到 jetty-9 作为容器。您只需要注意不要将 jetty-client 类暴露给 webapp 类加载器,因为 webapp 中已经有 jetty-8 类。我会注意到这是 webapp 类加载器隔离的目的之一,所以你可以在你的 webapp 和你的 servlet 容器中拥有不同版本的东西。在这种情况下,jetty-client 就像拥有两个不同版本的 slf4j,你不希望你的容器强迫你使用一个特定的版本哦一个依赖。我想,cometd 项目很快就会推出 3.0 版的 RC,或者如果你想在 Cometd 的前沿工作,你可以使用它的 SNAPSHOT。我可能会建议只使用 jetty-8 jetty-client 和 cometd 2.5(或至少它的最新版本)。

于 2013-03-29T12:56:02.333 回答