我正在使用Spring MVC做一个简单的登录应用程序。 这是一个MAVEN动态Web项目。 在运行项目时,我从 Servlet.service()方法获得 StackOverFlowError 。 我有所有文件结构如下。
Web.xml: -
/etc/
User-Beans.xml: -
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>Archetype Created Web Application</display-name>
<welcome-file-list>
<welcome-file>CPIHomepage.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>spring-mvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- <servlet-class>com.icesoft.faces.webapp.xmlhttp.PersistentFacesServlet</servlet-class> -->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring-mvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Spring-mvc-servlet.xml: -
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.ericsson.oss.wmom" />
<context:annotation-config />
<bean id="loginBean" class="com.ericsson.oss.wmom.Bean.LoginBean" />
<bean id="loginController" class="com.ericsson.oss.wmom.Controller.LoginController" />
Pom.xml: -
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<import resource="classpath:user-beans.xml" />
<context:component-scan base-package="com.ericsson.oss.wmom" />
<context:annotation-config />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/" />
<property name="suffix" value="." />
</bean>
我得到的例外: -
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.oss.ericsson.wranmom</groupId>
<artifactId>CPITool</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>CPITool Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>4.3.2.RELEASE</spring.version>
<junit.version>3.8.1</junit.version>
<servlet.version>3.1.0</servlet.version>
<servlet.version>3.0.1</servlet.version>
</properties>
<dependencies>
<!-- javax.servlet-api dependancy configures javax.servlet.http.HttpServlet
class in the java build path of index.jsp to avoid the below error . "The
superclass \u201cjavax.servlet.http.HttpServlet\u201d was not found on the Java Build
Path index.jsp" -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- Spring Framework -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Servlet API -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.faces/javax.faces-api -->
<dependency>
<groupId>javax.faces</groupId>
<artifactId>javax.faces-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.faces/jsf-api -->
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>CPITool</finalName>
</build>
LoginController.java: -
Servlet.service() for servlet spring-mvc threw exception
java.lang.StackOverflowError
at java.net.SocketImpl.getInetAddress(SocketImpl.java:235)
at java.net.SocksSocketImpl.getInetAddress(SocksSocketImpl.java:1038)
at java.net.Socket.getInetAddress(Socket.java:675)
at org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:1055)
at org.apache.coyote.Request.action(Request.java:351)
at org.apache.catalina.connector.Request.getRemoteAddr(Request.java:1235)
at org.apache.catalina.connector.RequestFacade.getRemoteAddr(RequestFacade.java:481)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
at javax.servlet.ServletRequestWrapper.getRemoteAddr(ServletRequestWrapper.java:260)
}