- Changing the return type from application/json to text/plain solved one issue.
--------------
- Now there is AbstractMethodError. This is caused by the inclusion of both cxf and jersey libraries in the classpath.
- http://web.archiveorange.com/archive/v/ACbGtNIkWRe4LYpKxHnE
java.lang.AbstractMethodError: org.apache.cxf.jaxrs.provider.XMLBeansElementProvider.isWriteable(Ljava/lang/Class;Ljava/lang/reflect/Type;[Ljava/lang/annotation/Annotation;Ljavax/ws/rs/core/MediaType;)Z
- Removing cxf (even the one that has been renamed as z-cxf, solved the issue)works with both application/json and also plain text return.
- Now added cxf again by renaming it to z-cxf.
----------------
- But still the error is there for application/json return data
27 Nov 2010 22:30:25 PST ERROR [/].[RESTful Web Services] -- Servlet.service() for servlet RESTful Web Services threw exception
java.lang.AbstractMethodError
at com.sun.jersey.core.spi.factory.MessageBodyFactory._getMessageBodyReader(MessageBodyFactory.java:268)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.getMessageBodyReader(MessageBodyFactory.java:256)
at com.sun.jersey.spi.container.ContainerRequest.getEntity(ContainerRequest.java:425)
at
Also the following.....
01 Dec 2010 05:03:43 PST ERROR [/].[RESTful Web Services] -- Servlet.service() for servlet RESTful Web Services threw exception
java.lang.AbstractMethodError: org.apache.cxf.jaxrs.provider.XMLBeansElementProvider.isWriteable(Ljava/lang/Class;Ljava/lang/reflect/Type;[Ljava/lang/annotation/Annotation;Ljavax/ws/rs/core/MediaType;)Z
at
This is fixed by including the following in web.xml (Note: remove extra space after <):
<>
<>RESTful Web Services
<>com.sun.jersey.spi.container.servlet.ServletContainer
<>
<>com.sun.jersey.config.property.resourceConfigClass
<>com.sun.jersey.api.core.PackagesResourceConfig
< /init-param>
<>
<>com.sun.jersey.config.property.packages
<>com.punya.ws.resources
< /init-param>
< /servlet>
-------------------
Other useful articles read while dedugging thi issue:
- Now as per the comments at http://web.archiveorange.com/archive/v/ACbGtNIkWRe4LYpKxHnE
added the following to web.xml:
But the resources and providers is just an example....so it failed. Doing it again now....but no luck
- http://jersey.576304.n2.nabble.com/Using-Jersey-1-x-for-JAX-RS-along-CXF-2-1-x-for-JAX-WS-td2490569.html
The issue is that CXF also contains an implementation of JAX-RS.
You need to ensure if you want to use Jersey that Jersey's
RuntimeDelegate is chosen (as described in the email), or iyou might
be able to place jersey jars before CXF jars in the class path.
- THe following article says to register with RunTImeDelegateImpl to solve the problem:
http://markmail.org/search/?q=list%3Anet.java.dev.jersey.users+AbstractMethodError#query:list%3Anet.java.dev.jersey.users%20AbstractMethodError+page:1+mid:x3y2gjfywvtscmzd+state:results
- Try this later http://blogs.sun.com/japod/entry/building_simple_jersey_web_app
Added the following to web.xml
com.sun.jersey.config.property.resourceConfigClass
com.sun.jersey.api.core.PackagesResourceConfig
com.sun.jersey.config.property.packages
com.example.my
Hurray, adding the above to web.xml worked fine...but still without cxf library. Now trying with cxf....----------
http://jersey.576304.n2.nabble.com/AbstractMethodError-on-requesting-resource-td2307443.html
I assumed the CXF version is getting loaded first because it appears
first in the classpath and therefore the ServiceLoader listing (or
something similar), so I renamed 'cxf-2.1.4.jar' to 'z-cxf-2.1.4.jar'.
It actually worked!
It looks like I can fart around with providing the correct
javax.ws.rs.ext.RuntimeDelegate implementation with a properties file
somewhere or other ($java.home/lib -- really? ugh), so I'll try that.
But I wanted to post this so nobody wasted time on my earlier message......
........
Another approach might be to register the Jersey
RuntimeDelegateImpl in that listener explicitly:
RuntimeDelegate.setInstance(new
com.sun.jersey.server.impl.provider.RuntimeDelegateImpl());
You could do this using your own servlet context listener. Or override
the:
com.sun.jersey.spi.container.servlet.ServlerContainer
and in the constructor set the runtime delegate instance.
Would it be possible to try the above? if it works we could support a
special feature, as an init-param, to explicitly set the runtime
delegate. ............
-------------
I am still seeing the error
ReplyDeletejava.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.build([Ljava/lang/Object;)Ljava/net/URI;
at com.strandgenomics.solutions.percy.pfizerkb.EntityDirectoryAccessor.getBaseURI(EntityDirectoryAccessor.java:64)
at com.strandgenomics.solutions.percy.pfizerkb.EntityDirectoryAccessor.(EntityDirectoryAccessor.java:28)
at com.strandgenomics.solutions.percy.pfizerkb.EntityDirectoryAccessor.getInstance(EntityDirectoryAccessor.java:36)
at com.strandgenomics.solutions.percy.pfizerkb.EntityDirectoryAccessorTest.setUp(EntityDirectoryAccessorTest.java:13)
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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:44)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
I am using com.sun.jersey.spi.spring.container.servlet.SpringServlet instead of native jersey servlet.
When I am trying to build my client request I get this message.
On client and server I rename by cxf lib to z-cxf, but didn't help. Do you have any suggestions?
Can you try deleting the cxf jar file and see if it works?
ReplyDeleteIf not, may be some other library has UriBuilder.