Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring Jetty JSP support in embedded mode in Maven project

Tags:

I can visit .html pages with Jetty, but when I visit a .jsp page I get:

0 13:21:13 / [INFO] No JSP support. Check that JSP jars are in lib/jsp and that the JSP option has been specified to start.jar

I added the following as dependencies:

<dependency>   <groupId>org.eclipse.jetty</groupId>   <artifactId>jetty-webapp</artifactId>   <version>8.0.0.M1</version> </dependency> <dependency>   <groupId>javax.servlet.jsp</groupId>   <artifactId>jsp-api</artifactId>   <version>2.1</version> </dependency> 

Does that fulfill the "check that JSP jars are in lib/jsp" part of the error message?

Also, I have no idea what "check that the JSP option has been specified to start.jar" means in this context. I have the following:

  public static void main(String[] args) throws Exception {     Server server = new Server();      SelectChannelConnector connector = new SelectChannelConnector();     connector.setPort(8080);     server.addConnector(connector);      WebAppContext webApp = new WebAppContext();     webApp.setContextPath("/");     webApp.setWar("src/main/webapp");     server.setHandler(webApp);     server.start();     server.join();   } 
like image 717
Ben McCann Avatar asked Nov 20 '10 21:11

Ben McCann


2 Answers

I got it to work by adding the Mortbay JSP dependency (this is in Gradle notation, but you get the idea):

compile 'org.eclipse.jetty:jetty-io:8.0.0.M3' compile 'org.eclipse.jetty:jetty-server:8.0.0.M3' compile 'org.eclipse.jetty:jetty-servlet:8.0.0.M3' compile 'org.eclipse.jetty:jetty-util:8.0.0.M3' compile 'org.eclipse.jetty:jetty-webapp:8.0.0.M3' compile 'org.mortbay.jetty:jsp-2.1-glassfish:2.1.v20100127' 

There's a larger writeup available on my blog.

like image 116
Ben McCann Avatar answered Sep 28 '22 00:09

Ben McCann


I have done it without using the jars from the Jetty distribution, using only Maven dependencies:

<properties>     <jetty.version>8.1.0.RC0</jetty.version>     <glassfish.javax.version>2.2.3</glassfish.javax.version>     <glassfish.javax-impl.version>2.2</glassfish.javax-impl.version>     <glassfish.jstl.version>1.2</glassfish.jstl.version> </properties>  <dependencies>     <!-- Jetty Webapp-->     <dependency>         <groupId>org.eclipse.jetty</groupId>         <artifactId>jetty-webapp</artifactId>         <version>${jetty.version}</version>     </dependency>      <!-- JSP Support -->     <dependency>         <groupId>org.glassfish.web</groupId>         <artifactId>javax.servlet.jsp</artifactId>         <version>${glassfish.javax.version}</version>     </dependency>      <dependency>         <groupId>org.glassfish.web</groupId>         <artifactId>jsp-impl</artifactId>         <version>${glassfish.javax-impl.version}</version>     </dependency>      <!-- EL Support -->     <dependency>         <groupId>org.glassfish.web</groupId>         <artifactId>javax.el</artifactId>         <version>${glassfish.javax.version}</version>     </dependency>      <dependency>         <groupId>org.glassfish.web</groupId>         <artifactId>el-impl</artifactId>         <version>${glassfish.javax-impl.version}</version>     </dependency>      <!-- JSTL Support -->     <dependency>         <groupId>javax.servlet</groupId>         <artifactId>jstl</artifactId>         <version>${glassfish.jstl.version}</version>     </dependency>      <dependency>         <groupId>org.glassfish.web</groupId>         <artifactId>jstl-impl</artifactId>         <version>${glassfish.jstl.version}</version>     </dependency> </dependencies> 
like image 34
Simon Huet Avatar answered Sep 27 '22 22:09

Simon Huet