dimanche 24 mai 2015

Error 500 when accessing jsp resource using maven unit test

I get 500 error when trying to access a jsp through unit tests, the unit test is working perfectly fine in eclipse, however, it errors out with 500 code when ran through maven.

I used:

mvn clean package -> which runs all the unit tests

Sample code:

    // Starting a jetty server
    jettyServer.start();
    ....
    // URL to the page the test wanted to validate
    URL url = new URL(getUrl() + "/Stats.jsp");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();

    try {
       conn.setRequestMethod("GET");
       conn.setRequestProperty("Accept", "text/xml");
    ....
    // FAILING HERE WITH 500
    assertEquals("Didn't get a succesful http response, output: " + conn.getResponseMessage(), 200, conn.getResponseCode());

The jsp is located under: src/main/resources/jsp

I tried to add mvn dependencies for all the jetty-related jar files that are under "Reference Libraries", and they are now under "Maven Dependencies" as well, but, that doesn't seem to help much.

Later in the logs I see some interesting warning not sure if it's related or not:

2015-05-24 14:35:08,362 WARN  [qtp82416174-739] servlet.ServletHandler(620):
javax.servlet.ServletException: java.lang.NoSuchMethodError: org.apache.jasper.compiler.JspUtil.expandClassPath(Ljava/util/List;)Ljava/util/List;
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:400)
at org.eclipse.jetty.jsp.JettyJspServlet.service(JettyJspServlet.java:103)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:497)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchMethodError: org.apache.jasper.compiler.JspUtil.expandClassPath(Ljava/util/List;)Ljava/util/List;
at org.apache.jasper.compiler.Jsr199JavaCompiler.setClassPath(Jsr199JavaCompiler.java:123)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:348)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:437)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:608)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:360)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:486)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:380)

Any idea what could be wrong? did i miss anything with the jsp setup or is there anything special needs to happen in mvn configurations to let jetty server able to serve the jsp?

Thanks for your help!

Aucun commentaire:

Enregistrer un commentaire