Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-19186

RestEasy - java.lang.NoClassDefFoundError handling PATCH request

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • None
    • 7.4.0.CD19
    • REST
    • None
    • Hide
      1. Run the JBEAP server.
      2. Deploy the attached app.war
      3. Then create the entity: ( You can use eap-7.4.0.CD19-CR1.postman_collection.json attached file)
        	curl --location --request POST 'http://localhost:8080/app/students' \
        		--header 'Content-Type: application/json' \
        		--header 'Content-Type: text/plain' \
        		--data-raw '{"id":"1","firstName":"Jones","school":"SomeVeryImportantSchool"}'
        

        4. Finally, patch the entity and you get the error:

        	curl --location --request PATCH 'http://localhost:8080/app/students/1' \
        		--header 'Content-Type: application/json-patch+json' \
        		--header 'Content-Type: text/plain' \
        		--data-raw '[{"op":"copy","from":"/firstName","path":"/lastName"},{"op":"replace","path":"/firstName","value":"John"},{"op":"remove","path":"/school"},{"op":"add","path":"/gender","value":"male"}]'
        
      Show
      Run the JBEAP server. Deploy the attached app.war Then create the entity: ( You can use eap-7.4.0.CD19-CR1.postman_collection.json attached file) curl --location --request POST 'http: //localhost:8080/app/students' \ --header 'Content-Type: application/json' \ --header 'Content-Type: text/plain' \ --data-raw '{ "id" : "1" , "firstName" : "Jones" , "school" : "SomeVeryImportantSchool" }' 4. Finally, patch the entity and you get the error: curl --location --request PATCH 'http: //localhost:8080/app/students/1' \ --header 'Content-Type: application/json-patch+json' \ --header 'Content-Type: text/plain' \ --data-raw '[{ "op" : "copy" , "from" : "/firstName" , "path" : "/lastName" },{ "op" : "replace" , "path" : "/firstName" , "value" : "John" },{ "op" : "remove" , "path" : "/school" },{ "op" : "add" , "path" : "/gender" , "value" : "male" }]'

    Description

      We (we are using JDK8 on RHEL7):

      10:23:52,492 ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to /StudentPatchTest/students/1: java.lang.NoClassDefFoundError: Failed to link com/github/fge/jsonpatch/JsonPatchMessages (Module "com.github.fge.json-patch" version 1.9.0.redhat-00002 from local module loader @5f2108b5 (finder: local module finder @31a5c39e (roots: /home/tborgato/tmp/jboss-eap-7.4/modules,/home/tborgato/tmp/jboss-eap-7.4/modules/system/layers/microprofile,/home/tborgato/tmp/jboss-eap-7.4/modules/system/layers/base,/home/tborgato/tmp/jboss-eap-7.4/modules/system/add-ons/spring))): com/github/fge/msgsimple/load/MessageBundleLoader
      	at java.lang.ClassLoader.defineClass1(Native Method)
      	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
      	at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:423)
      	at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:555)
      	at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:339)
      	at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:126)
      	at org.jboss.modules.Module.loadModuleClass(Module.java:731)
      	at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:247)
      	at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
      	at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
      	at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
      	at com.github.fge.jsonpatch.JsonPatch.<clinit>(JsonPatch.java:95)
      	at org.jboss.resteasy.plugins.providers.jackson.PatchMethodFilter.filter(PatchMethodFilter.java:88)
      	at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:306)
      	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:387)
      	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:356)
      	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:329)
      	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:440)
      	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:229)
      	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:135)
      	at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:356)
      	at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:138)
      	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:215)
      	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:227)
      	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
      	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:590)
      	at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
      	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
      	at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
      	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
      	at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
      	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      	at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68)
      	at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
      	at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
      	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      	at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
      	at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
      	at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
      	at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
      	at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
      	at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
      	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      	at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
      	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      	at org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
      	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      	at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269)
      	at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78)
      	at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133)
      	at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130)
      	at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
      	at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
      	at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
      	at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1541)
      	at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1541)
      	at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1541)
      	at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1541)
      	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249)
      	at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78)
      	at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99)
      	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:376)
      	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
      	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
      	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
      	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
      	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
      	at java.lang.Thread.run(Thread.java:748)
      

      To reproduce deploy attached app.war;
      It's taken from RestEasy test org.jboss.resteasy.test.resource.patch.StudentResource and the code handling the PATCH request is the following:

      	   @PATCH
      	   @Path("/{id}")
      	   @Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
      	   @Produces(MediaType.APPLICATION_JSON)
      	   public Student patchStudent(@PathParam("id") long id, Student student)
      	   {
      	      if (studentsMap.get(id) == null)
      	      {
      	         throw new NotFoundException();
      	      }
      	      studentsMap.put(id, student);
      	      return student;
      	   }
      

      Then create the entity:

      	curl --location --request POST 'http://localhost:8080/app/students' \
      		--header 'Content-Type: application/json' \
      		--header 'Content-Type: text/plain' \
      		--data-raw '{"id":"1","firstName":"Jones","school":"SomeVeryImportantSchool"}'
      

      Finally patch the entity and you get the error:

      	curl --location --request PATCH 'http://localhost:8080/app/students/1' \
      		--header 'Content-Type: application/json-patch+json' \
      		--header 'Content-Type: text/plain' \
      		--data-raw '[{"op":"copy","from":"/firstName","path":"/lastName"},{"op":"replace","path":"/firstName","value":"John"},{"op":"remove","path":"/school"},{"op":"add","path":"/gender","value":"male"}]'
      

      Attachments

        Issue Links

          Activity

            People

              rchakrab Ranabir Chakraborty
              tborgato@redhat.com Tommaso Borgato
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: