我正在编写我的第一个struts示例.i遵循了确切的步骤但是即便面对这个问题,也不知道什么错误的代码正在我的老师的机器上工作但我的不是,我认为我正在做一个小错误plz帮我找到 1)我有index.jsp
<%@ taglib uri="/struts-tags" prefix="s" %>
<s:form action="login">
<s:textfield name="username" label="username:"></s:textfield>
<s:submit></s:submit>
</s:form>
2)具有Loginaction类(pogo类)的bean包
package bean;
public class Loginaction {
String username;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String execute()
{
return "success";
}
}
3)struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="demo" extends="struts-default">
<action name="login" class="bean.Loginaction">
<result name="success">welcome.jsp</result>
</action>
</package>
</struts>
4)welcome.jsp
<h1>hi user.</h1>
5)web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>struts1</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
6)和目录结构
包和src文件夹中的struts.xml以及web-inf(jsps和web.xml)
控制台上的我得到了``
Apr 4, 2013 12:54:26 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /home/tarun/MyEclipse Blue/binary/com.sun.java.jdk.linux.x86_64_1.6.0.u43/bin:/home/tarun/MyEclipse Blue/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_11.0.0.me201211151802/tomcat/bin
Apr 4, 2013 12:54:26 AM org.apache.coyote.http11.Http11Protocol init
SEVERE: Error initializing endpoint
java.net.BindException: Address already in use:8080
at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:501)
at org.apache.coyote.http11.Http11Protocol.init(Http11Protocol.java:177)
at org.apache.catalina.connector.Connector.initialize(Connector.java:1059)
at org.apache.catalina.core.StandardService.initialize(StandardService.java:677)
at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:792)
at org.apache.catalina.startup.Catalina.load(Catalina.java:518)
at org.apache.catalina.startup.Catalina.load(Catalina.java:538)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:260)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:412)
Apr 4, 2013 12:54:26 AM org.apache.catalina.startup.Catalina load
SEVERE: Catalina.start
LifecycleException: Protocol handler initialization failed: java.net.BindException: Address already in use:8080
at org.apache.catalina.connector.Connector.initialize(Connector.java:1061)
at org.apache.catalina.core.StandardService.initialize(StandardService.java:677)
at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:792)
at org.apache.catalina.startup.Catalina.load(Catalina.java:518)
at org.apache.catalina.startup.Catalina.load(Catalina.java:538)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:260)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:412)
Apr 4, 2013 12:54:26 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 379 ms
Apr 4, 2013 12:54:26 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Apr 4, 2013 12:54:26 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.13
Apr 4, 2013 12:54:27 AM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Parsing configuration file [struts-default.xml]
Apr 4, 2013 12:54:27 AM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Parsing configuration file [struts-plugin.xml]
Apr 4, 2013 12:54:29 AM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Parsing configuration file [struts.xml]
Apr 4, 2013 12:54:29 AM org.apache.coyote.http11.Http11Protocol start
SEVERE: Error starting endpoint
java.net.BindException: Address already in use:8080
at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:501)
at org.apache.tomcat.util.net.JIoEndpoint.start(JIoEndpoint.java:515)
at org.apache.coyote.http11.Http11Protocol.start(Http11Protocol.java:204)
at org.apache.catalina.connector.Connector.start(Connector.java:1132)
at org.apache.catalina.core.StandardService.start(StandardService.java:531)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Apr 4, 2013 12:54:29 AM org.apache.catalina.startup.Catalina start
SEVERE: Catalina.start:
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: java.net.BindException: Address already in use:8080
at org.apache.catalina.connector.Connector.start(Connector.java:1139)
at org.apache.catalina.core.StandardService.start(StandardService.java:531)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Apr 4, 2013 12:54:29 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3506 ms
Apr 4, 2013 12:54:29 AM org.apache.catalina.core.StandardServer await
SEVERE: StandardServer.await: create[8005]:
java.net.BindException: Address already in use
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383)
at java.net.ServerSocket.bind(ServerSocket.java:328)
at java.net.ServerSocket.<init>(ServerSocket.java:194)
at org.apache.catalina.core.StandardServer.await(StandardServer.java:373)
at org.apache.catalina.startup.Catalina.await(Catalina.java:630)
at org.apache.catalina.startup.Catalina.start(Catalina.java:590)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Apr 4, 2013 12:54:29 AM org.apache.coyote.http11.Http11Protocol pause
INFO: Pausing Coyote HTTP/1.1 on http-8080`enter code here`
Apr 4, 2013 12:54:29 AM org.apache.catalina.connector.Connector pause
SEVERE: Protocol handler pause failed
java.lang.NullPointerException
at org.apache.jk.server.JkMain.pause(JkMain.java:679)
at org.apache.jk.server.JkCoyoteHandler.pause(JkCoyoteHandler.java:153)
at org.apache.catalina.connector.Connector.pause(Connector.java:1074)
at org.apache.catalina.core.StandardService.stop(StandardService.java:563)
at org.apache.catalina.core.StandardServer.stop(StandardServer.java:744)
at org.apache.catalina.startup.Catalina.stop(Catalina.java:616)
at org.apache.catalina.startup.Catalina$CatalinaShutdownHook.run(Catalina.java:659)
答案 0 :(得分:0)
这意味着进程已经在使用端口8080.通常,通过启动tomcat实例而不关闭前一个实例来启动新手。你应该检查一下。此外,可能已经有另一个服务侦听端口8080.如果是这样,您需要确定使用端口8080的进程。
我的建议是,您了解系统中可用的工具,这些工具可以帮助您回答以下问题:
1)正在运行哪些进程?
2)哪些网络端口已打开以侦听传入请求,又称哪些是服务器?
一旦你能做到这一点,你就会知道如何识别冲突的过程,然后你只需要关闭它。
答案 1 :(得分:0)
尝试查看您看到错误的计算机上的所有tomcat和Java进程,然后再次尝试启动tomcat。在您的情况下,8080已被另一个进程使用。先杀了,然后再试一次。
答案 2 :(得分:-1)
只需更改 server.xml 文件中的tomcat服务器http端口nb,保持原样。
按照以下步骤执行此操作:
<---Define a non-SSL HTTP/1.1 Connector on port 8080---->
<Connector port="8090" ..........>
RAAM