我有三个gradle模块:一个JavaEE API,一个Angular Front-End和一个Gradle项目,用于将这两个模块打包到EAR中。
将其中一个打包到EAR中,一切正常(API或FrontEnd正常运行)
只要我将包BOTH(API和前端)放入EAR,我就会在部署时获得ClassNotFoundExceptions:
09-Nov-2017 16:44:07.180 WARNUNG [http-nio-8080-exec-4] org.apache.openejb.server.rest.RESTService.appProviders can't load 'de.my.app.application.appRequestFloodingFilter'
java.lang.ClassNotFoundException: de.my.app.application.appRequestFloodingFilter
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
at org.apache.tomee.catalina.TomEEWebappClassLoader.loadWithDelegate(TomEEWebappClassLoader.java:211)
at org.apache.tomee.catalina.TomEEWebappClassLoader.loadClass(TomEEWebappClassLoader.java:201)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
at org.apache.openejb.server.rest.RESTService.appProviders(RESTService.java:567)
at org.apache.openejb.server.rest.RESTService.addAppProvidersIfNeeded(RESTService.java:296)
at org.apache.openejb.server.rest.RESTService.afterApplicationCreated(RESTService.java:132)
at org.apache.tomee.webservices.TomeeJaxRsService.afterApplicationCreated(TomeeJaxRsService.java:53)
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:483)
at org.apache.openejb.observer.ObserverManager$MethodInvocation.invoke(ObserverManager.java:406)
at org.apache.openejb.observer.ObserverManager.doFire(ObserverManager.java:111)
at org.apache.openejb.observer.ObserverManager.fireEvent(ObserverManager.java:100)
at org.apache.openejb.loader.SystemInstance.fireEvent(SystemInstance.java:217)
at org.apache.tomee.catalina.TomcatWebAppBuilder.afterStart(TomcatWebAppBuilder.java:1740)
at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:116)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:395)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.tomee.catalina.TomcatWebAppBuilder.deployWar(TomcatWebAppBuilder.java:651)
at org.apache.tomee.catalina.TomcatWebAppBuilder.deployWebApps(TomcatWebAppBuilder.java:589)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:996)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:717)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:713)
at org.apache.openejb.assembler.DeployerEjb.deploy(DeployerEjb.java:254)
at org.apache.openejb.assembler.DeployerEjb.deploy(DeployerEjb.java:144)
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:483)
at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:205)
at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:186)
at org.apache.openejb.security.internal.InternalSecurityInterceptor.invoke(InternalSecurityInterceptor.java:35)
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:483)
at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:205)
at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:186)
at org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:181)
at org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:100)
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:483)
at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:205)
at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:186)
at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:85)
at org.apache.openejb.core.singleton.SingletonContainer._invoke(SingletonContainer.java:256)
at org.apache.openejb.core.singleton.SingletonContainer.invoke(SingletonContainer.java:212)
at org.apache.openejb.server.ejbd.EjbRequestHandler.doEjbObject_BUSINESS_METHOD(EjbRequestHandler.java:371)
at org.apache.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:182)
at org.apache.openejb.server.ejbd.EjbDaemon.processEjbRequest(EjbDaemon.java:360)
at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:247)
at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:104)
at org.apache.openejb.server.httpd.ServerServlet.service(ServerServlet.java:60)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.tomee.catalina.OpenEJBSecurityListener$RequestCapturer.invoke(OpenEJBSecurityListener.java:97)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
所以简而言之:
我读了很多,尝试了很多,现在我不知道该找什么。
EAR deploymentProcessor
ear {
deploymentDescriptor {
version = "6"
initializeInOrder = true
applicationName = "My-App"
displayName = "My-App"
libDirName = "/lib"
// WARs
webModule(project(':MyAppClient').name + '-' + project(':MyAppClient').version + '.war', "/client/client")
webModule(project(':MyAppServerAPI').name + '-' + project(':MyAppServerAPI').version + '.war', "/api/api")
}
}
API依赖
dependencies {
//////////////////////////////////////
// Third party dependencies
//////////////////////////////////////
// Logging
compile 'org.slf4j:slf4j-api'
// JavaEE
compileOnly 'javax:javaee-api'
// Jackson Json
compile 'com.fasterxml.jackson.core:jackson-core'
compile 'com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider'
//apache commons
compile group: 'org.apache.commons', name: 'commons-lang3'
}
EAR的application.xml
<?xml version="1.0"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="6">
<application-name>My-App</application-name>
<display-name>My-App</display-name>
<initialize-in-order>true</initialize-in-order>
<module>
<web>
<web-uri>MyAppClient-0.1.0-SNAPSHOT.war</web-uri>
<context-root>/</context-root>
</web>
</module>
<module>
<web>
<web-uri>MyAppServerAPI-0.1.0-SNAPSHOT.war</web-uri>
<context-root>/api</context-root>
</web>
</module>
<library-directory>/lib</library-directory>
</application>
2017年11月20日更新
问题不属于Angular。在另一个用例中,我有一个与项目的另一个模块相关的WAR,在从模块A部署WAR并依赖于模块B的时候,JavaEE和类似的问题都出现了
答案 0 :(得分:0)
我的错:我有两个包含JAVA代码和路由的WAR。所以这两个文件都有一个web.xml
文件。我(为什么)在创建第一个模块时进行了探索性设置web-app:id
。将其拆分为两个项目时,我设置了一个新的display-name
,但没有更改web-app:id
现在我有了这个:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
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>My Module 1 API</display-name>
</web-app>
那一个:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
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>My Module 2 API</display-name>
</web-app>