Touchkit w/ JEE6 Support - Application not specified in servlet parameters

Hello!

I would like to integrate a Touchkit application with JEE/EJB support.

I have this working with a standard Vaadin project by extending the application servlet and injecting an instance of the application (and using the @SessionScoped notation on the application class itself). I am also adding application authentication via a redirect to a login screen (as described in the wiki: https://vaadin.com/wiki/-/wiki/Main/Creating%20Secure%20Vaadin%20Applications%20using%20JEE6)

For the TouchKit application, I followed the above approach but extended the TouchKitApplicationServlet as such:


import java.security.Principal;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;

import com.vaadin.Application;
import com.vaadin.addon.touchkit.server.TouchKitApplicationServlet;


@SuppressWarnings("serial")
@WebServlet(urlPatterns={"/ui/*", "/VAADIN/*"})
public class GoogleApiTestApplicationServlet extends TouchKitApplicationServlet {
	
	
	@Inject
	Instance<GoogleApiTestApplication> application;
		
	@Override
	protected Class<? extends Application> getApplicationClass()
			throws ClassNotFoundException {
	 return GoogleApiTestApplication.class;
	}

	@Override
	protected Application getNewApplication(HttpServletRequest request)
			throws ServletException {
		
		
		GoogleApiTestApplication app = application.get();
		Principal principal = request.getUserPrincipal();
		if (principal == null) {
			throw new ServletException("Access denied");
		}
		
		app.setUser(principal);
		app.setLogoutURL(request.getContextPath() + "/logout.jsp");
		return app;
	}
	

}

After the authentication proceeds, I am getting an “Application not specified in servlet parameters” error from Glassfish:

[#|2011-12-06T16:11:51.836-0500|WARNING|glassfish3.1.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=18;_ThreadName=Thread-2;|StandardWrapperValve[com.xpodigital.GoogleApiTestApplicationServlet]
: PWC1382: Allocate exception for servlet com.xpodigital.GoogleApiTestApplicationServlet
javax.servlet.ServletException: Application not specified in servlet parameters
at com.vaadin.terminal.gwt.server.ApplicationServlet.init(ApplicationServlet.java:63)
at com.vaadin.addon.touchkit.server.TouchKitApplicationServlet.init(TouchKitApplicationServlet.java:26

After getting the Glassfish error page, if I then refresh the page, I do in fact get the touchkit application.

In the process of troubleshooting the issue, I added the following to my servlet code:

@Override
public void init(ServletConfig servletConfig) throws ServletException {
    super.init(servletConfig);
}

…and at first it seemed that the error stopped being thrown when using the iPhone – however, as I added more code to my application it came back (or is this just a coincidence?!) Nevertheless, when testing from within Eclipse (with the built in browser), I would consistently get the error.

Unfortunately, I don’t really know what I’m doing here, so I’m not sure what the above init method is doing (it is not necessary in my standard Vaadin application). Does anyone know of the proper way to extend the TouchKitApplicationServlet so as to be able to inject the application and utilize EJBs?

BTW, I have set this up as a standard Vaadin application (rather than a Maven project).

Thanks kindly!
Josh

Just a bit more of clarification on this issue:

The “Application not specified” error is thrown only after the initial login (the web.xml file points to a login.jsp file to handle user authentication). After the login is successful, the error is thrown. Hitting “refresh” then brings up the touchkit application. If the browser is then refreshed with the ?restartApplication parameter appended to the url, the application loads without issue. To get the problem to occur again, the session needs to time out. Of course, if the application is redeployed the issue pops up again, as a re-authentication will be necessary.

Josh

I ended up purchasing Vaadin support to resolve this issue.

Here’s what team member Johannes Häyry came up with as the solution:

*Note that the application class differs from what was in my previous post (I ended up sending a more simplified application)

BTW, the Vaadin support experience was excellent. Johannes not only solved the issue, but did so very quickly. I definitely found the support service to be worth the money.