maven开发Compilation error org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException

在做maven项目时出现了一个问题。
开发环境:maven3.39,sts开发工具,jdk1.8.0.44版本,ssh框架整合。
问题:
tomcat(tomcat:run)插件启动正常,但是访问时控制台出现了以下异常:

1.严重: Compilation error
    org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException
2.An error occurred at line: 1 in the generated java file
    The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files
    Stacktrace:at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)

页面上报http 500-,抛出以下异常:

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

An error occurred at line: 1 in the generated java file
The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files

同一路径刷新了几次,发现又多了提示,具体如下:

1.root cause
org.apache.jasper.JasperException: Unable to load class for JSP

2.root cause
java.lang.ClassNotFoundException: org.apache.jsp.index_jsp

解决:
在网上查了一下maven的官方:maven发布的历史版本,发现3.3.9版本需要的java环境是1.7的,然后我把环境调到jdk1.7,发现可以正常运行。(难道和jdk版本有关)

但是:我在网上看到别人的解决方法,然后按照他们的做法试了一遍,发现也是可以的,即把pom文件添加tomcat7插件:

  <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.2</version>
        <configuration>
            <port>8080</port>
            <uriEncoding>UTF-8</uriEncoding>
        </configuration>
  </plugin>

然后运行,大写的注意:此时输入tomcat7:run,然后发现程序仍然可以正常运行。

两套组合(我的问题都可以解决):
1.使用maven默认插件tomcat6,jdk版本jdk1.7,命令: tomcat:run
2.不使用maven默认插件,而是使用tomcat7插件,此时 jdk1.8 和1.7都可以使用,但命令需要输入: tomcat7:run

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值