Servlet Exception at new Consumer Manager

14 views
Skip to first unread message

malhotra

unread,
Sep 24, 2008, 6:46:08 AM9/24/08
to OpenID4Java
I am trying to enable a simple app built using Struts2.0 framework for
OpenId. The application is deployed on Apache Tomcat 6.0. I get a
javax.servlet.ServletException at new ConsumerManager() call. Below is
the trace and other relevant information.

org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
javax.servlet.ServletException
at
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:
515)
at
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:
419)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
128)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
286)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
845)
at org.apache.coyote.http11.Http11Protocol
$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:
447)
at java.lang.Thread.run(Unknown Source)


The code is given below:

public class OpenIdLogin extends ActionSupport implements
ServletRequestAware,
ServletResponseAware {
private static final long serialVersionUID = -5998885243419513055L;

private final Log log = LogFactory.getLog(this.getClass());
ConsumerManager manager;

private ServletContext context;
public void init(){

try{
manager=new ConsumerManager();

manager.setAssociations(new InMemoryConsumerAssociationStore());
manager.setNonceVerifier(new InMemoryNonceVerifier(5000));
}
catch(ConsumerException e){
//throw new ServletException();
}
}


private HttpServletRequest request;
private HttpServletResponse response;
private String openid;

public String execute() throws Exception {


if(manager==null){
this.init();
}
.....................
...........}

Struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="loginPage" extends="struts-default">
<action name="Login" class="loginPage.actions.Login">
<result>/notification_page.jsp</result>
<result name="error">/login.jsp</result>
</action>
<action name="OpenIdLogin" class="loginPage.actions.OpenIdLogin">
<result>/redirect.jsp</result>
<result name="error">/login.jsp</result>
</action>
</package>
</struts>

The login.jsp is given below

<%@page language="java" import="java.util.*,javax.servlet.http.*" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<html>
<head>
<title>Login Page</title>

</head>
<body>
<h1>XYZ System</h1>


<s:form action="Login">
<% if (request.getParameter("userid") !=null)
out.println("<b>Login Failed</b><br><br>");
%>
<s:textfield label="User Id" name="userid"></s:textfield>
<s:password label="Password" name="password"></s:password>
<s:submit label="Login" name="Login"></s:submit>
</s:form>
<h2>
Login using your Open id
</h2>
<s:form action="OpenIdLogin">
<s:textfield label="Open Id" name="openid"></s:textfield>
<s:submit label="Login" name="OpenIdLogin"></s:submit>
</s:form>


</body>
</html>

Johnny Bufu

unread,
Sep 25, 2008, 2:30:47 AM9/25/08
to openi...@googlegroups.com

On 24/09/08 03:46 AM, malhotra wrote:
> I am trying to enable a simple app built using Struts2.0 framework for
> OpenId. The application is deployed on Apache Tomcat 6.0. I get a
> javax.servlet.ServletException at new ConsumerManager() call. Below is
> the trace and other relevant information.

There's nothing from org.openid4java.* in the stacktrace. Was it omitted
from your message, or else how do you know/link this stack with the
instantiation of the ConsumerManager?


Johnny

Ankush Malhotra

unread,
Sep 25, 2008, 3:11:49 AM9/25/08
to openi...@googlegroups.com
Well this is the complete stack trace and nothing has been omitted. I initiated remote server debugging the control goes to line (it hits the following breakpoint) 
consumer = new ConsumerManager();

From this line onwards it throws a ServletException. I also downloaded the code from server repository and set a break point at the very first line in the constructor of ConsumerManager.

_httpClient = HttpClientFactory.getInstance(
                _maxRedirects, Boolean.FALSE, _socketTimeout, _connectTimeout,
                CookiePolicy.IGNORE_COOKIES);

 The runtime flow doesnt hit that breakpoint and throws the servletException even before this.
I guess I am doing something wrong in Struts configuration. I came across one of the posts at OpenId4java group where Ratapouak talked about having used this library inside a webapp using Struts fwk. But he also mentioned having used a singleton per classloader manager that handles ConsumerManager. I dont know what he did in there. 
--
Ankush Malhotra 

Johnny Bufu

unread,
Sep 25, 2008, 3:24:19 AM9/25/08
to openi...@googlegroups.com

On 25/09/08 12:11 AM, Ankush Malhotra wrote:
> Well this is the complete stack trace and nothing has been omitted. I
> initiated remote server debugging the control goes to line (it hits the
> following breakpoint)
> consumer = new ConsumerManager();
>
> From this line onwards it throws a ServletException. I also downloaded
> the code from server repository and set a break point at the very first
> line in the constructor of ConsumerManager.
>
> _httpClient = HttpClientFactory.getInstance(
> _maxRedirects, Boolean.FALSE, _socketTimeout,
> _connectTimeout,
> CookiePolicy.IGNORE_COOKIES);
>
> The runtime flow doesnt hit that breakpoint and throws the
> servletException even before this.


Then it's probably a deployment / configuration issue. Maybe check how
endorsed libraries are handled in tomcat6, though it's not obviously
related.


Johnny

ratapouak

unread,
Sep 26, 2008, 3:34:55 AM9/26/08
to OpenID4Java
Hello Ankush,

I saw your message yesterday so sorry for the late response. I join
Jonnhy on that, how can you be sure this is an openid4java error ?
I didn't do anything particular in my webapp, just made a singleton
adapter to encapsulate the ConsumerManager class. Then in my code, I
call Adapter.getInstance().method() that does some stuff and delegates
the business to the underlying ConsumerManager object instance.

I'm using it in Tomcat 5.5 and struts 1.2.9 but I don't see why this
may fail with higher versions.

Have you embedded commons-httpclient in your war ?

David
Reply all
Reply to author
Forward
0 new messages