NoClassDefFoundError 单例持有者

NoClassDefFoundError Singletonholder

大家好!我最近部署了一个 Web 项目,在尝试获取单例 class 的实例时收到 NoClassDefFoundError。

com.vaadin.server.ServerRpcManager$RpcInvocationException: Unable to invoke method click in com.vaadin.shared.ui.button.ButtonServerRpc at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:170) at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:118) at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:287) at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:180) at com.vaadin.server.communication.PushHandler.run(PushHandler.java:174) at com.vaadin.server.communication.PushHandler.callWithUi(PushHandler.java:253) at com.vaadin.server.communication.PushHandler.access0(PushHandler.java:56) at com.vaadin.server.communication.PushHandler.onRequest(PushHandler.java:76) at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:174) at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:95) at org.atmosphere.container.GlassFishServ30WebSocketSupport.service(GlassFishServ30WebSocketSupport.java:60) at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:1802) at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:432) at org.atmosphere.websocket.DefaultWebSocketProcessor.run(DefaultWebSocketProcessor.java:285) at org.atmosphere.util.VoidExecutorService.execute(VoidExecutorService.java:101) at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:280) at org.atmosphere.websocket.DefaultWebSocketProcessor.invokeWebSocketProtocol(DefaultWebSocketProcessor.java:303) at org.atmosphere.container.GlassFishServ30WebSocketSupport$Grizzly2WebSocketApplication.onMessage(GlassFishServ30WebSocketSupport.java:157) at org.glassfish.grizzly.websockets.SimpleWebSocket.onMessage(SimpleWebSocket.java:163) at org.glassfish.grizzly.websockets.frametypes.TextFrameType.respond(TextFrameType.java:68) at org.glassfish.grizzly.websockets.DataFrame.respond(DataFrame.java:119) at org.glassfish.grizzly.websockets.BaseWebSocketFilter.handleRead(BaseWebSocketFilter.java:219) at org.glassfish.grizzly.filterchain.ExecutorResolver.execute(ExecutorResolver.java:119) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access0(WorkerThreadIOStrategy.java:56) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:168) ... 35 more Caused by: com.vaadin.event.ListenerMethod$MethodException: Invocation of method buttonClick in no.solarsoft.venus2.admissionweb2.presentation.components.wizard.contentparts.PaymentPanel failed. at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:528) at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198) at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161) at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:979) at com.vaadin.ui.Button.fireClick(Button.java:393) at com.vaadin.ui.Button.click(Button.java:57) ... 40 more Caused by: java.lang.ExceptionInInitializerError at no.solarsoft.venus2.payex.wsclient.PxOrderManager.getInstance(PxOrderManager.java:54) at no.solarsoft.venus2.admissionweb2.payment.payex.AbstractPayExHelper.initializeOrder(AbstractPayExHelper.java:60) at no.solarsoft.venus2.admissionweb2.payment.payex.PayExCreditCardHelper.initializeOrder(PayExCreditCardHelper.java:60) at no.solarsoft.venus2.admissionweb2.presentation.view.ApplicationWizardView$PaymentPanelModelPropertyChangeListener.propertyChange(ApplicationWizardView.java:1599) at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335) at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:327) at no.solarsoft.venus2.admissionweb2.presentation.components.wizard.content.model.PaymentPanelModel.createCreditCardPaymentEvent(PaymentPanelModel.java:210) at no.solarsoft.venus2.admissionweb2.presentation.components.wizard.contentparts.PaymentPanel.buttonClick(PaymentPanel.java:272) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508) ... 45 more Caused by: java.lang.IllegalStateException: MASM0001: Default configuration file [ jaxws-tubes-default.xml ] was not found at com.sun.xml.ws.assembler.MetroConfigLoader.init(MetroConfigLoader.java:142) at com.sun.xml.ws.assembler.MetroConfigLoader.(MetroConfigLoader.java:119) at com.sun.xml.ws.assembler.TubelineAssemblyController.getTubeCreators(TubelineAssemblyController.java:93) at com.sun.xml.ws.assembler.MetroTubelineAssembler.createClient(MetroTubelineAssembler.java:118) at com.sun.xml.ws.client.Stub.createPipeline(Stub.java:343) at com.sun.xml.ws.client.Stub.(Stub.java:310) at com.sun.xml.ws.client.Stub.(Stub.java:243) at com.sun.xml.ws.client.Stub.(Stub.java:258) at com.sun.xml.ws.client.sei.SEIStub.(SEIStub.java:98) at com.sun.xml.ws.client.WSServiceDelegate.getStubHandler(WSServiceDelegate.java:829) at com.sun.xml.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:818) at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:451) at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:419) at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:401) at javax.xml.ws.Service.getPort(Service.java:134) at com.payex.external.pxorder.PxOrder.getPxOrderSoap(PxOrder.java:83) at no.solarsoft.venus2.payex.wsclient.PxOrderManager.init(PxOrderManager.java:60) at no.solarsoft.venus2.payex.wsclient.PxOrderManager.(PxOrderManager.java:46) at no.solarsoft.venus2.payex.wsclient.PxOrderManager.(PxOrderManager.java:45) at no.solarsoft.venus2.payex.wsclient.PxOrderManager$PxOrderManagerSingletonHolder.(PxOrderManager.java:50) ... 58 more]]

[2015-09-05T09:30:09.061+0200] [glassfish 4.1] [SEVERE] [] [] [tid:
_ThreadID=35 _ThreadName=Thread-9] [timeMillis: 1441438209061] [levelValue: 1000] [[  

no.solarsoft.venus2.admissionweb2.CustomNavigator$InitializationException: ViewInitializer could not be found for view named "stdError". at no.solarsoft.venus2.admissionweb2.CustomNavigator.initView(CustomNavigator.java:91) at no.solarsoft.venus2.admissionweb2.CustomNavigator.navigateTo(CustomNavigator.java:123) at no.solarsoft.venus2.admissionweb2.AdmissionWebUI.error(AdmissionWebUI.java:211) at com.vaadin.server.LegacyCommunicationManager.handleConnectorRelatedException(LegacyCommunicationManager.java:397) at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:290) at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:180) at com.vaadin.server.communication.PushHandler.run(PushHandler.java:174) at com.vaadin.server.communication.PushHandler.callWithUi(PushHandler.java:253) at com.vaadin.server.communication.PushHandler.access0(PushHandler.java:56) at com.vaadin.server.communication.PushHandler.onRequest(PushHandler.java:76) at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:174) at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:95) at org.atmosphere.container.GlassFishServ30WebSocketSupport.service(GlassFishServ30WebSocketSupport.java:60) at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:1802) at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:432) at org.atmosphere.websocket.DefaultWebSocketProcessor.run(DefaultWebSocketProcessor.java:285) at org.atmosphere.util.VoidExecutorService.execute(VoidExecutorService.java:101) at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:280) at org.atmosphere.websocket.DefaultWebSocketProcessor.invokeWebSocketProtocol(DefaultWebSocketProcessor.java:303) at org.atmosphere.container.GlassFishServ30WebSocketSupport$Grizzly2WebSocketApplication.onMessage(GlassFishServ30WebSocketSupport.java:157) at org.glassfish.grizzly.websockets.SimpleWebSocket.onMessage(SimpleWebSocket.java:163) at org.glassfish.grizzly.websockets.frametypes.TextFrameType.respond(TextFrameType.java:68) at org.glassfish.grizzly.websockets.DataFrame.respond(DataFrame.java:119) at org.glassfish.grizzly.websockets.BaseWebSocketFilter.handleRead(BaseWebSocketFilter.java:219) at org.glassfish.grizzly.filterchain.ExecutorResolver.execute(ExecutorResolver.java:119) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access0(WorkerThreadIOStrategy.java:56) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545) at java.lang.Thread.run(Thread.java:745)]]

这是我的 PxOrderManager 的代码:

package no.solarsoft.venus2.payex.wsclient;

import java.net.MalformedURLException;
import java.net.URL;

import javax.xml.namespace.QName;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import no.solarsoft.venus2.admissionweb2.AdmissionWebUI;
import no.solarsoft.venus2.admissionweb2.AdmissionWebUI.RuntimeMode;

import com.payex.external.pxorder.PxOrder;
import com.payex.external.pxorder.PxOrderSoap;

public class PxOrderManager {

    private static final QName SERVICE_NAME = new QName("http://external.payex.com/PxOrder/", "PxOrder");
    private static final String TEST_WSDL_LOCATION_STRING = "https://test-external.payex.com/pxorder/pxorder.asmx?WSDL";
    private static final String WSDL_LOCATION_STRING = "https://external.payex.com/pxorder/pxorder.asmx?WSDL";
    private static final URL WSDL_LOCATION;

    private static final Logger log = LogManager.getLogger(PxOrderManager.class);

    // This initializes WSDL location. !!! USE TEST_WSDL_LOCATION_STRING for
    // testing against test web services.
    static {
        URL url = null;
        String urlString = null;
        try {
            urlString = AdmissionWebUI.RUNTIME_MODE.equals(RuntimeMode.PRODUCTION) ? WSDL_LOCATION_STRING
                    : TEST_WSDL_LOCATION_STRING;
            url = new URL(urlString);
        } catch (MalformedURLException e) {
            java.util.logging.Logger.getLogger(PxOrder.class.getName()).log(java.util.logging.Level.INFO,
                    "Can not initialize the default wsdl from {0}", urlString);
        }
        WSDL_LOCATION = url;
    }

    private PxOrder service;
    private PxOrderSoap port;

    private PxOrderManager() {
        init(WSDL_LOCATION);
    }

    private static class PxOrderManagerSingletonHolder {
        public static final PxOrderManager INSTANCE = new PxOrderManager();
    }

    public static PxOrderManager getInstance() {
        return PxOrderManagerSingletonHolder.INSTANCE;
    }

    private void init(URL wsdlUrl) {
        log.info("Initializing web service with wsdl location at: " + wsdlUrl.toString());
        service = new PxOrder(wsdlUrl, SERVICE_NAME);
        port = service.getPxOrderSoap();
    }

    public PxOrderSoap getPort() {
        return this.port;
    }
}

我已经尝试检查我的 war 文件的内容,它看起来很正常。 classes PxOrderManagerSingletonHolderPxOrderManager 存在

我所有的 jar 文件都在 web-inf/lib 文件夹中。我正在使用 vaadin 7 和 jdk 1.6.0_45(如果有帮助)

希望有人能帮助我。谢谢!

我认为你的问题出在不同的地方(不是 NoClassDefFoundError)。在你的堆栈跟踪中是这样的信息:

Caused by: java.lang.IllegalStateException: MASM0001: Default configuration file [ jaxws-tubes-default.xml ] was not found

解决方案描述为here at SO

编辑:

此外,考虑Java版本升级会很棒。 Vaadin Book 说:

Vaadin is compatible with Java 1.6 and later editions. Java EE 7 is required for proper server push support with WebSockets.