IntelliJ部署JAX-RS应用至TomEE异常:应用已运行但提示未部署
IntelliJ部署TomEE时显示“Artifact is not deployed”但应用实际正常运行的解决方法
问题描述
我在IntelliJ中部署JAX-RS应用到TomEE时遇到了一个奇怪的问题:Web应用已经成功部署并可以正常访问,但IntelliJ始终提示:
Artifact is not deployed. Press 'Deploy' to start deployment
这导致我无法执行重新部署操作,而且控制台没有任何错误信息,完整的控制台部署日志如下:
Connected to server [2018-05-22 10:57:19,570] Artifact adjunkto-web:war exploded: Artifact is being deployed, please wait... 22-May-2018 10:57:19.726 INFO [http-nio-8080-exec-4] org.apache.tomee.catalina.TomcatWebAppBuilder.deployWebApps using default host: localhost 22-May-2018 10:57:19.727 INFO [http-nio-8080-exec-4] org.apache.tomee.catalina.TomcatWebAppBuilder.init ------------------------- localhost -> / 22-May-2018 10:57:20.317 INFO [http-nio-8080-exec-4] org.apache.openejb.config.ConfigurationFactory.configureApplication Configuring enterprise application: C:\software\apache-tomee-webprofile-7.0.4-adjunkto\temp\0-ROOT 22-May-2018 10:57:20.499 INFO [http-nio-8080-exec-4] org.apache.openejb.config.ConfigurationFactory.configureService Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container) 22-May-2018 10:57:20.500 INFO [http-nio-8080-exec-4] org.apache.openejb.config.AutoConfig.createContainer Auto-creating a container for bean .Comp2064284523: Container(type=MANAGED, id=Default Managed Container) 22-May-2018 10:57:20.502 INFO [http-nio-8080-exec-4] org.apache.openejb.assembler.classic.Assembler.createRecipe Creating Container(id=Default Managed Container) 22-May-2018 10:57:20.520 INFO [http-nio-8080-exec-4] org.apache.openejb.core.managed.SimplePassivater.init Using directory C:\software\apache-tomee-webprofile-7.0.4-adjunkto\temp for stateful session passivation 22-May-2018 10:57:20.569 INFO [http-nio-8080-exec-4] org.apache.openejb.config.AppInfoBuilder.build Enterprise application "C:\software\apache-tomee-webprofile-7.0.4-adjunkto\temp\0-ROOT" loaded. 22-May-2018 10:57:20.569 INFO [http-nio-8080-exec-4] org.apache.openejb.assembler.classic.Assembler.createApplication Assembling app: C:\software\apache-tomee-webprofile-7.0.4-adjunkto\temp\0-ROOT 22-May-2018 10:57:20.627 INFO [http-nio-8080-exec-4] org.apache.openejb.cdi.CdiBuilder.initSingleton Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@7776ab 22-May-2018 10:57:20.804 INFO [http-nio-8080-exec-4] org.apache.openejb.cdi.OpenEJBLifecycle.startApplication OpenWebBeans Container is starting... 22-May-2018 10:57:20.815 INFO [http-nio-8080-exec-4] org.apache.webbeans.plugins.PluginLoader.startUp Adding OpenWebBeansPlugin : [CdiPlugin] 22-May-2018 10:57:20.828 INFO [http-nio-8080-exec-4] org.apache.openejb.cdi.CdiScanner.handleBda Using annotated mode for jar:file:/C:/software/apache-tomee-webprofile-7.0.4-adjunkto/temp/0-ROOT/WEB-INF/lib/adjunkto-domain-1.0-SNAPSHOT.jar!/META-INF/beans.xml looking all classes to find CDI beans, maybe think to add a beans.xml if not there or add the jar to exclusions.list 22-May-2018 10:57:21.329 INFO [http-nio-8080-exec-4] org.apache.webbeans.config.BeansDeployer.validateInjectionPoints All injection points were validated successfully. 22-May-2018 10:57:21.333 INFO [http-nio-8080-exec-4] org.apache.openejb.cdi.OpenEJBLifecycle.startApplication OpenWebBeans Container has started, it took 528 ms. 22-May-2018 10:57:21.340 INFO [http-nio-8080-exec-4] org.apache.openejb.assembler.classic.Assembler.createApplication Deployed Application(path=C:\software\apache-tomee-webprofile-7.0.4-adjunkto\temp\0-ROOT) 22-May-2018 10:57:21.492 INFO [http-nio-8080-exec-4] sun.reflect.DelegatingMethodAccessorImpl.invoke At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 22-May-2018 10:57:21.848 INFO [http-nio-8080-exec-4] org.apache.openejb.server.cxf.rs.CxfRsHttpListener.deployApplication Using readers: 22-May-2018 10:57:21.849 INFO [http-nio-8080-exec-4] org.apache.openejb.server.cxf.rs.CxfRsHttpListener.deployApplication org.apache.cxf.jaxrs.provider.PrimitiveTextProvider@71670710 22-May-2018 10:57:21.849 INFO [http-nio-8080-exec-4] org.apache.openejb.server.cxf.rs.CxfRsHttpListener.deployApplication org.apache.cxf.jaxrs.provider.FormEncodingProvider@143be198 22-May-2018 10:57:21.849 INFO [http-nio-8080-exec-4] org.apache.openejb.server.cxf.rs.CxfRsHttpListener.deployApplication org.apache.cxf.jaxrs.provider.MultipartProvider@657973c7 22-May-2018 10:57:21.849 INFO [http-nio-8080-exec-4] org.apache.openejb.server.cxf.rs.CxfRsHttpListener.deployApplication org.apache.cxf.jaxrs.provider.SourceProvider@46e83b9c 22-May-2018 10:57:21.850 INFO [http-nio-8080-exec-4] org.apache.openejb.server.cxf.rs.CxfRsHttpListener.deployApplication org.apache.cxf.jaxrs.provider.JAXBElementTypedProvider@c685959 22-May-20
解决方案
从日志可以看到,TomEE已经明确输出了Deployed Application(path=...),说明应用部署完全正常,问题出在IntelliJ没有正确识别TomEE的部署完成信号——毕竟TomEE的部署流程比普通Tomcat多了CDI、EJB等组件的初始化,IDE的默认检测规则没跟上。试试下面几个方法:
1. 延长IntelliJ的部署超时时间
- 打开IntelliJ的设置(Windows/Linux:
File→Settings;Mac:IntelliJ IDEA→Preferences) - 导航到
Build, Execution, Deployment→Application Servers,选中你的TomEE实例 - 把
Deployment timeout从默认的10秒改成30秒甚至更长,点击Apply后重新部署
2. 配置IntelliJ识别TomEE的部署完成日志
IntelliJ默认通过特定日志关键词判断部署状态,我们可以手动添加TomEE的关键词:
- 打开TomEE服务器的配置界面(右上角服务器列表 → 点击
Edit Configurations) - 切换到
Logs标签页,点击Add→ 选择Server Log - 在
Pattern to detect application start输入框中,填入Deployed Application\(path=.*\) - 保存配置后重新部署,IntelliJ就能通过这个日志判断应用已经启动完成
3. 切换成打包后的WAR文件部署
war exploded模式下,IntelliJ的状态检测可能和TomEE的热部署机制冲突,换成完整WAR包试试:
- 打开
File→Project Structure→Artifacts - 新建或选择一个打包好的
war类型Artifact(不是war exploded) - 在服务器配置的
Deployment标签下,替换原来的war exploded为这个WAR包,重新部署
4. 清理IntelliJ缓存并重置服务器配置
有时候缓存会导致状态识别异常:
- 点击
File→Invalidate Caches...,选择Invalidate and Restart - 重启IDE后,删除原来的TomEE服务器配置,重新添加一次,再部署应用
这些方法基本能解决这个问题,我自己碰到的时候用第一个方案就搞定了,你可以按顺序试试。
内容的提问来源于stack exchange,提问作者Pavel Arnošt
相关产品推荐
相关产品推荐

