Getting HTTP 500 when starting a servlet in Jetty

I have a servlet that worked fine until a few days ago. But the only thing I changed is the nexus repo, which I use for maven. I run the servlet through mvn jetty: run

But when I try to access the site, and not see the home page, I see:

HTTP ERROR 500 Problem accessing /. Reason: jregex/Pattern 

I can access another url like /favicon.ico. But I cannot find anything in this jregex / Pattern error, and it does not look like the jregex library is used in the code at all.

I also do not see problems in the magazines. It seems that the requests for the home page do not get into my servlet, but the requests for other pages.

This happens on both Arch Linux and Mac OS X 10.7.

This is almost certainly a dependency problem, because after replacing my ~/.m2 with the old one (with dependencies on the old nexus server) it works.

Sometimes I also get:

 HTTP ERROR: 503 Problem accessing /. Reason: SERVICE_UNAVAILABLE 
+2
source share
4 answers

I would start by comparing the ear / war file created before and after modifying pom.xml . This should change the jar files. Learning everything - open source, downloading sources from maven repo and comparing them. \

Edit: JRegex is a Java library with Perge regexp support. Perhaps changing the maven repo caused other versions of your dependencies to load, and they have some additional JRegex dependency. (You should be able to verify this).

Try adding JRegex to your dependencies and see what happens. (Please note that this will be a workaround if you are in production and in a hurry)

+1
source

Jason is what works for me, this is what I use quite often, pom.xml (the corresponding part):

 <dependencies> <!-- Jetty dependencies --> <dependency> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-embedded</artifactId> <version>6.1.26</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>7.0.2.v20100331</version> <configuration> <webAppConfig> <contextPath>/jetty-example</contextPath> <descriptor>${basedir}/src/main/webapp/WEB-INF/web.xml</descriptor> </webAppConfig> <scanIntervalSeconds>5</scanIntervalSeconds> <stopPort>9966</stopPort> <stopKey>foo</stopKey> <connectors> <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector"> <port>9080</port> <maxIdleTime>60000</maxIdleTime> </connector> </connectors> </configuration> </plugin> </plugins> </build> 

Here is web.xml located at the above location in webappconfig as a handle:

 <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <display-name>HelloWorld Application</display-name> <description> lalala </description> <servlet> <servlet-name>HelloServlet</servlet-name> <servlet-class>com.mypackage.jetty.Hello</servlet-class> </servlet> <servlet-mapping> <servlet-name>HelloServlet</servlet-name> <url-pattern>/hello</url-pattern> </servlet-mapping> </web-app> 

And the servlet itself:

 public final class Hello extends HttpServlet { private static final long serialVersionUID = 903359962771189189L; public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter writer = response.getWriter(); writer.println("<html>"); writer.println("<head>"); writer.println("<title>Sample Application Servlet Page</title>"); writer.println("</head>"); writer.println("<body bgcolor=white>"); writer.println("<table border=\"0\" cellpadding=\"10\">"); writer.println("<tr>"); writer.println("<td>"); writer.println("</td>"); writer.println("<td>"); writer.println("<h1>W00w I totally work</h1>"); writer.println("</td>"); writer.println("</tr>"); writer.println("</table>"); writer.println("</body>"); writer.println("</html>"); } } 

You can start the server by running mvn jetty:run and checking it at http://localhost:9080/jetty-example/hello

In addition, you can add performance to the plug-in and start the jetty when you finish building your project. Without the need to manually mvn jetty:run every time.

 <executions> <execution> <id>start-jetty</id> <phase>pre-integration-test</phase> <goals> <goal>run</goal> </goals> <configuration> <daemon>true</daemon> </configuration> </execution> <execution> <id>stop-jetty</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> </executions> 

You can optionally add a berth configuration file, which I use for the database (for different environments). You would add the file location to webAppConfig your fit plugin as follows:

 <webAppConfig> <contextPath>/my-tool</contextPath> <descriptor>${basedir}/src/main/webapp/WEB-INF/jetty/web.xml </descriptor> <jettyEnvXml>${basedir}/src/main/webapp/WEB-INF/jetty/jetty-env.xml </jettyEnvXml> </webAppConfig> 

And an example of the contents of the jetty-env.xml file:

 <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd"[]> <Configure id="wac" class="org.eclipse.jetty.webapp.WebAppContext"> <!-- PRIMARY DATABASE --> <New id="devDS" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg>primaryDS</Arg> <Arg> <!-- ie Postgress --> <New class="org.postgresql.ds.PGSimpleDataSource"> <Set name="User">myuser</Set> <Set name="Password">password</Set> <Set name="DatabaseName">database</Set> <Set name="ServerName">database.stackoverflow.com</Set> <Set name="PortNumber">5432</Set> </New> </Arg> </New> <!-- BACKUP DATABASE <New id="devDS" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg>backupDS</Arg> <Arg> ..... </Arg> --> </Configure> 

You must be kind with this.

+2
source

What is the mvn command you're working with? Have you tried loading the artifact manually and running mvn on the local artifact?

At first I used mvn to load an artifact. This will confirm that all of your settings / permission settings are functional and appropriate. For this, you can use the Maven Dependency Plugin (v2.4) to download the dependency on the local file. See this post for more details.

Once you can make sure that you can download the artifact locally, try launching jetty: starting the local artifact. If this works, you know that you are having problems with your repo.

If this still does not work, you may have problems with the mirror settings or with the repo configuration. For example, if mvn needs a plugin or dependency that you do not have locally, it will look for a third-party repository. Your settings.xml file can reflect all this on a local nexus server that cannot be configured to boot from MvnCentral.

Make sure you have no problem loading dependencies / plugins. You can easily point to mvncentral from your .xml settings and generally bypass your nexus server.

0
source

FWIW. Can you compare files with a tool like BeyondCompare ( Scooter Software )

0
source

All Articles