Liesbeth
Liesbeth

Reputation: 13

Tomcat can't compile class when using selenium

I'm running Debian Jessie on my laptop. There is a Tomcat8 server installed. That seems to work fine when running a simple web application. But after adding selenium (selenium-server-standalone-2.45.0.jar) I get

HTTP Status 500 - Unable to compile class for JSP:   type Exception report

message Unable to compile class for JSP:

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: [31] in the generated java file: [<path>]
The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory

The jar is added by putting it in WEB-INF/lib in eclipse or in netbeans by right clicking Library > Add library When the selenium jar is removed, everything works fine. When I run the project on the installed tomcat it fails. When I run the project with a tomcat server in netbeans it fails. When the same project exported from my computer and imported on a friends computer who is running windows, it works just fine.

Does somebody knows what I'm doing wrong? Thanks!

Upvotes: 1

Views: 363

Answers (1)

piet.t
piet.t

Reputation: 11911

The problem is that the selenium-server-jar is intended to be run as a standalone application. Because of that it contains its own servlet-container.

When you try to run it within another servlet-container (your tomcat) the tomcat-runtime tries to compile a jsp but for this webapplication the selenium-jar seems to be put on the classpath before tomcat's own jars. As there also seems to be a version-mismatch between the jasper-versions of tomcat and selenium this is bound to cause trouble:tomcat uses servlet-version 3.1 and expects a method getJspApplicationContext(ServletContext) in class javax.servlet.jsp.JspFactory (which was added with servlet-spec 2.1). But this class seems to be loaded from the selenium-jar and that contains an older jasper-version that is still missing this method (it seems to support only servlet-version 2.0).

tl;dr: Don't use the selenium-server-jar within a servlet-container.

Upvotes: 1

Related Questions