0

我有一个微服务野蝇群。它有一些从 google protobuf 生成的代码。但是如果我从命令行使用 java -jar ..... 开始并从浏览器调用服务器,我会得到以下异常。如果我从 Eclipse 启动它,则不会发生错误。

 2017-05-04 14:49:24,752 FATAL [javax.enterprise.resource.webcontainer.jsf.context] (default task-1) JSF1073: java.lang.NoClassDefFoundError erfasst wõhrend Verarbeitung von RENDER_RESPONSE
    2017-05-04 14:49:24,752 FATAL [javax.enterprise.resource.webcontainer.jsf.context] (default task-1) com/google/protobuf/Message: java.lang.NoClassDefFoundError: com/google/protobuf/Message
            at org.cmp42.grpc.StreamClient.<init>(StreamClient.java:48)
            at org.cmp42.grpc.StreamClient.<init>(StreamClient.java:37)
            at org.cmp42.grpc.StreamClientHandler.<init>(StreamClientHandler.java:25)
            at org.cpm42.beans.TestController.<init>(TestController.java:34)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at java.lang.Class.newInstance(Class.java:442)
            at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:186)
            at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:100)
            at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
            at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
            at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:257)
            at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:117)
            at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
            at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
            at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:116)
            at com.sun.el.parser.AstValue.getBase(AstValue.java:150)
            at com.sun.el.parser.AstValue.getValue(AstValue.java:199)
            at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)
            at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
            at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
            at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
            at javax.faces.component.UIOutput.getValue(UIOutput.java:174)
            at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
            at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
            at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
            at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
            at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
            at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
            at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:458)
            at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
            at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
            at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
            at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
            at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
            at javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
            at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
            at io.undertow.websockets.jsr.JsrWebSocketFilter.doFilter(JsrWebSocketFilter.java:130)
            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
            at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
            at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
            at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
            at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
            at org.wildfly.swarm.generated.FaviconErrorHandler.handleRequest(FaviconErrorHandler.java:62)
            at io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:94)
            at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
            at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
            at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
            at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
            at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
            at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
            at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
            at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
            at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
            at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
            at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
            at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
            at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
            at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
            at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
            at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
            at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
            at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
            at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
            at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
            at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
            at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
            at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
            at io.undertow.server.Connectors.executeRootHandler(Connectors.java:211)
            at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:809)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
            at java.lang.Thread.run(Thread.java:745)
    Caused by: java.lang.ClassNotFoundException: com.google.protobuf.Message from [Module "deployment.d8d214e5-87b4-4c2c-910f-9e6f398dad28.war:main" from Service Module Loader]
            at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
            at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
            at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
            at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
            ... 82 more

谁能解释为什么在 IDE 中一切正常并且从命令行我得到这个错误?

这是我的主要课程 mit mani 功能:

Swarm swarm = new Swarm();

WARArchive archive = ShrinkWrap.create(WARArchive.class);

archive.addAllDependencies();

archive.addClass(StreamClientHandler.class);
archive.addClass(StreamClient.class);
//add beans to Deployment
archive.addPackage("org.cpm42.beans");
//add websocket to Deployment
archive.addPackage("org.cpm42.websocket");
//add grpc-generated sources
archive.addPackage("org.cpm42.protobuf3.generated");

archive.staticContent("/");

archive.addAsWebInfResource(new ClassLoaderAsset("WEB-INF/web.xml", Application.class.getClassLoader()), "web.xml");

swarm.start();

swarm.deploy(archive);
4

0 回答 0