0

I'm working on a java module using maven to build, all of my code builds successfully on main/java, but when I try to start creating the tests and I instantiate a class from the test/java folder the build fails with the following error:

java.lang.UnsupportedClassVersionError: javax/servlet/jsp/tagext/TryCatchFinally : Unsupported major.minor version 51.0

I'm using intelliJ in a mac, and when I check my (only) java version installed I get this:

java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

Same for javac.

I've tried the following:

  • Invalidate Cache and restart IntelliJ
  • Check the java compiler settings on IntelliJ (everything is set to 1.6)
  • Delete the javax folder on my .m2 directory so maven downloads it again
  • Double checked the versions on my pom

I can't build with java 7 because then it will break a huge deal of code because Im working on a module that will interact with a java 6 built project.

It makes no sense to me because this happens only when the code is in a jUnit test case, otherwise it works!

Your help is very appreciated, thanks.

EDIT: This is not a duplicate question... because none of the existing questions talks about the version of the TryCatchFinally version. Some people are just trying to earn badges or something...

RicardoE
  • 1,665
  • 6
  • 24
  • 42
  • Why do you think building with Java 7 means you can't work with Java 6 output? – Kevin Workman Jul 23 '14 at 14:01
  • Im afraid I will get the same error I'm getting with javax.servlet package here... it was built with java 7, and Im with java 6, and its driving me crazy... – RicardoE Jul 23 '14 at 14:03
  • Why would you get the same error? Your error is telling you that you're trying to run NEW code with an OLD version of Java. Running OLD code with a NEW version of Java is fine. – Kevin Workman Jul 23 '14 at 14:05
  • the thing is that this old code compiled with a new version will run in an old version, so at the long road it will be new code running in an old version of java... – RicardoE Jul 23 '14 at 14:09
  • If you search with `javax.servlet.jsp.tagext.TryCatchFinally` in maven or via findjar.com, you'll find maven dependencies. Do not forget `provided`. Or look in your local .m2/repository for the used dependency. – Joop Eggen Jul 23 '14 at 14:11

1 Answers1

3

This error means that the javax.servlet.jsp.tagext.TryCatchFinally class that you have in dependencies has been compiled with Java 7 while you're only on 6.

I suspect the reason is that your servlet, JSP or taglib dependency is on a version built for Java 7 and you'd have to downgrade it.

What dependencies do you have in there?

EDIT: It looks like JSP 2.3 is part of Java EE 7: http://en.wikipedia.org/wiki/Java_EE_version_history. I think you're out of luck here and the only options are using Java EE 6 (downgrading the JSP dependency to 2.1 or 2.2) or upgrading to Java 7.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Konrad Garus
  • 53,145
  • 43
  • 157
  • 230
  • how can I get a java 6 built version of the package with maven? – RicardoE Jul 23 '14 at 14:01
  • I have 2 dependencies: spring-webmcv 4.0.4.RELEASE, and javax.servlet.jsp-api 2.3.1, I can't change the javax version because its in a parent pom which is used by more packages (a lot more). – RicardoE Jul 23 '14 at 14:08
  • 1
    It looks like JSP 2.3 is only part of Java EE 7. – Konrad Garus Jul 23 '14 at 14:13
  • 1
    I downgraded my artifact to version 2.2.1-b03, and I finally got BUILD SUCCESS! thanks for the clues bro! your rock :) – RicardoE Jul 23 '14 at 14:25