0

I have a rest web service which consumes JAXB annotated nested object as input as well as produces JAXB annotated nested object.

You can think of my nested objects like;

{
    "propertyOne": "bla bla",
    "propertyTwo": "5",
    objectB: {
        "propertyA": "xyz",
        "propertyB": "true"
    }

}

And my resource definition for web service like;

    @POST
    @Path("/abc")
    @Produces({ MediaType.APPLICATION_JSON })
    @Consumes({ MediaType.APPLICATION_JSON })
    public ObjectC search(ObjectA objectA) {
        // some logic
    }

This is a working structure with java1.8 on weblogic 12c. But after migration to java11 and weblogic 14c when I send a request to this web service I am receiving an empty objectA in my search resource like;

{
    "propertyOne": "",
    "propertyTwo": "",
    objectB: null
}

there is a unmarshalling problem, why is that? any idea...

NOT : library used from past I am using MOXY as JSON provider

        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-moxy</artifactId>
            <scope>provided</scope>
        </dependency>
4
  • Which version of Jersey does WebLogic 14 use? Moxy might not even be the default anymore. If you want to ensure Moxy is used, don't put it as provided and explicitly register the Moxy provider (or feature) Commented Jun 17, 2021 at 11:18
  • @PaulSamsotha, thnx your reply. I removed moxy's scope and registered MoxyJsonFeature but now I getting an error; Caused By: java.lang.ClassCastException: class org.glassfish.jersey.logging.LoggingFeatureAutoDiscoverable cannot be cast to class org.glassfish.jersey.internal.spi.AutoDiscoverable (org.glassfish.jersey.logging.LoggingFeatureAutoDiscoverable is in unnamed module of loader weblogic.utils.classloaders.ChangeAwareClassLoader @1ac42b0d; org.glassfish.jersey.internal.spi.AutoDiscoverable is in unnamed module of loader com.oracle.classloader.weblogic.LaunchClassLoader @13e39c73) Commented Jun 17, 2021 at 14:29
  • If WebLogic has MOXy library already, you can probably put the scope back. Registering the feature should be enough to ensure MOXy is used. I think the error might be due the different in Jersey version you are using in your application and the version of Jersey WebLogic has Commented Jun 17, 2021 at 20:31
  • Hi @PaulSamsotha, you are right, it was enough to register, it worked. I think weblogic keeps moxy libraries still. Commented Jun 21, 2021 at 5:08

1 Answer 1

0

Paul's recommendation solved the issue, just put moxy in provided scope and register MoxyJsonFeature, it worked

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.