我正在尝试部署在Tomcat上运行的Java Web应用程序。我拿到了这本书
适用于Web应用程序的专业Java:具有Websockets,Spring Framework,JPA Hibernate和Spring Security
我已经做了所有事情,以使IntelliJ IDEA 13与Tomcat 8.0.9一起工作。我手动测试了服务器容器,它运行良好,甚至部署.war文件也很好用。然而,当我继续开始/调试一个Web应用程序 - 在这种情况下,第一个例子形成书 - 从IntelliJ应用程序不会开始。 Tomcat日志中的输出并不多见。
服务器输出告诉我:
Connected to server
[2014-08-08 09:17:35,075] Artifact Sample-Debug-IntelliJ:war exploded: Artifact is being deployed, please wait...
[2014-08-08 09:17:35,097] Artifact Sample-Debug-IntelliJ:war exploded: Error during artifact deployment. See server log for details.
[2014-08-08 09:17:35,098] Artifact Sample-Debug-IntelliJ:war exploded: com.intellij.javaee.oss.admin.jmx.JmxAdminException: com.intellij.execution.ExecutionException: L:\java-dev\java_web_apps_chapter_code\9781118656464 Full Code\Chapter 02\Sample-Debug- IntelliJ\target\sample-debug-intellij-1.0.0.SNAPSHOT not found for the web module.
08-Aug-2014 21:17:44.671 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory L:\java-dev\apache-tomcat-8.0.9\webapps\manager
08-Aug-2014 21:17:44.939 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory L:\java-dev\apache-tomcat-8.0.9\webapps\manager has finished in 268 ms
Tomcat Catalina Log输出:
08-Aug-2014 22:56:35.843 INFO [main] org.apache.catalina.core.AprLifecycleListener.init Loaded APR based Apache Tomcat Native library 1.1.30 using APR version 1.4.8.
08-Aug-2014 22:56:35.846 INFO [main] org.apache.catalina.core.AprLifecycleListener.init APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
08-Aug-2014 22:56:36.652 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.0.1g 7 Apr 2014)
08-Aug-2014 22:56:36.738 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-apr-8080"]
08-Aug-2014 22:56:36.746 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-apr-8009"]
08-Aug-2014 22:56:36.747 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1060 ms
08-Aug-2014 22:56:36.771 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
08-Aug-2014 22:56:36.771 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.9
08-Aug-2014 22:56:36.778 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
08-Aug-2014 22:56:36.784 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8009"]
08-Aug-2014 22:56:36.785 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 38 ms
08-Aug-2014 22:56:46.785 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory L:\java-dev\apache-tomcat-8.0.9\webapps\manager
08-Aug-2014 22:56:47.035 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory L:\java-dev\apache-tomcat-8.0.9\webapps\manager has finished in 251 ms
我已经在Windows和OSX上尝试过,但两者的故事完全相同,错误相同。
当我访问http://localhost:8080/
时,我可以看到服务器已启动并正在运行。但是,该应用程序尚未部署。
任何人遇到与我相同的错误和/或知道解决方案?
我正在运行IntelliJ IDEA 13.0.3,Java 1.8.0_11和Tomcat 8.0.9。
编辑:我也尝试使用IntelliJ IDEA 13.1.4。没有任何区别。下载Tomcat,解压缩并对其进行以下更改(步骤2-4);
在conf/tomcat-users.xml
我添加了此用户:
<user username="admin" password="admin" roles="manager-gui,admin-gui" />
在conf/web.xml
我添加了org.apache.jasper.servlet.jspServlet
元素
<init-param>
<param-name>compilerSourceVM</param-name>
<param-value>1.8</param-value>
</init-param>
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.8</param-value>
</init-param>
<init-param>
<param-name>compiler</param-name>
<param-value>modern</param-value>
</init-param>
下载了apache-ant并在setenv.bat
目录中添加了apache-tomcat/bin
文件,其中包含以下脚本
export CLASSPATH=L:/java-dev/jdk8/lib/tools.jar:L:/java-dev/apache-ant/lib/ant.jar:L:/java-dev/apache-ant/lib/ant-launcher.jar
启动IntelliJ并添加了Tomcat应用程序服务器。
然后我导入了项目并将其设置为使用我刚刚添加的Tomcat服务器。
我尝试部署一个IntelliJ自己创建的JavaEE Web应用程序,并立即运行。看起来这本书所引用的源代码有问题。
答案 0 :(得分:1)
对我来说,它适用于:
文件&gt;项目结构&gt;工件 在里面 右侧的输出布局&gt;&#34;可用元素?&#34;
右键单击可用的库(对我而言是#34; Spring MVC-4.2.4.RELEASE&#34;)
放入Lib(实际点击修复警告按钮)
它有效。
答案 1 :(得分:0)
在IntelliJ IDEA中打开“调试配置”,并确保选中“部署Tomcat中配置的应用程序”复选框,如screenshot上所示
答案 2 :(得分:0)