0

I set the default JRE to 1.5.0 in the 'Installed JREs" settings in preferences in Eclipse(STS 3.5) and ran a maven build with a profile (which includes the wsimport goal of the jaxws-maven-plugin). But immediately i get this exception.

Exception:

Exception in thread "main" java.lang.UnsupportedClassVersionError: (org/apache/maven/cli/MavenCli) bad major version at offset=6
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:267)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:600)
at java.net.URLClassLoader.access$400(URLClassLoader.java:124)
at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:1055)
at java.security.AccessController.doPrivileged(AccessController.java:274)
at java.net.URLClassLoader.findClass(URLClassLoader.java:492)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:389)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:242)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
at org.codehaus.plexus.classworlds.launcher.Launcher.getMainClass(Launcher.java:144)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:266)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:46)

POM.xml(a child POM):

<profile>
        <id>retrieve-generate-client</id>
        <build>
            <plugins>

                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>jaxws-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>generate-ordinaryws-client-code</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>wsimport</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <packageName>com.abc.service.retrievedocument</packageName>
                        <wsdlDirectory>${basedir}/src/wsdl</wsdlDirectory>
                        <wsdlFiles>
                            <wsdlFile>RetrieveDocument/Technology-RetrieveDocument.wsdl</wsdlFile>
                        </wsdlFiles>
                        <verbose>true</verbose>
                        <sourceDestDir>${project.build.directory}/wsjava/RetrieveDocument</sourceDestDir>

                    </configuration>

                </plugin>

But the maven version im using(3.2.1) says it supports java 1.5 and later. What am I missing here? I want to use the JDK 1.5 which i have to run the profile.

knk
  • 79
  • 1
  • 9
  • You are compiling with JDK 1.6 – Laurentiu L. Jul 31 '15 at 07:29
  • You should use an actuall jdk (version 7 or 8) – Jens Jul 31 '15 at 07:29
  • What is the configured Java version in your pom.xml? – Matthias J. Sax Jul 31 '15 at 07:30
  • No I purposefully want to run the profile using JDK 1.5 since its a constraint for generating the Web Service client code(production environment which is going to use this code is running at JDK 1.5) – knk Jul 31 '15 at 07:31
  • @MatthiasJ.Sax Its set at 1.7, but I have overridden that parent setting using the maven-compiler-plugin in that profile as you can see. Shouldnt that work? – knk Jul 31 '15 at 07:34
  • Is $JAVA_HOME configured correctly (ie, pointing to Java 1.5 installation)? – Matthias J. Sax Jul 31 '15 at 07:35
  • @Jens it's no duplicate. The question is more specific about maven configuration (the basic error that is discussed in the link you shared is understood and not the problem). – Matthias J. Sax Jul 31 '15 at 07:38
  • 1
    https://maven.apache.org/docs/history.html : Maven 3.2.1 - Required Java Version: Java 6 – user158037 Jul 31 '15 at 07:43
  • @MatthiasJ.Sax Im using maven through Eclipse( have changed the Maven > Installations setting to point to an external maven installation), so JAVA_HOME need not be set is my understanding. Am I correct? And moreover i was bale to run maven before with JDK 1.7 for the same POM. – knk Jul 31 '15 at 07:54
  • As @user158037 points out, your claim that maven 3.2.1 work with Java 5 is wrong. You need at least 6 -- and I would even recommend to use Java 8 (Support for older Java version ended already: http://www.oracle.com/technetwork/java/eol-135779.html). However, even if you use JDK 6 (or higher) to run maven, you can still compile your sources to a lower version (so your configuration of `source` and `target` in `maven-compiler-plugin` is ok). – Matthias J. Sax Jul 31 '15 at 08:00
  • @MatthiasJ.Sax Yes user158037 is right. I looked it up in maven website only later. Bad documentation on my company's IT inventory department' part :( Spent 2 hours trying to figure out what went wrong. And thanks for the suggestion about the build for lower versions of java :) I will do just that. – knk Aug 01 '15 at 02:59

0 Answers0