I am using Ant to run my Java application. I have my main in Subscriber class which uses other libraries. So I wanted to run the Controller.Subscriber. But I get the following bug:
[java] Error: A JNI error has occurred, please check your installation and try again
[java] Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/paho/client/mqttv3/MqttCallback
[java] at java.lang.Class.getDeclaredMethods0(Native Method)
[java] at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
[java] at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
[java] at java.lang.Class.getMethod0(Class.java:3018)
[java] at java.lang.Class.getMethod(Class.java:1784)
[java] at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
[java] at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
[java] Caused by: java.lang.ClassNotFoundException: org.eclipse.paho.client.mqttv3.MqttCallback
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[java] ... 7 more
[java] Java Result: 1
My Ant file is the following:
<project default="run">
<target name="run">
<java classname="Controller.Subscriber" fork="true">
<classpath>
<pathelement path="target/classes"/>
</classpath>
</java>
</target>
</project>
The path to the Subscriber class: target/classes/Controller/Subscriber.class
What am I doing wrong? Do I have to first to create jar file from my class files to can run the java program or can I execute the class files? Or do I miss a parameter in my java command?
I also tried the following Ant file by giving explicit classpath:
<project default="run">
<target name="run">
<java classname="Controller.Subscriber" fork="true" classpath="classpath">
<classpath>
<pathelement path="target/classes"/>
</classpath>
</java>
</target>
<path id="classpath">
<fileset dir="target">
<include name="*.jar"/>
</fileset>
</target>
</project>
But I am getting the same error message.
I have found the solution to the problem: I have to use classpathref instead of classpath. For some reason classpath="classpath" does not read the id "classpath". But classpathref solved the problem.
Related
I am upgrading Apache CXF from 3.2.14 to 3.3.8 where I got stuck with the below exception while building wdsl client.
[echo] TOTAL_MIB_ISAM_3.1.0.7.txt
[java] Nov 19, 2020 4:26:42 PM org.apache.velocity.runtime.log.JdkLogChute log
[java] SEVERE: ResourceManager : unable to find resource 'org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm' in any resource loader.
[java]
[java] WSDLToJava Error: Could not find Velocity template file: org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm
[java]
[java] org.apache.cxf.tools.common.ToolException: Could not find Velocity template file: org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm
[java] at org.apache.cxf.tools.common.VelocityGenerator.doWrite(VelocityGenerator.java:101)
[java] at org.apache.cxf.tools.wsdlto.core.AbstractGenerator.doWrite(AbstractGenerator.java:54)
[java] at org.apache.cxf.tools.wsdlto.frontend.jaxws.generators.FaultGenerator.generate(FaultGenerator.java:133)
[java] at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:288)
[java] at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:156)
[java] at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:404)
[java] at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:105)
[java] at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
[java] at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
[java] at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:185)
[java] Caused by: org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm'
[java] at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:474)
[java] at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:352)
[java] at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1533)
[java] at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1514)
[java] at org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.java:299)
[java] at org.apache.velocity.app.Velocity.getTemplate(Velocity.java:358)
[java] at org.apache.cxf.tools.common.VelocityGenerator.doWrite(VelocityGenerator.java:98)
[java] ... 9 more
[INFO] ------------------------------------------------------------------------
Using the below task to generate WDSL client using WSDLToJava and specified all cxf related jar in its cxf.classpath. But still it couldn't find the resource in 'org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm'
cxf.xml
<java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true" failonerror="true">
<jvmarg value="-Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"/>
<jvmarg value="-Dorg.apache.cxf.stax.allowInsecureParser=true"/>
<arg line="${cxf_args}"/>
<classpath>
<path refid="cxf.classpath"/>
</classpath>
</java>
<path id="cxf.classpath">
<fileset file="${org.apache.cxf:cxf-common-schemas:jar}"/>
<fileset file="${org.apache.cxf:cxf-core:jar}"/>
<fileset file="${org.apache.cxf:cxf-rt-bindings-soap:jar}"/>
<fileset file="${org.apache.cxf:cxf-rt-bindings-xml:jar}"/>
<fileset file="${org.apache.cxf:cxf-rt-databinding-jaxb:jar}"/>
<fileset file="${org.apache.cxf:cxf-rt-frontend-jaxrs:jar}"/>
<fileset file="${org.apache.cxf:cxf-rt-frontend-jaxws:jar}"/>
<fileset file="${org.apache.cxf:cxf-rt-frontend-simple:jar}"/>
<fileset file="${org.apache.cxf:cxf-rt-rs-client:jar}"/>
<fileset file="${org.apache.cxf:cxf-rt-transports-http:jar}"/>
<fileset file="${org.apache.cxf:cxf-rt-transports-http-jetty:jar}"/>
<fileset file="${org.apache.cxf:cxf-rt-transports-local:jar}"/>
<fileset file="${org.apache.cxf:cxf-rt-ws-addr:jar}"/>
<fileset file="${org.apache.cxf:cxf-rt-wsdl:jar}"/>
<fileset file="${org.apache.cxf:cxf-rt-ws-policy:jar}"/>
<fileset file="${org.apache.cxf:cxf-tools-common:jar}"/>
<fileset file="${org.apache.cxf:cxf-tools-validator:jar}"/>
<fileset file="${org.apache.cxf:cxf-tools-wsdlto-core:jar}"/>
<fileset file="${org.apache.cxf:cxf-tools-wsdlto-databinding-jaxb:jar}"/>
<fileset file="${org.apache.cxf:cxf-tools-wsdlto-frontend-jaxws:jar}"/>
....
</path>
Do I need any other dependency to be added?
I had a similar issue when building my application, and eventually tracked it back to the cxf-tools-common jar. Starting in 3.3.4, the method doWrite in the VelocityGenerator class had two changes:
3.3.0
props.put("resource.loader", "class");
props.put("class.resource.loader.class", clzName);
3.3.4
props.put("resource.loaders", "class");
props.put("resource.loader.class.class", clzName);
In my application, if I revert the changes to this one file, my build will complete. This might be a bug with CXF.
Checked the same with the CXF team.
https://issues.apache.org/jira/browse/CXF-8390
Adding or Upgrading the velocity to the latest solved the issue.
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.2</version>
</dependency>
When I am trying to run my test case as Java Application, it executes successfully. But when I am running it through Ant, I am getting error that WebDriver class definition is not found. However, I have included the respective jar.
Please let me know where I am going wrong.
Below java file of test case resides in C:\Automation_Practice\DEPAutomation\src\workflows
package workflows;
import java.io.IOException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
public class UploadToken {
public static void main(String[] args) throws InterruptedException, IOException {
// Variable Declaration
WebDriver driver = new FirefoxDriver();
Actions action = new Actions(driver);
String baseUrl = "https://staging.maas360.com/emc/";
//String expectedTitle = "MaaS360";
//String actualTitle = "";
String uname = "3043275_sagrawal";
String password = "admin#123";
//Open Home Page
driver.manage().window().maximize();
driver.get(baseUrl);
//Login
driver.findElement(By.id("EMail")).sendKeys(uname);
driver.findElement(By.id("Password")).sendKeys(password);
driver.findElement(By.id("submit")).click();
//Go to Enrollments Page
Thread.sleep(5000);
WebElement deviceMenu = driver.findElement(By.xpath(".//*[#id='203']"));
WebElement enrollments = driver.findElement( By.xpath(".//[#id='766']"));
action.moveToElement(deviceMenu).perform();
Thread.sleep(5000);
enrollments.click();
//Go to Streamlined Enrollment page
Thread.sleep(10000);
driver.switchTo().frame(driver.findElement(By.id("Content")));
WebElement streamlineButton = driver.findElement(By.id("streamlinedEnrollButton"));
streamlineButton.click();
//Upload Token
Thread.sleep(10000);
driver.findElement(By.id("tokenNameInput")).sendKeys("Token 1");
WebElement browseButton = driver.findElement(By.xpath("//input[#id='fileInputTokenFile']"));
browseButton.click();
Thread.sleep(10000);
Runtime.getRuntime().exec("C:/Users/akhandelwal/Desktop/akash.exe");
Thread.sleep(5000);
driver.findElement(By.id("confirmFormSubmit")).click();
//Authenticate token upload
Thread.sleep(5000);
driver.findElement(By.id("passwordtext")).sendKeys(password);
driver.findElement(By.id("confirmPasswordFormSubmit")).click();
Thread.sleep(10000);
//Close Browser
driver.quit();
}
}
All the jars of selenium resides in C:\Automation_Practice\DEPAutomation\lib
Here is my build.xml file
<?xml version="1.0" encoding="UTF-8"?>
<project name="DEP" default="exec" basedir=".">
<!-- set global properties for this build -->
<property name="src" location="./src"/>
<property name="build.dir" location="${basedir}/build"/>
<property name="external.jars" value=".\lib"/>
<property name="TestOperation.dir" value="${external.jars}/TestOperation" />
<property name="test.dir" value="${src}/workflows"/>
<target name="setClasspath">
<path id="classpath_jars">
<pathelement path="${basedir}/"/>
<fileset dir="${external.jars}">
<include name="**/*.jar"/>
</fileset>
</path>
<pathconvert pathsep=";" property="test.classpath" refid="classpath_jars" />
</target>
<target name="clean">
<echo message="----------Delete the binary folder and create it again----------" />
<delete dir="${build.dir}"/>
<mkdir dir="${build.dir}"/>
</target>
<target name="compile" depends="clean,setClasspath">
<echo message="----------Compile the source files to ${build.dir}----------" />
<echo message="classpath:${test.classpath}"/>
<javac srcdir="${test.dir}" destdir="${build.dir}" debug="on" includeantruntime="false">
<classpath refid="classpath_jars"/>
</javac>
</target>
<target name="exec" depends="compile">
<jar destfile="${TestOperation.dir}/TestOperation.jar" basedir="${build.dir}">
<manifest >
<attribute name="Main-Class" value="workflows.UploadToken" />
</manifest>
</jar>
<java fork="true" jar="${TestOperation.dir}/TestOperation.jar" />
</target>
</project>
On running the Ant Build I am getting following error message:
Buildfile: C:\Automation_Practice\DEPAutomation\build.xml
clean:
[echo] ----------Delete the binary folder and create it again----------
[delete] Deleting directory C:\Automation_Practice\DEPAutomation\build
[mkdir] Created dir: C:\Automation_Practice\DEPAutomation\build
setClasspath:
compile:
[echo] ----------Compile the source files to C:\Automation_Practice\DEPAutomation\build----------
[echo] classpath:C:\Automation_Practice\DEPAutomation;C:\Automation_Practice\DEPAutomation\lib\TestOperation\TestOperation.jar;C:\Automation_Practice\DEPAutomation\lib\apache-mime4j-0.6.jar;C:\Automation_Practice\DEPAutomation\lib\bsh-1.3.0.jar;C:\Automation_Practice\DEPAutomation\lib\cglib-nodep-2.1_3.jar;C:\Automation_Practice\DEPAutomation\lib\commons-codec-1.10.jar;C:\Automation_Practice\DEPAutomation\lib\commons-collections-3.2.1.jar;C:\Automation_Practice\DEPAutomation\lib\commons-exec-1.3.jar;C:\Automation_Practice\DEPAutomation\lib\commons-io-2.4.jar;C:\Automation_Practice\DEPAutomation\lib\commons-lang3-3.4.jar;C:\Automation_Practice\DEPAutomation\lib\commons-logging-1.1.3.jar;C:\Automation_Practice\DEPAutomation\lib\cssparser-0.9.16.jar;C:\Automation_Practice\DEPAutomation\lib\gson-2.3.1.jar;C:\Automation_Practice\DEPAutomation\lib\guava-18.0.jar;C:\Automation_Practice\DEPAutomation\lib\hamcrest-core-1.3.jar;C:\Automation_Practice\DEPAutomation\lib\hamcrest-library-1.3.jar;C:\Automation_Practice\DEPAutomation\lib\htmlunit-2.17.jar;C:\Automation_Practice\DEPAutomation\lib\htmlunit-core-js-2.17.jar;C:\Automation_Practice\DEPAutomation\lib\httpclient-4.4.1.jar;C:\Automation_Practice\DEPAutomation\lib\httpcore-4.4.1.jar;C:\Automation_Practice\DEPAutomation\lib\httpmime-4.4.1.jar;C:\Automation_Practice\DEPAutomation\lib\jcommander-1.29.jar;C:\Automation_Practice\DEPAutomation\lib\jetty-io-9.2.11.v20150529.jar;C:\Automation_Practice\DEPAutomation\lib\jetty-util-9.2.11.v20150529.jar;C:\Automation_Practice\DEPAutomation\lib\jna-4.1.0.jar;C:\Automation_Practice\DEPAutomation\lib\jna-platform-4.1.0.jar;C:\Automation_Practice\DEPAutomation\lib\junit-dep-4.11.jar;C:\Automation_Practice\DEPAutomation\lib\nekohtml-1.9.22.jar;C:\Automation_Practice\DEPAutomation\lib\netty-3.5.7.Final.jar;C:\Automation_Practice\DEPAutomation\lib\phantomjsdriver-1.2.1.jar;C:\Automation_Practice\DEPAutomation\lib\sac-1.3.jar;C:\Automation_Practice\DEPAutomation\lib\selenium-java-2.46.0-srcs.jar;C:\Automation_Practice\DEPAutomation\lib\selenium-java-2.46.0.jar;C:\Automation_Practice\DEPAutomation\lib\serializer-2.7.2.jar;C:\Automation_Practice\DEPAutomation\lib\testng-6.8.5.jar;C:\Automation_Practice\DEPAutomation\lib\websocket-api-9.2.11.v20150529.jar;C:\Automation_Practice\DEPAutomation\lib\websocket-client-9.2.11.v20150529.jar;C:\Automation_Practice\DEPAutomation\lib\websocket-common-9.2.11.v20150529.jar;C:\Automation_Practice\DEPAutomation\lib\xalan-2.7.2.jar;C:\Automation_Practice\DEPAutomation\lib\xercesImpl-2.11.0.jar;C:\Automation_Practice\DEPAutomation\lib\xml-apis-1.4.01.jar
[javac] Compiling 3 source files to C:\Automation_Practice\DEPAutomation\build
exec:
[jar] Building jar: C:\Automation_Practice\DEPAutomation\lib\TestOperation\TestOperation.jar
[java] java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver
[java] at java.lang.Class.getDeclaredMethods0(Native Method)
[java] at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
[java] at java.lang.Class.privateGetMethodRecursive(Unknown Source)
[java] at java.lang.Class.getMethod0(Unknown Source)
[java] at java.lang.Class.getMethod(Unknown Source)
[java] at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
[java] at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
[java] Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WebDriver
[java] at java.net.URLClassLoader.findClass(Unknown Source)
[java] at java.lang.ClassLoader.loadClass(Unknown Source)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
[java] at java.lang.ClassLoader.loadClass(Unknown Source)
[java] ... 7 more
[java] Error: A JNI error has occurred, please check your installation and try again
[java] Exception in thread "main"
[java] Java Result: 1
BUILD SUCCESSFUL
Total time: 2 seconds
I'm working on an ANT script now for a web application(And I have very minimal knowledge in ant script and weblogic server administration).
When I execute the ant script , everything work fine except the script fail to precompile the jsps. PFB the ant script for jsp precompile
<!-- run jsp compile -->
<target name="jspc" unless="warBuild.notRequired" depends="compileAll">
<java classname="weblogic.jspc" fork="yes" failonerror="true">
<arg line="-compiler ${WL_COMPILER} -nowarn -compileAll -webapp ${build} -depend -d ${classes}"/>
<classpath>
<pathelement path="${app.classpath};${classes}"/>
</classpath>
</java>
</target>
And PFB the error log
jspc:
[java] java.lang.NullPointerException
[java] at weblogic.jsp.internal.java.JavaCompilationContext$JavacJavaCompilationContext.init(JavaCompilationContext.java:67)
[java] at weblogic.jsp.internal.CPL.createJavaCompilationContext(CPL.java:584)
[java] at weblogic.jsp.internal.CPL.setClassLoader(CPL.java:555)
[java] at weblogic.servlet.jsp.JspCLLManager.initCompilerOptions(JspCLLManager.java:396)
[java] at weblogic.servlet.jsp.JspCLLManager.initialize(JspCLLManager.java:235)
[java] at weblogic.servlet.jsp.JspCLLManager.(JspCLLManager.java:228)
[java] at weblogic.servlet.jsp.JspCLLManager.(JspCLLManager.java:221)
[java] at weblogic.servlet.jsp.JspCLLManager.compileJsps(JspCLLManager.java:126)
[java] at weblogic.servlet.jsp.jspc20.runBodyInternal(jspc20.java:456)
[java] at weblogic.servlet.jsp.jspc20.runBody(jspc20.java:265)
[java] at weblogic.utils.compiler.Tool.run(Tool.java:158)
[java] at weblogic.utils.compiler.Tool.run(Tool.java:115)
[java] at weblogic.jspc.main(jspc.java:22)
[java] Unexpected exception while compiling jsps :java.lang.NullPointerException
Any help will be appreciated .Thanks in advance
Got the solution .
The issue is because the jre version of weblogic and jre version used in the workspace(Eclipse) was different.As a result the compilation of jsps were failed.I have changed the recommended jre version, ie jre1.6 (for weblogic 10.3.5) and it worked fine.
Here's the error I keep getting at runtime:
[java] Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException
Note, this is a runtime error, not a compile-time one. Both tasks in my build.xml have an identical classpath set, and the compile task runs fine every single time:
<path id="classpath">
<fileset dir="lib" includes="*.jar" />
</path>
<target name="compile">
<mkdir dir="build/classes"/>
<javac
srcdir="src"
classpathref="classpath"
includeantruntime="false"
destdir="build/classes"
/>
</target>
...
<target name="run" depends="clean,compile,jar">
<java
jar="build/jar/${project.name}.jar"
fork="true"
classpathref="classpath"
>
<sysproperty key="java.library.path" path="${path.lib}/windows"/>
</java>
</target>
Trying to run the jar via command-line manually yields the same result:
java -cp .:lib/*.jar -Djava.library.path=lib/windows -jar build/jar/JUtopia.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException
Note that the library jarfile is ok:
bash-3.1$ jar -tf lib/lwjgl.jar | grep LWJGLException
org/lwjgl/LWJGLException.class
And the native libraries are in place:
bash-3.1$ ls lib/windows/lwjgl.dll
lib/windows/lwjgl.dll
The question: where the blazes have I gone wrong? I've been beating at this problem for nearly 3 days. Any help would be much appreciated.
Full result stack:
clean:
[delete] Deleting directory C:\Users\mkumpan\Projects\JUtopia\build
compile:
[mkdir] Created dir: C:\Users\mkumpan\Projects\JUtopia\build\classes
[javac] Compiling 12 source files to C:\Users\mkumpan\Projects\JUtopia\build\classes
jar:
[mkdir] Created dir: C:\Users\mkumpan\Projects\JUtopia\build\jar
[jar] Building jar: C:\Users\mkumpan\Projects\JUtopia\build\jar\JUtopia.jar
run:
[java] Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException
[java] at JUtopia.<init>(Unknown Source)
[java] at JUtopia.main(Unknown Source)
[java] Caused by: java.lang.ClassNotFoundException: org.lwjgl.LWJGLException
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[java] ... 2 more
P.S.: Note, I'm using Console2 with bash in a windows environment for my commandline work, thus the windows natives yet linux shell syntax. Using vanilla cmd to run the jar yields the same result.
-jar...
When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored. - reference
try setting the Class-Path in the JAR
Alternatively try running without the -Jar option, by specifying the main class on the command line
One of the possible causes is that while loading the class LWJGLException it also references another class which can't be found on the classpath. Hence the reported error is sometimes not clear.
Important here is thet you have this NoClassDefFoundError and not ClassNotFoundException which is the error you assume you are having: it cannot find the class LWHLException, yes it can ! But it cannot load it....
I have my application entities in a separate project from my main servlet, and they aren't being DataNucleus enhanced.
Not sure if I'm just breaking the rules or what, but setting the ORM setting on the project doesn't enhance my .class files. The way my workspace is built is by compiling the projects, then running an ant script builds jar files and copies them into the lib directory of my servlet.
I suppose that if I must, I can add some java tasks to my ant scripts to enhance my .class files. If that's the case, an example of the task would be helpful.
I do want to keep my projects are they are, let me know what I need to do to maintain that.
This is my build.xml of the project containing my entities:
<project default="default">
<property name="appengine.sdk.dir" location="C:\superlongpathtomyeclipseplugins\plugins\com.google.appengine.eclipse.sdkbundle_1.6.5\appengine-java-sdk-1.6.5"/>
<import file="${appengine.sdk.dir}/config/user/ant-macros.xml"/>
<target name="default" depends="dist"/>
<target name="dist">
<enhance>
<classpath>
<pathelement path="${appengine.sdk.home}/lib/*"/>
<pathelement path="bin"/>
</classpath>
<fileset dir="bin" includes="**/*.class" />
</enhance>
<jar basedir="bin" destfile="dist\sessionexample.model.jar"/>
</target>
</project>
But now here is the error I'm getting:
java.lang.RuntimeException: Unexpected exception
at com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:76)
at com.google.appengine.tools.enhancer.Enhance.(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(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:74)
... 2 more
Caused by: java.lang.NoClassDefFoundError: com/google/appengine/api/datastore/Key
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getDeclaredMethods(Unknown Source)
at org.datanucleus.metadata.annotations.AbstractAnnotationReader.getJavaBeanAccessorAnnotationsForClass(AbstractAnnotationReader.java:238)
at org.datanucleus.metadata.annotations.AbstractAnnotationReader.getMetaDataForClass(AbstractAnnotationReader.java:128)
at org.datanucleus.metadata.annotations.AnnotationManagerImpl.getMetaDataForClass(AnnotationManagerImpl.java:136)
at org.datanucleus.metadata.MetaDataManager.loadAnnotationsForClass(MetaDataManager.java:2278)
at org.datanucleus.metadata.MetaDataManager.loadClasses(MetaDataManager.java:385)
at org.datanucleus.enhancer.DataNucleusEnhancer.getFileMetadataForInput(DataNucleusEnhancer.java:743)
at org.datanucleus.enhancer.DataNucleusEnhancer.enhance(DataNucleusEnhancer.java:545)
at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1252)
... 7 more
Caused by: java.lang.ClassNotFoundException: com.google.appengine.api.datastore.Key
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.google.appengine.tools.enhancer.EnhancerLoader.loadClass(EnhancerLoader.java:107)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 18 more
Do I need to keep adding things to my <classpath> until it works?
The DataNucleus project defines many ways to run enhancement. It's for you to choose which one makes most sense to your environment and build system. Any other methods not defined on that page are not supported (by us)
Finally got an ant task to run:
<project default="default">
<property name="appengine.sdk.dir" location="c:\pathtoeclipse\eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.6.5\appengine-java-sdk-1.6.5"/>
<import file="${appengine.sdk.dir}/config/user/ant-macros.xml"/>
<target name="default" depends="dist"/>
<target name="dist">
<enhance>
<classpath>
<pathelement path="${appengine.sdk.home}/lib/*"/>
<pathelement path="${appengine.sdk.home}/lib/user/*"/>
<pathelement path="${appengine.sdk.home}/lib/user/orm/*"/>
<pathelement path="bin"/>
</classpath>
<fileset dir="bin" includes="**/*.class" />
</enhance>
<jar basedir="bin" destfile="dist\sessionexample.model.jar"/>
</target>
</project>