hstaudacher / osgi-jax-rs-connector

An OSGi - JAX-RS 2.0 Connector, software repository available on the link below
http://hstaudacher.github.io/osgi-jax-rs-connector
Other
190 stars 98 forks source link

ClassNotFoundException when using MOXyJsonProviderService message reader #90

Closed thugcee closed 9 years ago

thugcee commented 9 years ago

Hi, I'm using JAX-RS MOXy Provider and I can see com.eclipsesource.jaxrs.provider.moxy.MOXyJsonProviderService on the lists of body message readers and writers. I want to consume and provide both XML and JSON. Now I'm testing JSON. I can produce it, but when I try to consume I get:

java.lang.ClassNotFoundException: org.eclipse.persistence.internal.libraries.antlr.runtime.tree.Tree cannot be found by org.eclipse.persistence.core_2.5.0.v20130507-3faac2b

EclipseLink ANTLR bundle is active:

52  ACTIVE      org.eclipse.persistence.antlr_3.2.0.v201302191141
BryanHunt commented 9 years ago

That should work. Did you by chance add the antlr bundle while the framework was running? I recall having a similar problem and a simple restart of the framework fixed it.

On Mar 19, 2015, at 6:44 PM, Seweryn Niemiec <notifications@github.com mailto:notifications@github.com> wrote:

Hi, I'm using JAX-RS MOXy Provider and I can see com.eclipsesource.jaxrs.provider.moxy.MOXyJsonProviderService on the lists of body message readers and writers. I want to consume and provide both XML and JSON. Now I'm testing JSON. I can produce it, but when I try to consume I get:

java.lang.ClassNotFoundException: org.eclipse.persistence.internal.libraries.antlr.runtime.tree.Tree cannot be found by org.eclipse.persistence.core_2.5.0.v20130507-3faac2b

EclipseLink ANTLR bundle is active:

52 ACTIVE org.eclipse.persistence.antlr_3.2.0.v201302191141 — Reply to this email directly or view it on GitHub https://github.com/hstaudacher/osgi-jax-rs-connector/issues/90.

thugcee commented 9 years ago

I'm fighting to isolate this problem for a few hours. There was a lot of restarts. It occurs on two different machines (but environments on booth of them are almost the same). Equinox is a container and I start it from Eclipse. Everything seems to be fine:

Bundles:

id  State       Bundle
0   ACTIVE      org.eclipse.osgi_3.10.2.v20150203-1939
                Fragments=53, 54, 57, 58
2   ACTIVE      org.eclipse.equinox.http.jetty_3.0.200.v20131021-1843
4   ACTIVE      org.apache.felix.gogo.command_0.10.0.v201209301215
6   ACTIVE      javax.servlet-api_3.0.1
7   ACTIVE      org.apache.felix.gogo.runtime_0.10.0.v201209301036
11  ACTIVE      org.apache.felix.gogo.shell_0.10.0.v201212101605
16  ACTIVE      org.eclipse.equinox.http.servlet_1.1.500.v20140318-1755
17  ACTIVE      org.eclipse.equinox.console_1.1.0.v20140131-1639
18  ACTIVE      org.eclipse.osgi.services_3.4.0.v20140312-2051
24  ACTIVE      org.mongodb.mongo-java-driver_2.13.0.RELEASE
28  ACTIVE      org.eclipse.equinox.ds_1.4.200.v20131126-2331
30  ACTIVE      org.eclipse.equinox.util_1.0.500.v20130404-1337
35  ACTIVE      org.scala-lang.scala-library_2.11.6.v20150224-172222-092690e7bf
37  ACTIVE      org.eclipse.jetty.security_8.1.16.v20140903
38  ACTIVE      org.eclipse.jetty.http_8.1.16.v20140903
39  ACTIVE      org.apache.commons.lang_2.6.0
40  ACTIVE      org.eclipse.jetty.io_8.1.16.v20140903
41  ACTIVE      org.eclipse.jetty.server_8.1.16.v20140903
43  ACTIVE      commons-logging_1.1.1
44  ACTIVE      org.apache.commons.configuration_1.10.0
45  ACTIVE      org.eclipse.jetty.continuation_8.1.16.v20140903
46  ACTIVE      org.eclipse.jetty.servlet_8.1.16.v20140903
47  ACTIVE      org.eclipse.jetty.util_8.1.16.v20140903
50  ACTIVE      com.eclipsesource.jaxrs.jersey-all_2.16.1
51  ACTIVE      com.eclipsesource.jaxrs.provider.security_2.0.1.201502251332
52  ACTIVE      com.eclipsesource.jaxrs.publisher_4.2.1.201502251332
53  RESOLVED    org.eclipse.osgi.compatibility.state_1.0.1.v20140709-1414
                Master=0
54  RESOLVED    org.eclipse.equinox.transforms.hook_1.1.0.v20131021-1933
                Master=0
55  ACTIVE      com.eclipsesource.jaxrs.provider.moxy_2.0.1.201502251332
56  ACTIVE      org.eclipse.persistence.moxy_2.5.0.v20130507-3faac2b
57  RESOLVED    org.eclipse.equinox.region_1.2.0.v20140128-1636
                Master=0
58  RESOLVED    org.eclipse.equinox.weaving.hook_1.1.1.v20140821-1918
                Master=0
59  ACTIVE      org.eclipse.persistence.core_2.5.0.v20130507-3faac2b
61  ACTIVE      org.eclipse.persistence.antlr_3.2.0.v201302191141
63  ACTIVE      org.mongodb.morphia.util_0.110.0
64  ACTIVE      org.mongodb.morphia_0.110.0
65  ACTIVE      com.thoughtworks.proxytoys_1.0.0
67  ACTIVE      edu.zut.aci.nsg.restapi_0.0.1.qualifier
osgi> bundle 61
org.eclipse.persistence.antlr_3.2.0.v201302191141 [61]
  Id=61, Status=ACTIVE      Data Root=/home/ser/lab/eclipse/neustemgen/.metadata/.plugins/org.eclipse.pde.core/edu.zut.aci.nsg.restapi/org.eclipse.osgi/61/data
  "No registered services."
  No services in use.
  Exported packages
    org.eclipse.persistence.internal.libraries.antlr.runtime; version="3.2.0"[exported]
    org.eclipse.persistence.internal.libraries.antlr.runtime.debug; version="3.2.0"[exported]
    org.eclipse.persistence.internal.libraries.antlr.runtime.misc; version="3.2.0"[exported]
    org.eclipse.persistence.internal.libraries.antlr.runtime.tree; version="3.2.0"[exported]
  No imported packages
  No fragment bundles
  No required bundles

osgi> packages org.eclipse.persistence.internal.libraries.antlr.runtime.tree
osgi.wiring.package; bundle-symbolic-name="org.eclipse.persistence.antlr"; bundle-version:Version="3.2.0.v201302191141"; version:Version="3.2.0"; osgi.wiring.package="org.eclipse.persistence.internal.libraries.antlr.runtime.tree"<org.eclipse.persistence.antlr_3.2.0.v201302191141 [61]>
thugcee commented 9 years ago

When I add osgi-jax-rs-connector/gson provider to the container and rewrite code for gson it works fine.

The test method (for MOXy) looks like this:

    @PUT @Path("/{name}")
    @Consumes(MediaType.APPLICATION_JSON)
    public Response register(@PathParam("name") String name, User user) {
        System.out.println(user);
        return Response.status(Response.Status.CREATED).build();
    }
thugcee commented 9 years ago

I have changed MOXy to 2.5.2 (resolved from this p2 repo http://download.eclipse.org/rt/eclipselink/updates/) and it works now.

hstaudacher commented 9 years ago

@BryanHunt do we need to update moxy?

BryanHunt commented 9 years ago

Sounds like it. Might check to see if the other eclipse-link bundles need to be updated as well.

thugcee commented 9 years ago

I'm still not sure if it isn't problem with my configuration. Tomorrow I'll try to go back to osgi-jax-rs-connector's MOXy and check it again. It's my first app based on OSGi container, so I could break many things.

But if you plan MOXy update, then maybe straight to 2.6. It has support for JSR-353 (Java API for JSON Processing). Now I have to use MOXy for JSON/XML<->POJO mapping and Gson for JSON<->DOM.

BTW. Thx for osgi-jax-rs-connector. It's a great software for REST/OSGi beginners. Among other solutions it provided a "clean way", which I liked very much.

thugcee commented 9 years ago

OK, it had to by some my fault. I have prepared target platform with MOXy from osgi-jax-rs-connector, manually selected only necessary bundles to start and now XML and JSON Providers and Consumers work without problems. Sorry for false alarm.