ENV: Amazon Linux with Tomcat6 on EC2.

I create a simple dynamic web project with an index.jsp on Eclipse, load it to cloud and it shows up correctly. But once I create a servlet and do the same process, the page says service not available and gives error code 503.

I have tried to remove the servlet tags in web.xml, then it works again.

Just to clarify, I have two existing dynamic web projects that I'd like to have deployed on cloud. Both are running fine on local Tomcat6.

edit: enter image description here

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>Test</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
  <servlet>
    <description></description>
    <display-name>Se</display-name>
    <servlet-name>Se</servlet-name>
    <servlet-class>Servlet.Se</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>Se</servlet-name>
    <url-pattern>/Se</url-pattern>
  </servlet-mapping>
</web-app>

Above is my web.xml, if I remove servlet,servlet-mapping blocks, it works again.

有帮助吗?

解决方案

The UnsupportedClassVersionError usually happens because you are using a newer JDK version for compiling than the version used at runtime. Try compiling with the same JDK version used by Tomcat.

其他提示

SEVERE: Error deploying web application archive Test.war java.lang.UnsupportedClassVersionError: Servlet/Se : Unsupported major.minor version 51.0 (unable to load class Servlet.Se)

This type of error occurs when you have compiled your running your application on a different version of JRE than it was originally intended for or compiled on.

51.0 means that it is expecting JRE version 7 and (it is most probable that) you must be running it on JRE 6 on your ec2 server. First determine what is the version of the JRE on your ec2 server with the command

$ java -version

and make sure that is matches the one with on which the code was initially compiled on. It is most probable that you compiled your code on JRE7 and on ec2 server, JRE6 is configured and you might want to upgrade it on ec2 server, or downgrade on your machine.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top