We use Jersey all the time in web apps and standalone java apps, and I
thought it should be easy to use it in a custom ant task. However, I've
had nothing but problems so far...
I've tried the latest 1.0.x and 1.1.x releases without success.
I've got jersey-bundle, jersey-apache-client and commons-httpclient-3.1
(plus other deps) on the path (verified with ant in verbose mode) and
get this error:
BUILD FAILED
java.lang.ExceptionInInitializerError
at com.acadiasoft.ant.task.http.HttpTask.doGet(HttpTask.java:50)
at com.acadiasoft.ant.task.http.HttpTask.execute(HttpTask.java:31)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.Main.runBuild(Main.java:758)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException:
com.sun.ws.rs.ext.RuntimeDelegateImpl
at
javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:112)
at javax.ws.rs.core.MediaType.<clinit>(MediaType.java:44)
... 18 more
Caused by: java.lang.ClassNotFoundException:
com.sun.ws.rs.ext.RuntimeDelegateImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at javax.ws.rs.ext.FactoryFinder.newInstance(FactoryFinder.java:44)
at javax.ws.rs.ext.FactoryFinder.find(FactoryFinder.java:141)
at
javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:95)
... 19 more
Total time: 1 second
If I run the same code through a unit test (invoked from eclipse), with
the same classpath as ant is using, it works fine...
Is there something I'm missing... why should it matter that its running
as a custom ant taskdef?