Apache Tomcat: 408 error with Form Authentication - forms

I'm developing a web-application using Apache Tomcat. I've followed a guide to implement form authentication but something doesn't work. When I try to login with correct credentials, I get this error:
HTTP Status 408 - The time allowed for the login process has been exceeded. If you wish to continue you must either click back twice and re-click the link you requested or close and re-open your browser
type Status report
message The time allowed for the login process has been exceeded. If you wish to continue you must either click back twice and re-click the link you requested or close and re-open your browser
description The client did not produce a request within the time that the server was prepared to wait.
Apache Tomcat/8.0.0-RC5
If I insert invalid credentials instead, Tomcat redirects me correctly to the login-failed.html page.
This is the structure of my web application:
<webapps>
/mywebapp
/css
/html
login.html
login-failed.html
/members
members-index.html
/js
/META-INF
context.xml
/WEB-INF
web.xml
users.xml
web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="mywebapp" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>My web app</display-name>
<description>My web app description</description>
<welcome-file-list>
<welcome-file>html/login.html</welcome-file>
</welcome-file-list>
<!-- Define the roles we want to use in the application -->
<security-role>
<role-name>member</role-name>
</security-role>
<security-constraint>
<!-- Define the resource -->
<web-resource-collection>
<web-resource-name>Members Only</web-resource-name>
<url-pattern>/html/members/*</url-pattern>
</web-resource-collection>
<!-- Only members can access this resource -->
<auth-constraint>
<role-name>member</role-name>
</auth-constraint>
<user-data-constraint>
<!-- transport-guarantee can be CONFIDENTIAL, INTEGRAL, or NONE -->
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<!-- Use FORM security -->
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/html/login.html</form-login-page>
<form-error-page>/html/login-failed.html</form-error-page>
</form-login-config>
</login-config>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
users.xml file:
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="member"/>
<user username="john" password="pass" roles="member"/>
</tomcat-users>
context.xml file:
<Context>
<Realm className="org.apache.catalina.realm.MemoryRealm"
pathname="webapps/mywebapp/WEB-INF/users.xml" />
</Context>
login.html file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it" lang="it">
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<div id="container">
<form id="login_form" method="post" action="j_security_check">
<fieldset>
<legend>Login</legend>
<ul>
<li>
<label for="username">Username:</label>
<input type="text" name="j_username" maxlength="25" />
</li>
<li>
<label for="password">Password:</label>
<input type="password" name="j_password" maxlength="32" />
</li>
</ul>
<input type="submit" value="Go" />
</fieldset>
</form>
</div>
</body>
</html>
login-failed file:
<h1>Login failed</h1>
members-index.html file:
<h1>Welcome to Members Area</h1>
Thank you.

Related

IBM Cloud: App ID is not Authenticating on localhost, but works on CF

I am trying to run IBM App ID on localhost. The App ID Login Widget is coming up. But after login it is not redirecting to my application. It is showing the login page again.
The same codebase is running on CF instance very well.
URL : https://us-south.appid.cloud.ibm.com/oauth/v4/xxxxxxx-62a9-4a02-8710-f421c59571a5/authorization?response_type=code&client_id=xxxxxxx-4c08-4f11-8370-181061306b65&state=001630038048040MsOwH2vS2&redirect_uri=https://localhost:9443/ne/oidcclient/redirect/MyRP&scope=openid+profile&language=en
Server.xml
<server description="new server">
<!-- Enable features -->
<featureManager>
<feature>jsp-2.3</feature>
<feature>localConnector-1.0</feature>
<!-- Features for APP ID -->
<feature>servlet-3.1</feature>
<feature>appSecurity-2.0</feature>
<feature>openidConnectClient-1.0</feature>
<feature>ssl-1.0</feature>
</featureManager>
<authFilter>
<requestUrl matchType="notContain" urlPattern="/getToken"/>
</authFilter>
<!-- To access this server from a remote client add a host attribute to the following
element, e.g. host="*" -->
<httpEndpoint httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/>
<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true" startTimeout="15m"/>
<webContainer extractHostHeaderPort="true" trustHostHeaderPort="true"/>
<applicationMonitor dropinsEnabled="false" updateTrigger="mbean"/>
<config updateTrigger="mbean"/>
<applicationMonitor updateTrigger="mbean"/>
<!--
<keyStore id="opTestKeyStore" location="\resources\security/mytruststore.jks" type="JKS"
password="keystorePwd" />
<openidConnectProvider id="OAuthConfigSample" oauthProviderRef="OAuthConfigSample"
signatureAlgorithm="RS256" keyStoreRef="opTestKeyStore" keyAliasName="myOpKeyAlias" />
-->
<keyStore id="defaultKeyStore" password="${keystore_password}"/>
<ssl id="oidcClientSSL" keyStoreRef="defaultKeyStore" trustDefaultCerts="true"/>
<openidConnectClient authFilterid="myAuthFilter"
authorizationEndpointUrl="${APP_ID_OAUTH_SERVER_URL}/authorization"
clientId="${APP_ID_CLIENT_ID}" clientSecret="${APP_ID_CLIENT_SECRET}" id="MyRP"
issuerIdentifier="${APP_ID_OAUTH_SERVER_URL}"
jwkEndpointUrl="${APP_ID_OAUTH_SERVER_URL}/publickeys"
redirectToRPHostAndPort="https://localhost:9443/ne/" signatureAlgorithm="RS256"
tokenEndpointAuthMethod="basic" tokenEndpointUrl="${APP_ID_OAUTH_SERVER_URL}/token"/>
<logging consoleLogLevel="INFO" logDirectory="${application.log.dir}"/>
<!-- <webApplication id="ne" location="ne-1.0.0-BUILD-SNAPSHOT.war" name="ne"/>-->
<webApplication id="ne" location="ne-1.0.0-BUILD-SNAPSHOT.war" name="ne"/>
</server>

Apache ODE BPEL soapenv:Server axis2ns1:selectionFailure

I am new to BPEL and struggling to get started.
I created a simple If/Else workflow, but getting the following error when I am testing the wsdl file with eclipse web services explorer:
soapenv:Server axis2ns1:selectionFailure
My understanding from other similar questions is its probably something very simple and related to namespace or variable name in the if condition, but I can't understand why, and how to solve it.
I am using Apache ODE 1.3.7 on Eclipse 4.7.1 Oxygen and Tomcat 8.5.
This is my workflow design:
BPEL FILE:
<!-- Flow1 BPEL Process [Generated by the Eclipse BPEL Designer] -->
<!-- Date: Mon Nov 13 23:18:38 AST 2017 -->
<bpel:process name="Flow1"
targetNamespace="http://Flow1"
suppressJoinFailure="yes"
xmlns:tns="http://Flow1"
xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
>
<!-- Import the client WSDL -->
<bpel:import location="Flow1Artifacts.wsdl" namespace="http://Flow1"
importType="http://schemas.xmlsoap.org/wsdl/" />
<!-- ================================================================= -->
<!-- PARTNERLINKS -->
<!-- List of services participating in this BPEL process -->
<!-- ================================================================= -->
<bpel:partnerLinks>
<!-- The 'client' role represents the requester of this service. -->
<bpel:partnerLink name="client"
partnerLinkType="tns:Flow1"
myRole="Flow1Provider"
/>
</bpel:partnerLinks>
<!-- ================================================================= -->
<!-- VARIABLES -->
<!-- List of messages and XML documents used within this BPEL process -->
<!-- ================================================================= -->
<bpel:variables>
<!-- Reference to the message passed as input during initiation -->
<bpel:variable name="input"
messageType="tns:Flow1RequestMessage"/>
<!--
Reference to the message that will be returned to the requester
-->
<bpel:variable name="output"
messageType="tns:Flow1ResponseMessage"/>
</bpel:variables>
<!-- ================================================================= -->
<!-- ORCHESTRATION LOGIC -->
<!-- Set of activities coordinating the flow of messages across the -->
<!-- services integrated within this business process -->
<!-- ================================================================= -->
<bpel:sequence name="main">
<!-- Receive input from requester.
Note: This maps to operation defined in Flow1.wsdl
-->
<bpel:receive name="receiveInput" partnerLink="client"
portType="tns:Flow1"
operation="process" variable="input"
createInstance="yes"/>
<!-- Generate reply to synchronous request -->
<bpel:if name="If">
<bpel:condition expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[$input.payload/tns:input="John"]]></bpel:condition>
<bpel:sequence name="Sequence">
<bpel:assign validate="no" name="Assign">
<bpel:copy>
<bpel:from>
<bpel:literal xml:space="preserve">Hi John</bpel:literal>
</bpel:from>
<bpel:to part="payload" variable="output">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:result]]></bpel:query>
</bpel:to>
</bpel:copy>
</bpel:assign>
<bpel:reply name="replyOutput" partnerLink="client" portType="tns:Flow1" operation="process" variable="output" />
</bpel:sequence>
<bpel:else>
<bpel:sequence name="Sequence1">
<bpel:assign validate="no" name="Assign1">
<bpel:copy>
<bpel:from>
<bpel:literal xml:space="preserve">Not john</bpel:literal>
</bpel:from>
<bpel:to part="payload" variable="output">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:result]]></bpel:query>
</bpel:to>
</bpel:copy>
</bpel:assign>
<bpel:reply name="Reply" partnerLink="client" operation="process" portType="tns:Flow1" variable="output"></bpel:reply>
</bpel:sequence>
</bpel:else>
</bpel:if>
</bpel:sequence>
</bpel:process>
WSDL FILE:
<?xml version="1.0"?>
<definitions name="Flow1"
targetNamespace="http://Flow1"
xmlns:tns="http://Flow1"
xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TYPE DEFINITION - List of types participating in this BPEL process
The BPEL Designer will generate default request and response types
but you can define or import any XML Schema type and use them as part
of the message types.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<types>
<schema attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="http://Flow1"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="Flow1Request">
<complexType>
<sequence>
<element name="input" type="string"/>
</sequence>
</complexType>
</element>
<element name="Flow1Response">
<complexType>
<sequence>
<element name="result" type="string"/>
</sequence>
</complexType>
</element>
</schema>
</types>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MESSAGE TYPE DEFINITION - Definition of the message types used as
part of the port type defintions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<message name="Flow1RequestMessage">
<part name="payload" element="tns:Flow1Request"/>
</message>
<message name="Flow1ResponseMessage">
<part name="payload" element="tns:Flow1Response"/>
</message>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PORT TYPE DEFINITION - A port type groups a set of operations into
a logical service unit.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- portType implemented by the Flow1 BPEL process -->
<portType name="Flow1">
<operation name="process">
<input message="tns:Flow1RequestMessage" />
<output message="tns:Flow1ResponseMessage"/>
</operation>
</portType>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PARTNER LINK TYPE DEFINITION
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<plnk:partnerLinkType name="Flow1">
<plnk:role name="Flow1Provider" portType="tns:Flow1"/>
</plnk:partnerLinkType>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BINDING DEFINITION - Defines the message format and protocol details
for a web service.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<binding name="Flow1Binding" type="tns:Flow1">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="process">
<soap:operation
soapAction="http://Flow1/process" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SERVICE DEFINITION - A service groups a set of ports into
a service unit.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<service name="Flow1Service">
<port name="Flow1Port" binding="tns:Flow1Binding">
<soap:address location="http://localhost:8084/ode/processes/Flow1" />
</port>
</service>
</definitions>
and Deploy.xml
<?xml version="1.0" encoding="UTF-8"?>
<deploy xmlns="http://www.apache.org/ode/schemas/dd/2007/03" xmlns:Flow1="http://Flow1">
<process name="Flow1:Flow1">
<active>true</active>
<retired>false</retired>
<process-events generate="all"/>
<provide partnerLink="client">
<service name="Flow1:Flow1Service" port="Flow1Port"/>
</provide>
</process>
</deploy>
SelectionFailure indicates that xml element that is being queried is not found. Looking at your BPEL, I assume the output variable is being queried before initializing it.
Initialize the output variable before the if/else:
<bpel:assign validate="no" name="initialize">
<bpel:copy>
<bpel:from>
<bpel:literal xml:space="preserve">
<tns:Flow1Response xmlns:tns="http://Flow1"><tns:result /></tns:Flow1Response>
</bpel:literal>
</bpel:from>
<bpel:to part="payload" variable="output" />
</bpel:copy>
</bpel:assign>

How to config spring security

I'm trying learning how to protect my web Application using Spring security I have some problems,
this is my web.xml
<welcome-file-list>
<welcome-file>loginPage.html</welcome-file>
<welcome-file>loginPage.htm</welcome-file>
<welcome-file>loginPage.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<!-- Spring context files to be loaded -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/dispatcher-servlet.xml,
/WEB-INF/spring-security.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- filter declaration for Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
and this my spring-security.xml
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" 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.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<http auto-config="true">
<intercept-url pattern="/*" access="ROLE_USER" />
<form-login login-processing-url="/login" login-page="/loginPage"
username-parameter="username" password-parameter="password"
default-target-url="/secured/mypage" authentication-failure-url="/loginPage?auth=fail" />
<logout logout-url="/logout" logout-success-url="/logoutPage" />
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="srccodes" password="password" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
and finally my servlet-dispatcher.xml
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/" />
<property name="suffix" value=".jsp" />
</bean>
My application run normally and I have my login page, when I type the right login et password I have error 404 not found!! with url
localhost:8084/LoginFormExampleSpring/secured/mypage
this is my form
<form action="${pageContext.request.contextPath}/login" method="post">
<table>
<tr>
<td>Username:</td>
<td><input type='text' name='username' /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password'></td>
</tr>
<tr>
<td colspan='2'><input name="submit" type="submit" value="Submit"></td>
</tr>
</table>
</form>
anyone can help me please?
It sounds like you need to add a mapping for /secured/mypage To do so:
Create a file at /WEB-INF/pages/secured/mypage.jsp
Add a mvc:view-controller to dispatcher-servlet.xml
For example:
dispatcher-servlet.xml
<mvc:view-controller path="/secured/mypage"/>

The requested resource () is not available in sample spring mvc application

I'm new bee to spring. Just started my sample application in sprinv mvc. But, I can't able to view the page since it is showing "The requested resource () is not available." Cannot figure out where is the problem. I'm pasting the code below.
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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" >
<servlet>
<servlet-name>my</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>my</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
</web-app>
**
my-servlet.xml
**
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
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-2.5.xsd">
<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
<bean name="/index.html" class="mypackage.web.myController"/>
</beans>
**
MyController.java
**
package mypackage.web;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public class myController implements Controller{
public ModelAndView handleRequest(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException{
String msg="Hello!!! I'm coming from Controller. You Catched me ";
ModelAndView mv = new ModelAndView("index");
mv.addObject("message",msg);
return mv;
}
}
index.jsp
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<%#taglib prefix="i" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>My First Application in Spring</title>
</head>
<body>
<p>Check Below</p>
<p>
<em>${message}</em>
</p>
</body>
</html>
It's almost configured correctly, so well done so far :-) There are a couple of minor problems here that are causing the problems you see. Firstly, the bean is currently defined with a lowercase m:
<bean name="/index.html" class="mypackage.web.myController"/>
Although this is allowed, it is not conventional, so Spring will not be able to find the correct bean without some additional configuration.
Also, it was not clear from the question which URL you are using, but it should be something of the form http://localhost:8080/<project>/myIndex.html
There is a good summary of the convention here.
So we have 2 options… either rename the class to MyController and save as MyController.java or modify the ControllerClassNameHandlerMapping bean to be case sensitive like so:
<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
<property name="caseSensitive" value="true" />
</bean>
Furthermore, it is not the cause of the problem but if you use the ControllerClassNameHandlerMapping you can omit bean name, so you can just use:
<bean class="mypackage.web.MyController"/>
I guess the most annoying part is that the web application deploys without error. However if you examine the log, there is a marked difference:
Deployment of incorrectly configured webapp:
04-Jul-2011 09:13:58 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#5f0e7d: defining beans []; root of factory hierarchy
04-Jul-2011 09:13:58 org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'my': initialization completed in 157 ms
Deployment of correctly configured webapp:
04-Jul-2011 09:15:33 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#de537: defining beans [org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping#0,viewResolver,mypackage.web.MyController#0]; root of factory hierarchy
04-Jul-2011 09:15:49 org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/my*] onto handler 'mypackage.web.MyController#0'
04-Jul-2011 09:15:49 org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'my': initialization completed in 296 ms
Secondly, once the mapping is fixed, you may discover that the JSP is not found. In the sample I created, I added the views under /WEB-INF/jsp so I needed to update the prefix property in my-servlet.xml to <property name="prefix" value="/WEB-INF/jsp/"/>. However depending on the location of your views, you may not need to do this.
Personally I find the annotation based approach for MVC in Spring much easier to configure and follow, so I will recommend that you read REST in Spring 3: #MVC as you might find that easier to implement.
i was having the same problem because i was following step by step a tutorials thats up on the Netbeans official website, there it says and i quote "note that the JSTL (JavaServer Pages Standard Tag Library) library is added to the classpath during project creation by default. Deselect this option (as in the above screenshot), since you do not require JSTL for this tutorial. " once i tried leaving it checked i could be able to run my sample project, i really dont know anything more, hope this helps someone!

javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20

I have created simple Java Dynamic Web project in Eclipse. I host my project on Glassfish 2.1.1. When I try open p1.jsf page in browser I got following error:
javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20.
I have no idea how to correct this error...
Here is may p1.jsf definition:
<%# page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%# taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%# taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<f:view>
<h:outputLabel value="outputLabel"></h:outputLabel>
</f:view>
</body>
</html>
My web.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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>web4</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>FacesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
</web-app>
My faces-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
version="1.2">
</faces-config>
Error details from Glassfish log:
PWC1406: Servlet.service() for servlet FacesServlet threw exception javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20
org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:860)
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:558)
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:490)
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:873)
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:558)
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:490)
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:873)
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:558)
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:490)
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:873)
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:558)
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:490)
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
FacesServlet should be mapped on an url-pattern of *.jsf (or anything else other than *.jsp).
No javax.faces.DEFAULT_SUFFIX is needed in web.xml if you already use JSP. The JSP page itself must actually be named pagename.jsp (and thus not pagename.jsf, this is the root cause of the recursive forward calls).
Open the page in the webbrowser using the *.jsf suffix: http://example.com/context/pagename.jsf (and thus not by pagename.jsp, else you would get RuntimeException: FacesContext not found).
This means that recursive internal forwards occur. A few things to observe:
make sure you are accessing the page via the right suffix. i.e. http://localhost:8080/app/p1.jsp, and not p1.page - you have mapped the jsf suffix to be .jsp
check your navigation rules in your faces-config.xml
make sure you have the following context-param defined:
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.jsp</param-value>
</context-param>
To summarize - the javax.faces.DEFAULT_SUFFIX determines the file extension under which the page are sought, and the <url-pattern> of the faces-servlet determines the way the jsf pages are accessed by clients (browsers)