I have jar archive build with Ant 1.9.1
When I launch class from it I get the following exception:
Caused by Java exception: java.lang.NoSuchMethodError: com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput.setChecked(Z)V
at com.blablabla.kats.drivers.CheckBox.check(CheckBox.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.blablabla.kats.utils.Operation.doInvoke(Operation.java:142)
at com.blablabla.kats.utils.Operation.invokeMethod(Operation.java:117)
at com.blablabla.kats.model.handles.ElementOperationHandle.invokeOn(ElementOperationHandle.java:33)
at com.blablabla.kats.model.statements.DirectAction.execute(DirectAction.java:45)
at com.blablabla.kats.model.StatementSequence.executeStatement(StatementSequence.java:74)
at com.blablabla.kats.model.StatementSequence.doExecute(StatementSequence.java:50)
at com.blablabla.kats.model.Procedure.call(Procedure.java:46)
at com.blablabla.kats.model.statements.Invocation.execute(Invocation.java:48)
at com.blablabla.kats.model.StatementSequence.executeStatement(StatementSequence.java:74)
at com.blablabla.kats.model.StatementSequence.doExecute(StatementSequence.java:50)
at com.blablabla.kats.model.TestCase.execute(TestCase.java:41)
at com.blablabla.kats.model.TestSuite.execute(TestSuite.java:45)
at com.blablabla.kats.model.TestProgram.execute(TestProgram.java:40)
at com.blablabla.kats.Main.main(Main.java:158)
When I compile "com.blablabla.kats.drivers.CheckBox" class by javac and replace corresponding file in jar all works fine.
I use htmlunit 2.12
java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
corresponding Ant task:
<path id="classpath.libraries">
<fileset dir="${basedir}/lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="compile">
<javac srcdir="${basedir}/src/java" destdir="classes" debug="true" source="1.5" target="1.5">
<classpath refid="classpath.libraries" />
</javac>
</target>
${basedir}/lib contains a lot of jars.
The main are
kats.jar - my project, containing com.blablabla.kats.drivers.CheckBox
htmlunit-2.12.jar - where com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput.setChecked(Z) is.
Why it can happen?
The only difference that i see is, you are using 1.5 in ant script where as looking at the java version you are using java6 to run it. I am not sure if this may make a big difference as it should be backward compatible, but still give it a try. Change this version to 1.6 in ant build.xml
I found out that I didn't delete old compiled class.
When I cleaned up compiled classes all worked fine.
Related
I am currently trying to compile an application in CruiseControl using ANT but get an UnsupportedClassVersionError. The setup is as follows:
Environment: Windows server 2012
IDE: Eclipse Luna running JDK 8
Build server: CruiseControl 2.4.1 running on JDK 6
Build tool: ANT
Compiler: JDK 8 update 102
JAXWS-RI: 2.2.10
CruiseControl is installed as a service and during startup JAVA_HOME is set to JDK 6 in a file called wrapper.conf. As target version is Java 8 another env variable is also set.
set.JAVA_HOME=C:/jdk1.6
set.JAVA_HOME_JDK8=C:/jdk1.8.0_102
In the ANT build scripts the javac task has fork set to true and specifies the path to the java executable like this:
<property name="javac.fork" value="yes"/>
<property environment="env"/>
<property name="javac.location" value="${env.JAVA_HOME_JDK8}\\bin\\javac.exe"/>
<javac includeantruntime="false" destdir="${builddir}" debug="true"
target="1.8" source="1.8" debuglevel="lines,vars,source"
fork="${javac.fork}" executable="${javac.location}">
The above setup works well but fails when I try to use JAXWS-RI to create artifacts. The specific error reported is:
java.lang.UnsupportedClassVersionError: com/company/area/thing/services/Service1 : Unsupported major.minor version 52.0
at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:539)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:384)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: C:\path\build.xml:133: The following error occurred while executing this line:
java.lang.UnsupportedClassVersionError: com/company/area/thing/services/Service1 : Unsupported major.minor version 52.0
at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:539)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:384)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382)
... 12 more
Caused by: java.lang.UnsupportedClassVersionError: com/company/area/thing/services/Service1 : Unsupported major.minor version 52.0
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1225)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382)
... 20 more
Caused by: java.lang.UnsupportedClassVersionError: com/company/area/thing/services/Service1 : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at com.sun.tools.ws.wscompile.WsgenOptions.getClass(WsgenOptions.java:305)
at com.sun.tools.ws.wscompile.WsgenOptions.validateEndpointClass(WsgenOptions.java:244)
at com.sun.tools.ws.wscompile.WsgenOptions.validate(WsgenOptions.java:235)
at com.sun.tools.ws.wscompile.WsgenTool.run(WsgenTool.java:131)
at com.sun.tools.ws.ant.WsGen2.runInVm(WsGen2.java:357)
at com.sun.tools.ws.ant.WsTask2.execute(WsTask2.java:423)
at com.sun.tools.ws.ant.WsGen2.execute(WsGen2.java:351)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
... 23 more
As far as I can see it is thrown because WSGEN uses JAVA_HOME (pointing to JDK 6) to find the Java executable subsequently used to generate stuff.
WSSGEN setup is:
<target name="wsgen-compile">
<mkdir dir="${builddir}"/>
<javac includeantruntime="false" destdir="${builddir}" debug="true" target="1.8" source="1.8" debuglevel="lines,vars,source" fork="${javac.fork}" executable="${javac.location}">
<src path="${src.tmp}" />
<classpath>
<pathelement path="${classpath}"/>
<pathelement path="${builddir}/../../common/bin"/>
<pathelement path="${builddir}/../../server/bin"/>
<fileset dir="${libdir}">
<include name="*.jar"/>
</fileset>
</classpath>
</javac>
</target>
<target name="wsgen-generate">
<taskdef name="wsgen" classname="com.sun.tools.ws.ant.WsGen2">
<classpath>
<fileset dir="${webserviceslibdir}/jax/jaxws-ri/lib">
<include name="*.jar"/>
</fileset>
</classpath>
</taskdef>
<wsgen verbose="true"
genwsdl="true"
xendorsed="false"
keep="true"
resourcedestdir="properties"
destdir="${src.tmp}"
sei="com.nordea.nordiccms.server.webservices.${service}">
<classpath>
<pathelement path="${classpath}"/>
<pathelement path="${builddir}/../../common/bin"/>
<pathelement path="${builddir}/../../server/bin"/>
<fileset dir="${libdir}">
<include name="*.jar"/>
</fileset>
</classpath>
<arg value="J.java_home"/>
</wsgen>
<delete>
<fileset dir="${src.tmp}">
<include name="**/*.class"/>
</fileset>
</delete>
</target>
<target name="wsgen" depends="compile">
<echo message=""/>
<echo message="Building ${distributionnameserver} WebService files"/>
<echo message="----------"/>
<mkdir dir="${builddir}/wsgen"/>
<delete dir="${src.tmp}"/>
<mkdir dir="${src.tmp}"/>
<ant target="wsgen-generate">
<property name="service" value="Service1"/>
</ant>
<ant target="wsgen-compile"/>
<delete dir="${src.tmp}"/>
</target>
I want to configure WSGEN to use JDK 8 instead of JDK 6 while compiling, but I have so far been unable to do so. Does anybody know how I might solve this problem? I should mention that upgrading CruiseControl to run on JDK8 is not an option at this point.
The error has the following...
Caused by: java.lang.UnsupportedClassVersionError: com/company/area/thing/services/Service1 : Unsupported major.minor version 52.0
/*snip*/
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at com.sun.tools.ws.wscompile.WsgenOptions.getClass(WsgenOptions.java:305)
The error is saying that the version of the Java Runtime (the JRE) running Ant is older than JRE version 52.0. JRE 52.0 is the major number for Java SE 8 (see How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version).
The JRE running Ant is trying to interact with the Java class com/company/area/thing/services/Service1. However, the Service1 class was compiled with Java 8. The older JRE running Ant doesn't know how to handle Java 8 classes, so the build fails.
Try running Ant with Java 8. Set JAVA_HOME to point to an installation of JDK 8.
Use the following build.xml script to verify the version of Java being used:
<project name="ant-jdk-version">
<echo>Java Version via Ant: ${ant.java.version}</echo>
<echo>Java Version System Prop: ${java.version}</echo>
</project>
The script should output something similar to...
[echo] Java Version via Ant: 1.8
[echo] Java Version System Prop: 1.8.0_60
Anybody knows about this kind of build failure on build.xml ?
build.xml is genereated automatically by Eclipse.
BUILD FAILED
E:\EclipseWorkspace\Launcher3\build.xml:48: Class not found: javac1.8
build.xml:48 is as following.
<javac debug="true" debuglevel="${debuglevel}" destdir="bin/classes" includeantruntime="false" source="${source}" target="${target}">
do you have a correctly installed and CONFIGURED jdk?
The message doesn't look so, as the compiler (javac) could not be found
I write a java package, and I want to compile it into .class files first and then package it. Following codes are what I do in my ant script. Under the directory of "src/compressScript" are four java class I wrote.
<?xml version="1.0" encoding="UTF-8" standalone="no"?><project basedir="."default="compileJava" name="compileJava">
<target name="compileJava">
<mkdir dir="buildTest"/>
<javac includeantruntime="false" srcdir="src/compressScript" destdir="buildTest"/>
</target>
</project>
When I try to use javac task of ANT to run this scirpt, the error is like this:
Buildfile: C:\Users\di_yu\workspace\AffirmedNetworks\buildTest.xml
compileJava:
BUILD FAILED
C:\Users\di_yu\workspace\AffirmedNetworks\buildTest.xml:6:java.lang.UnsupportedClassVersionError: com/sun/tools/javac/Main : Unsupported major.minor version 52.0
Total time: 545 milliseconds
I check my compiler, the installed JRE is JRE 7.0 and the compiler compliance level is 1.7. So what's the problem?
Folks, trying to automatically generate UML diagrams from code to speed up the discovery process. I've come across a project that does exactly what we need, http://www.umlgraph.org/doc/indexw.html
After the installation, I get the following:
umlgraph test png
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/umlgraph/doclet/UmlGraph : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: org.umlgraph.doclet.UmlGraph. Program will exit.
Java version on the system:
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.11.90) (rhel-1.62.1.11.11.90.el6_4-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
Can someone please point me in the correct direction? Does anyone use a similar project? Thanks!
It looks like umlgraph 5.6_6.1-SNAPSHOT was compiled for Java 7 only. Here's a snapshot from it's build.xml:
<javac srcdir="${src}" destdir="${build}" debug="true" deprecation="true" >
<compilerarg value="-Xlint"/>
</javac>
No "target" attribute set explicitly, so platform java version is used. And from JAR manifest it's obvoius, that it was compiled on java 1.7
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.7.0_21-b11 (Oracle Corporation)
So you can either install Java 7 to run umlgraph, or use the older version of ulmgraph, which was compiled to be compartible with Java 6.
I use ant to build my GAE WebApp. This is the datanucleus target:
<target name="datanucleusenhance" depends="compile"
description="Performs enhancement on compiled data classes.">
<enhance_war war="war">
</enhance_war>
</target>
This is the error I got:
org.datanucleus.exceptions.NucleusException: Plugin (Bundle) "org.datanucleus" is already registered. Ensure you dont have multiple JAR versions of the same plugin in the classpath. The URL
"file:/home/xxxx/.eclipse/org.eclipse.platform_4.2.0_1473617060/plugins/com.google.appengine.eclipse.sdkbundle_1.7.2/appengine-java-sdk-1.7.2/lib/opt/tools/datanucleus/v1/datanucleus-core-1.1.5.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/war/WEB-INF/lib/datanucleus-core-3.1.0-m5.jar."
I've tried this ant target:
<target name="datanucleusenhance" depends="compile" description="Performs enhancement on compiled data classes.">
<enhance_war war="war">
<args>
<arg value="-enhancerVersion" />
<arg value="v3.1.0" />
</args>
</enhance_war>
</target>
I've tried to delete "datanucleus-core-1.1.5.jar". The error then is:
java.lang.RuntimeException: Unexpected exception
at com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:76)
at com.google.appengine.tools.enhancer.Enhance.<init>(Enhance.java:71)
at com.google.appengine.tools.enhancer.Enhance.main(Enhance.java:51)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:74)
... 2 more
Caused by: java.lang.NoClassDefFoundError: org/datanucleus/OMFContext
at org.datanucleus.enhancer.DataNucleusEnhancer.<init>(DataNucleusEnhancer.java:172)
at org.datanucleus.enhancer.DataNucleusEnhancer.<init>(DataNucleusEnhancer.java:150)
at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1157)
... 7 more
Caused by: java.lang.ClassNotFoundException: org.datanucleus.OMFContext
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at com.google.appengine.tools.enhancer.EnhancerLoader.loadClass(EnhancerLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 10 more
How can I use JDO3.0 with GAE1.7.2?
Using the GAE plugin for Intellij, I had to remove the default configured orm directory, and specifically add the higher version libraries.
The GAE SDK is organized as such:
/lib/user/orm (default persistence libraries I removed)
AND
/lib/opt/user/datanucleus/v2
To access this configuration in IntelliJ, from the context menu for my project:
{context menu} -> Open Module Settings -> Libraries -> AppEngine ORM
Use the [-] button to remove the jars within this directory: /lib/user/orm
Use the [+] button to add the jars within this directory: /lib/opt/user/datanucleus/v2
Got the answer. The correct ant target should be:
<target name="datanucleusenhance" depends="compile" description="Performs enhancement on compiled data classes.">
<enhance_war war="war">
<args>
<arg value="-enhancerVersion" />
<arg value="v2" />
</args>
</enhance_war>
</target>
the version is the GAE JDO/JPA plugin version.(Thanks DataNucleus!:)
You seem to be confusing which versions of dependent jars to use. GAE 1.7.2 uses GAE JDO/JPA plugin v2.x, which in turn needs DataNucleus 3.x. You evidently have (various) DataNucleus 1.x jars present.