0

我正在编写我的第一个 struts 示例。我遵循了确切的步骤,但即使遇到这个问题,也不知道在我老师的机器上工作的错误代码是什么,但在我的机器上却没有,我认为我正在做一个小错误,请帮助我定位 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) 欢迎.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)中的其他包和 struts.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)
4

3 回答 3

0

这意味着一个进程已经在使用端口 8080。通常,新手会因为启动一个 tomcat 实例而没有关闭前一个实例而被绊倒。你应该检查一下。此外,可能已经有另一个服务在侦听端口 8080。如果是这样,您需要确定哪个进程正在使用端口 8080。

我的建议是您了解您的系统上有哪些工具可以帮助您回答以下问题:

1)什么进程正在运行?

2)哪些网络端口开放用于监听传入请求,也就是哪些是服务器?

一旦你能做到这一点,你就会知道如何识别冲突的进程,然后你只需要关闭它。

于 2013-04-03T21:19:05.890 回答
0

尝试杀死您看到错误的机器上的所有 tomcat 和 Java 进程,然后再次尝试启动 tomcat。在您的情况下,8080 已被另一个进程使用。先杀死它,然后再试一次。

于 2014-03-26T01:55:30.783 回答
-1

只需更改server.xml文件中的 tomcat 服务器 http 端口 nb 保持原样即可。

为此,请按照以下步骤操作:

  1. 打开../tomcat5.x/conf/server.xml并更改端口 nb 例如8081或 8090 任何而不是 8080
    In...
    <---Define a non-SSL HTTP/1.1 Connector on port 8080---->
    <Connector port="8090" ..........>
  2. 保存。
  3. 最后启动tomcat服务器

就这样。
谢谢你。

拉姆

于 2013-07-08T09:52:38.467 回答