我尝试使用Jetty 9.4.8运行应用程序的部署。这是一个有角度的Java Maven多模块应用程序
这是我的web.xml
PAYMENT_UPDATED
我通过在WEB-INF(http://www.agorava.org/news/2012/07/10/Starting-a-CDI-webapp-from-Maven-with-Weld-servlet-and-jetty-plugin/)下创建jetty-env.xml,通过JNDI公开了CDI bean管理器。
<?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">
<display-name>Tourism Applicationwith Angular</display-name>
<description>
This is a simple web application with a source code organization
based on the recommendations of the Application Developer's Guide.
</description>
<display-name>Archetype Created Web Application</display-name>
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<resource-env-ref>
<description>Object factory for the CDI Bean Manager</description>
<resource-env-ref-name>BeanManager</resource-env-ref-name>
<resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
</resource-env-ref>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>webservice.TourismWebService</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
要允许Jetty加载服务器类,我在WEB-INF(http://wiki.eclipse.org/Jetty/Reference/Jetty_Classloading)下创建文件jetty-web.xml
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="webAppCtx" class="org.eclipse.jetty.webapp.WebAppContext">
<New id="BeanManager" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg>
<Ref id="webAppCtx"/>
</Arg>
<Arg>BeanManager</Arg>
<Arg>
<New class="javax.naming.Reference">
<Arg>javax.enterprise.inject.spi.BeanManager</Arg>
<Arg>org.jboss.weld.resources.ManagerObjectFactory</Arg>
<Arg/>
</New>
</Arg>
</New>
</Configure>
当我运行码头时,出现以下错误消息
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="serverClasses">
<Array type="java.lang.String">
<Item>-org.eclipse.jetty.servlet.ServletContextHandler.Decorator</Item>
</Array>
</Set>
<Call name="prependServerClass">
<Arg>-org.eclipse.jetty.servlet.listener.IntrospectorCleaner</Arg>
</Call>
<Call name="prependServerClass">
<Arg>-org.eclipse.jetty.servlet.listener.ELContextCleaner</Arg>
</Call>
<Call name="prependServerClass">
<Arg>-org.eclipse.jetty.util.Decorator</Arg>
</Call>
<Call name="prependServerClass">
<Arg>-org.eclipse.jetty.util.DecoratedObjectFactory</Arg>
</Call>
<Call name="prependServerClass">
<Arg>-org.eclipse.jetty.server.handler.ContextHandler.</Arg>
</Call>
<Call name="prependServerClass">
<Arg>-org.eclipse.jetty.server.handler.ContextHandler</Arg>
</Call>
<Call name="prependServerClass">
<Arg>-org.eclipse.jetty.servlet.ServletContextHandler</Arg>
</Call>
</Configure>
谢谢您的帮助
答案 0 :(得分:1)
将<Set>
与serverClasses
相对应,将其撤消,因为这将撤消serverClasses
正常运行的所有现有(和必需)设置。
删除此部分...
<Set name="serverClasses">
<Array type="java.lang.String">
<Item>-org.eclipse.jetty.servlet.ServletContextHandler.Decorator</Item>
</Array>
</Set>
您应该将对serverClasses
的修改限制为对现有列表进行prependServerClass
或addServerClass
的调用。
示例:
<Call name="prependServerClass">
<Arg>-org.eclipse.jetty.servlet.ServletContextHandler</Arg>
</Call>
<!-- or -->
<Call name="addServerClass">
<Arg>-org.eclipse.jetty.servlet.ServletContextHandler</Arg>
</Call>
答案 1 :(得分:0)
它解决了我的问题。但是,我还有另一个错误
2018-11-21 20:41:16.229:INFO:oejs.session:main: No SessionScavenger set, using defaults
2018-11-21 20:41:16.234:INFO:oejs.session:main: Scavenging every 660000ms
20:41:16.328 [main] INFO org.jboss.weld.environment.servletWeldServlet - WELD-ENV-001006: org.jboss.weld.environment.servlet.EnhancedListener used to initialize Weld
20:41:16.410 [main] DEBUG org.jboss.resteasy.cdi.i18n - RESTEASY010540: Doing a lookup for BeanManager in java:comp/BeanManager
20:41:16.417 [main] DEBUG org.jboss.resteasy.cdi.i18n - RESTEASY010610: Unable to obtain BeanManager from java:comp/BeanManager
20:41:16.417 [main] DEBUG org.jboss.resteasy.cdi.i18n - RESTEASY010540: Doing a lookup for BeanManager in java:app/BeanManager
20:41:16.417 [main] DEBUG org.jboss.resteasy.cdi.i18n - RESTEASY010610: Unable to obtain BeanManager from java:app/BeanManager
20:41:16.421 [main] DEBUG org.jboss.resteasy.cdi.i18n - RESTEASY010550: Error occurred trying to look up via CDI util.
org.jboss.weld.exceptions.IllegalStateException: WELD-001327: Unable to identify the correct BeanManager. The calling class org.jboss.resteasy.cdi.CdiInjectorFactory is placed in multiple bean archives
at org.jboss.weld.SimpleCDI.ambiguousBeanManager(SimpleCDI.java:95)
at org.jboss.weld.SimpleCDI$ClassNameToBeanManager.findBeanManager(SimpleCDI.java:68)
at org.jboss.weld.SimpleCDI$ClassNameToBeanManager.apply(SimpleCDI.java:46)
at org.jboss.weld.SimpleCDI$ClassNameToBeanManager.apply(SimpleCDI.java:39)
at org.jboss.weld.util.cache.ReentrantMapBackedComputingCache$1.apply(ReentrantMapBackedComputingCache.java:55)
at org.jboss.weld.util.cache.ReentrantMapBackedComputingCache$1.apply(ReentrantMapBackedComputingCache.java:51)
at org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.getValue(ReentrantMapBackedComputingCache.java:64)
at org.jboss.weld.SimpleCDI.getBeanManager(SimpleCDI.java:104)
at org.jboss.weld.SimpleCDI.getBeanManager(SimpleCDI.java:37)
at org.jboss.resteasy.cdi.CdiInjectorFactory.lookupBeanManagerCDIUtil(CdiInjectorFactory.java:232)
at org.jboss.resteasy.cdi.CdiInjectorFactory.lookupBeanManager(CdiInjectorFactory.java:152)
at org.jboss.resteasy.cdi.CdiInjectorFactory.<init>(CdiInjectorFactory.java:44)
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 org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:148)
at org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap.contextInitialized(ResteasyBootstrap.java:28)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:890)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:532)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:853)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:344)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1515)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1477)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133)
at org.eclipse.jetty.server.Server.start(Server.java:418)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.server.Server.doStart(Server.java:385)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at runjettyrun.Bootstrap.main(Bootstrap.java:89)
20:41:16.423 [main] DEBUG org.jboss.resteasy.cdi.i18n - RESTEASY010565: Found BeanManager in ServletContext
20:41:16.423 [main] DEBUG org.jboss.resteasy.cdi.i18n - RESTEASY010565: Found BeanManager in ServletContext
在一开始,我认为这是由于多个档案中引用了一个类。但是错误消息指出“正在调用的类...”