2 Replies Latest reply on Nov 7, 2013 3:33 AM by Steven Pessall

    IllegalAccessException on Serialization of JSR-310 classes

    Steven Pessall Newbie

      We are currently replacing the java.util.Date classes with classes from the java 7 backport of JSR-310.

       

      When using org.threeten.bp.LocalDateTime as parameter in a local ejb call on JBoss 7.2 we get the following stack trace:

       

      15:44:27,319 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/TestProxy].[kam.cmd.resourcebrowser.RestApp]] (http-/0.0.0.0:38080-1) JBWEB000236: Servlet.service() for servlet kam.cmd.resourcebrowser.RestApp threw exception: org.jboss.resteasy.spi.UnhandledException: java.lang.RuntimeException: JBAS014154: Failed to marshal EJB parameters

          at org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:365) [resteasy-jaxrs-2.3.5.Final.jar:]

          at org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:233) [resteasy-jaxrs-2.3.5.Final.jar:]

          at org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:209) [resteasy-jaxrs-2.3.5.Final.jar:]

          at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:557) [resteasy-jaxrs-2.3.5.Final.jar:]

          at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524) [resteasy-jaxrs-2.3.5.Final.jar:]

          at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126) [resteasy-jaxrs-2.3.5.Final.jar:]

          at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.3.5.Final.jar:]

          at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.3.5.Final.jar:]

          at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.3.5.Final.jar:]

          at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final.jar:1.0.2.Final]

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.2.0.Final.jar:7.2.0.Final]

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.2.0.Final.jar:7.2.0.Final]

          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) [jbossweb-7.2.0.Final.jar:7.2.0.Final]

          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.2.0.Final.jar:7.2.0.Final]

          at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.2.0.Final.jar:7.2.0.Final]

          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.2.0.Final.jar:7.2.0.Final]

          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.2.0.Final.jar:7.2.0.Final]

          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.2.0.Final.jar:7.2.0.Final]

          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336) [jbossweb-7.2.0.Final.jar:7.2.0.Final]

          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.2.0.Final.jar:7.2.0.Final]

          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.2.0.Final.jar:7.2.0.Final]

          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920) [jbossweb-7.2.0.Final.jar:7.2.0.Final]

          at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]

      Caused by: java.lang.RuntimeException: JBAS014154: Failed to marshal EJB parameters

          at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:270) [jboss-as-ejb3-7.2.0.Final.jar:7.2.0.Final]

          at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:259) [jboss-as-ejb3-7.2.0.Final.jar:7.2.0.Final]

          at org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:170) [jboss-as-ejb3-7.2.0.Final.jar:7.2.0.Final]

          at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) [jboss-ejb-client-1.0.16.Final.jar:1.0.16.Final]

          at org.jboss.ejb.client.EJBHomeCreateInterceptor.handleInvocation(EJBHomeCreateInterceptor.java:79) [jboss-ejb-client-1.0.16.Final.jar:1.0.16.Final]

          at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) [jboss-ejb-client-1.0.16.Final.jar:1.0.16.Final]

          at org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:42) [jboss-ejb-client-1.0.16.Final.jar:1.0.16.Final]

          at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) [jboss-ejb-client-1.0.16.Final.jar:1.0.16.Final]

          at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:125) [jboss-ejb-client-1.0.16.Final.jar:1.0.16.Final]

          at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) [jboss-ejb-client-1.0.16.Final.jar:1.0.16.Final]

          at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:177) [jboss-ejb-client-1.0.16.Final.jar:1.0.16.Final]

          at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:161) [jboss-ejb-client-1.0.16.Final.jar:1.0.16.Final]

          at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:124) [jboss-ejb-client-1.0.16.Final.jar:1.0.16.Final]

          at com.sun.proxy.$Proxy124.getList(Unknown Source)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_45]

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_45]

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_45]

          at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_45]

          at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267) [weld-core-1.1.10.Final.jar:2012-10-12 10:00]

          at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52) [weld-core-1.1.10.Final.jar:2012-10-12 10:00]

          at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137) [weld-core-1.1.10.Final.jar:2012-10-12 10:00]

          at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263) [weld-core-1.1.10.Final.jar:2012-10-12 10:00]

          at org.jboss.weld.bean.builtin.CallableMethodHandler.invoke(CallableMethodHandler.java:52) [weld-core-1.1.10.Final.jar:2012-10-12 10:00]

          at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56) [weld-core-1.1.10.Final.jar:2012-10-12 10:00]

          at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105) [weld-core-1.1.10.Final.jar:2012-10-12 10:00]

          at kam.cmd.boundary.access.MDListService$431771952$Proxy$_$$_Weld$Proxy$.getList(MDListService$431771952$Proxy$_$$_Weld$Proxy$.java) [cmd-core-boundary-0.0.10-SNAPSHOT.jar:]

          at kam.cmd.client.AbstractMasterDataClient.getData(AbstractMasterDataClient.java:57) [cmd-core-client-base-0.0.10-SNAPSHOT.jar:]

          at kam.cmd.client.ejb.EJBMasterDataClient$Proxy$_$$_WeldClientProxy.getData(EJBMasterDataClient$Proxy$_$$_WeldClientProxy.java) [cmd-core-client-ejb-0.0.10-SNAPSHOT.jar:]

          at kam.cmd.resourcebrowser.BackwareBrowser.getRes(BackwareBrowser.java:37) [classes:]

          at kam.cmd.resourcebrowser.BackwareBrowser$Proxy$_$$_WeldClientProxy.getRes(BackwareBrowser$Proxy$_$$_WeldClientProxy.java) [classes:]

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_45]

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_45]

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_45]

          at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_45]

          at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167) [resteasy-jaxrs-2.3.5.Final.jar:]

          at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257) [resteasy-jaxrs-2.3.5.Final.jar:]

          at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222) [resteasy-jaxrs-2.3.5.Final.jar:]

          at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:211) [resteasy-jaxrs-2.3.5.Final.jar:]

          at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542) [resteasy-jaxrs-2.3.5.Final.jar:]

          ... 19 more

      Caused by: java.io.InvalidClassException: org.threeten.bp.Ser; Illegal access exception occurred accessing the constructor: java.lang.IllegalAccessException: Class org.jboss.marshalling.reflect.PublicReflectiveCreator can not access a member of class org.threeten.bp.Ser with modifiers "public"

          at org.jboss.marshalling.reflect.PublicReflectiveCreator.create(PublicReflectiveCreator.java:43)

          at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:240)

          at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:174)

          at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134)

          at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:268) [jboss-as-ejb3-7.2.0.Final.jar:7.2.0.Final]

          ... 57 more

       

      The class org.threeten.bp.Ser is a package visible helper class used in the serialization of LocalDateTime objects. What I don't understand is, why the SerializingCloner tries to directly instantiate this helper class.

       

      Can anyone shed some light on this issue?

        • 1. Re: IllegalAccessException on Serialization of JSR-310 classes
          Steven Pessall Newbie

          I did some further digging to narrow the problem down:

           

          The LocalDateTime class uses the Externalizable mechanism for serialization. It does not implement the Externalizable interface itself but delegates serialization to org.threeten.bp.Ser by implementing the writeReplace() method.

           

          Now the org.jboss.marshalling.cloner.SerializingCloner tries to clone the replacement object by calling the default constructor. This fails because while org.threeten.bp.Ser does have a public default constructor the class itself is only package visible. This actually fulfills the Java Object Serialization Specification, which only demands a public constructor for Externalizable classes (see http://docs.oracle.com/javase/6/docs/platform/serialization/spec/serial-arch.html#7185).

           

          This problem would not occur if the replacement object is not cloned. The cloning is actually not necessary, as org.threeten.bp.LocalDateTime.writeReplace() always creates a new instance of org.threeten.bp.Ser.

           

          Is there a way to prevent the org.jboss.marshalling.cloner.SerializingCloner from cloning the replacement object? One possible Solution would be to add org.threeten.bp.Ser to the UNCLONED Set of SerializingCloner, but there does not seem to be a way to do this from outside of SerializingCloner.

          • 2. Re: IllegalAccessException on Serialization of JSR-310 classes
            Steven Pessall Newbie

            I just realized that the problem would be solved, if the SerializingCloner would use the class org.jboss.marshalling.reflect.ReflectiveCreator instead of org.jboss.marshalling.reflect.PublicReflectiveCreator for the instantiation of the clone objects.


            And the ClonerConfiguration object actually allows the configuration of the creator class.


            So I actually only have one question: How do I configure jboss-marshalling within JBoss 7?