2

我需要将我的项目从 Php 更改为 Java/Spring。现在一切都非常适合更改(所有新版本:Spring5、Java9、Tomcat9 和其他一些很酷的新东西)。

自从我使用 Java 和 Tomcat 开发以来已经有一段时间了,我对 IntelliJ 还是很陌生。

所以现在我有一个 Spring 项目、许多库和一个在服务器上运行的 Tomcat。我知道,我可以在本地开发,但由于项目情况,那不是选项。我需要“实时更新”。

一切都设置好了(服务器上的 JMX 端口、调试端口等)。如果我手动触发 Artifactbuildung,神器(战争爆炸)看起来不错。如果我手动将该工件上传到服务器并重新启动 Tomcat,则一切正常。但是这样上传和部署需要几分钟,这很烦人。

但是,如果我在 IntelliJ 和 HotSwap 类中运行调试模式(我什至尝试过“重新部署”),IntelliJ 会在工件部署期间给我一个错误“错误”。有关详细信息,请参阅服务器日志。”。

10-Oct-2017 21:07:18.704 INFORMATION [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.StandardContext.reload Reloading Context with name [<contextName>] has started
10-Oct-2017 21:07:22.638 INFORMATION [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.StandardContext.reload Reloading Context with name [<contextName>] is completed
10-Oct-2017 21:07:32.645 WARNUNG [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.StandardContext.backgroundProcess Exception processing loader [WebappLoader[StandardEngine[Catalina].StandardHost[localhost].StandardContext[<contextName>]]] background process
 java.lang.IllegalStateException: java.util.zip.ZipException: error in opening zip file
    at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.getArchiveEntry(AbstractSingleArchiveResourceSet.java:98)
    at org.apache.catalina.webresources.AbstractArchiveResourceSet.getResource(AbstractArchiveResourceSet.java:254)
    at org.apache.catalina.webresources.StandardRoot.getResourceInternal(StandardRoot.java:281)
    at org.apache.catalina.webresources.Cache.getResource(Cache.java:62)
    at org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:216)
    at org.apache.catalina.webresources.StandardRoot.getClassLoaderResource(StandardRoot.java:225)
    at org.apache.catalina.loader.WebappClassLoaderBase.modified(WebappClassLoaderBase.java:674)
    at org.apache.catalina.loader.WebappLoader.modified(WebappLoader.java:343)
    at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:287)
    at org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:5461)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1394)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1398)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1398)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1366)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.zip.ZipException: error in opening zip file
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:225)
    at java.util.zip.ZipFile.<init>(ZipFile.java:155)
    at java.util.jar.JarFile.<init>(JarFile.java:166)
    at java.util.jar.JarFile.<init>(JarFile.java:103)
    at org.apache.catalina.webresources.AbstractArchiveResourceSet.openJarFile(AbstractArchiveResourceSet.java:302)
    at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.getArchiveEntry(AbstractSingleArchiveResourceSet.java:94)
    ... 14 more

10-Oct-2017 21:07:42.648 INFORMATION [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.startup.HostConfig.reload Reloading context [/<contextName>]
10-Oct-2017 21:07:42.648 INFORMATION [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.StandardContext.reload Reloading Context with name [/<contextName>] has started
10-Oct-2017 21:07:46.223 INFORMATION [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.StandardContext.reload Reloading Context with name [/<contextName>] is completed
10-Oct-2017 21:07:46.227 SCHWERWIEGEND [RMI TCP Connection(125)-79.208.253.91] org.apache.tomcat.util.modeler.BaseModelMBean.invoke Exception invoking method createStandardContext
 java.lang.NullPointerException
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:471)
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:405)
    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:498)
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:287)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
    at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
    at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
    at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
    at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
    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:498)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
    at sun.rmi.transport.Transport$1.run(Transport.java:200)
    at sun.rmi.transport.Transport$1.run(Transport.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

10-Oct-2017 21:07:46.350 INFORMATION [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.StandardContext.reload Reloading Context with name [<contextName>] has started
10-Oct-2017 21:07:50.125 INFORMATION [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.StandardContext.reload Reloading Context with name [<contextName>] is completed

同样:如果我将相同的“内容”/工件上传到服务器并手动重新启动,一切都很好,所以我很确定,它与 IntelliJ Config 或 Tomcat 中的远程设置有关。

以下是配置:

来自日志的服务器 Tomcat 配置:

Listening for transport dt_socket at address: 38001
10-Oct-2017 21:15:58.110 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/9.0.0.M26
10-Oct-2017 21:15:58.112 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Aug 2 2017 20:29:05 UTC
10-Oct-2017 21:15:58.112 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         9.0.0.0
10-Oct-2017 21:15:58.112 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux
10-Oct-2017 21:15:58.112 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            3.13.0-042stab124.2
10-Oct-2017 21:15:58.112 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
10-Oct-2017 21:15:58.112 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /usr/lib/jvm/java-8-oracle/jre
10-Oct-2017 21:15:58.112 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_144-b01
10-Oct-2017 21:15:58.113 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
10-Oct-2017 21:15:58.113 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /opt/apache-tomcat-9.0.0.M26
10-Oct-2017 21:15:58.113 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /opt/apache-tomcat-9.0.0.M26
10-Oct-2017 21:15:58.113 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties
10-Oct-2017 21:15:58.113 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
10-Oct-2017 21:15:58.113 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dfile.encoding=UTF-8
10-Oct-2017 21:15:58.113 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dnet.sf.ehcache.skipUpdateCheck=true
10-Oct-2017 21:15:58.113 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:+UseConcMarkSweepGC
10-Oct-2017 21:15:58.113 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:+CMSClassUnloadingEnabled
10-Oct-2017 21:15:58.116 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:+UseParNewGC
10-Oct-2017 21:15:58.117 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
10-Oct-2017 21:15:58.117 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
10-Oct-2017 21:15:58.117 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote
10-Oct-2017 21:15:58.117 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=9010
10-Oct-2017 21:15:58.117 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.local.only=false
10-Oct-2017 21:15:58.117 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
10-Oct-2017 21:15:58.117 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
10-Oct-2017 21:15:58.117 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -agentlib:jdwp=transport=dt_socket,address=38001,suspend=n,server=y
10-Oct-2017 21:15:58.117 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/opt/tomcat
10-Oct-2017 21:15:58.117 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/opt/tomcat
10-Oct-2017 21:15:58.117 INFORMATION [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/opt/tomcat/temp

以防万一: IntelliJ 配置的截图

所以我的问题:为什么我在 IntelliJ 2017.2.4 上进行 HotSwap 或重新部署时会收到 ZipExceptions?如果我能提供任何其他有用的信息,请告诉我。

(也试过 IntelliJ 2017.1.5)(我试了一百次,所以这不是上传/损坏库的问题)

4

0 回答 0