1 2 Previous Next 16 Replies Latest reply on Dec 18, 2007 1:40 AM by Scott Stark

    Serialization, NoSuchMethodException in ProfileServiceUnitTe

    Scott Stark Master

      I'm seeing this failure on most of the ProfileServiceUnitTestCase tests currently. Are you seeing these Alexey?

      Caused by: java.lang.NoSuchMethodException: class java.lang.ClassLoader.defineClass - [class [Ljava.lang.Object;, int, int]
       at org.jboss.reflect.plugins.introspection.ReflectionUtils.findExactMethod(ReflectionUtils.java:240)
       at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.readObject(ReflectMethodInfoImpl.java:129)
       at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:946)
       ... 145 more
      



        • 1. Re: Serialization, NoSuchMethodException in ProfileServiceUn
          Scott Stark Master

          The problem looks to be an incorrect generation of the ClassLoader.defineClass(byte[], int, int) method. What shows up on the test client is a ReflectMethodInfoImpl(defineClass) object that has a parameterTypes[0] value of ArrayInfoImpl@4532be10{name=[Ljava.lang.Object;}. There is no defineClass method that takes an array of Objects.

          • 2. Re: Serialization, NoSuchMethodException in ProfileServiceUn
            Ales Justin Master

            You're right. :-(
            This test shows it:

            public class Test
            {
             public static void main(String[] args)
             {
             try
             {
             Configuration configuration = new PropertyConfiguration();
             BeanInfo beanInfo = configuration.getBeanInfo(ClassLoader.class);
             Set<MethodInfo> methods = beanInfo.getMethods();
             for(MethodInfo mi : methods)
             {
             byte[] bytes = serialize((Serializable)mi);
             Object o = deserialize(bytes);
             System.out.println("o = " + o);
             }
             }
             catch (Exception e)
             {
             e.printStackTrace();
             }
             }
            
             protected static byte[] serialize(Serializable object) throws Exception
             {
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
             ObjectOutputStream oos = new ObjectOutputStream(baos);
             oos.writeObject(object);
             oos.close();
             return baos.toByteArray();
             }
            
             protected static Object deserialize(byte[] bytes) throws Exception
             {
             ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
             ObjectInputStream ois = new ObjectInputStream(bais);
             return ois.readObject();
             }
            }
            


            Any ideas?
            I'll have a look at it.
            Trying to fix it, and commit together with all the changes needed for Alexey.

            • 3. Re: Serialization, NoSuchMethodException in ProfileServiceUn
              Ales Justin Master

              Found it. :-)

              From WeakTypeCache:

               private T getGenericArrayType(GenericArrayType type)
               {
               // TODO JBMICROCONT-131 this needs implementing properly
               return get(Object[].class);
               }
              


              Adrian? :-)
              Or what to do?
              Since if implementing this was trivial, it would have been already done. ;-)

              • 4. Re: Serialization, NoSuchMethodException in ProfileServiceUn
                Scott Stark Master

                Its already there in some form as this test produces the correct primitive ArrayInfo:

                 public void testByteArrayInfo()
                 {
                 TypeInfoFactory factory = getTypeInfoFactory();
                 byte[] x = {};
                 TypeInfo xinfo = factory.getTypeInfo(x.getClass());
                 getLog().debug(xinfo);
                 assertTrue(xinfo instanceof ArrayInfo);
                 ArrayInfo ainfo = (ArrayInfo) xinfo;
                 }
                
                28 DEBUG [ByteArrayUnitTestCase] ArrayInfoImpl@3148aa23{name=[B}
                



                • 5. Re: Serialization, NoSuchMethodException in ProfileServiceUn
                  Ales Justin Master

                  Yes.
                  This is when you are trying to transform runtime type instance - which is generics unaware.

                  If you did something like this:

                  public class MyClass
                  {
                   public byte[] someBytes();
                  }
                  

                  And then (pseudo) MyClass.getMethod("someBytes").getGenericReturnType().
                  Then it would fail.

                  In this code
                   public T get(Type type)
                   {
                   if (type == null)
                   throw new IllegalArgumentException("Null type");
                  
                   if (type instanceof ParameterizedType)
                   return getParameterizedType((ParameterizedType) type);
                   else if (type instanceof Class)
                   return getClass((Class<?>) type);
                   else if (type instanceof TypeVariable)
                   // TODO Figure out why we need this cast with the Sun compiler?
                   return (T) getTypeVariable((TypeVariable) type);
                   else if (type instanceof GenericArrayType)
                   return getGenericArrayType((GenericArrayType) type);
                   else if (type instanceof WildcardType)
                   return getWildcardType((WildcardType) type);
                   else
                   throw new UnsupportedOperationException("Unknown type: " + type + " class=" + type.getClass());
                   }
                  


                  The first example is picked up by (instance of Class), where the 2nd one is by the method I mentioned before.

                  • 6. Re: Serialization, NoSuchMethodException in ProfileServiceUn
                    Scott Stark Master

                    Ok, I see. The initial implementation getGenericArrayType that should be simple is to handle primitive arrays.

                    The problem is that the getGenericArrayType does not belong in the WeakTypeClass as a private method as it cannot be override to return an ArrayInfo. The implementation should simply be the following in IntrospectionTypeInfoFactoryImpl:

                     protected ArrayInfo getGenericArrayType(GenericArrayType type)
                     {
                     Type compType = type.getGenericComponentType();
                     TypeInfo componentType = getTypeInfo(compType);
                     ArrayInfoImpl result = new ArrayInfoImpl(componentType);
                     return result;
                     }
                    



                    • 7. Re: Serialization, NoSuchMethodException in ProfileServiceUn
                      Ales Justin Master

                      OK, I'll fix this.
                      But you'll have to do the release - in this case of commons as well. :-)

                      • 9. Re: Serialization, NoSuchMethodException in ProfileServiceUn
                        Ales Justin Master

                         

                        "scott.stark@jboss.org" wrote:
                        OK.

                        I've updated and commited commons core.
                        And I'll comment this code in IntrospectionTypeInfoFactoryImpl
                         protected TypeInfo getGenericArrayType(GenericArrayType type)
                         {
                         Type compType = type.getGenericComponentType();
                         TypeInfo componentType = getTypeInfo(compType);
                         return new ArrayInfoImpl(componentType);
                         }
                        

                        otherwise current MC build would complain.

                        So, once you've updated Commons-core, please uncomment this code. :-)

                        • 10. Re: Serialization, NoSuchMethodException in ProfileServiceUn
                          Scott Stark Master

                          Just check in the other changes as I have the IntrospectionTypeInfoFactoryImpl change done with a test case and am releasing common 2.2.3.GA now.

                          • 12. Re: Serialization, NoSuchMethodException in ProfileServiceUn
                            Scott Stark Master

                            The server fails to load any deployers with the current mc trunk jars:

                            19:49:59,750 ERROR [ProfileServiceBootstrap] Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
                            
                            *** CONTEXTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}
                            
                            WSDeployerHook_JAXRPC_POST_JSE
                             -> WebServiceDeployerPostJSE{Installed:Instantiated}
                             -> WebServiceDeployerPostJSE{Installed:Instantiated}
                             -> WSDeployerHook_JAXRPC_POST_JSE{Installed:Configured}
                             -> WSDeployerHook_JAXRPC_POST_JSE{Installed:Configured}
                             -> WebServiceDeployerPostJSE{Start:Instantiated}
                             -> WebServiceDeployerPostJSE{Create:Instantiated}
                            
                            WSDeployerHook_JAXRPC_PRE_JSE
                             -> WebServiceDeployerPreJSE{Installed:Instantiated}
                             -> WebServiceDeployerPreJSE{Start:Instantiated}
                             -> WSDeployerHook_JAXRPC_PRE_JSE{Installed:Configured}
                             -> WebServiceDeployerPreJSE{Create:Instantiated}
                             -> WebServiceDeployerPreJSE{Installed:Instantiated}
                             -> WSDeployerHook_JAXRPC_PRE_JSE{Installed:Configured}
                            
                            WSDeployerHook_JAXWS_POST_JSE
                             -> WebServiceDeployerPostJSE{Installed:Instantiated}
                             -> WebServiceDeployerPostJSE{Start:Instantiated}
                             -> WSDeployerHook_JAXWS_POST_JSE{Installed:Configured}
                             -> WSDeployerHook_JAXWS_POST_JSE{Installed:Configured}
                             -> WebServiceDeployerPostJSE{Installed:Instantiated}
                             -> WebServiceDeployerPostJSE{Create:Instantiated}
                            
                            WSDeployerHook_JAXWS_PRE_JSE
                             -> WebServiceDeployerPreJSE{Create:Instantiated}
                             -> WebServiceDeployerPreJSE{Installed:Instantiated}
                             -> WebServiceDeployerPreJSE{Installed:Instantiated}
                             -> WSDeployerHook_JAXWS_PRE_JSE{Installed:Configured}
                             -> WSDeployerHook_JAXWS_PRE_JSE{Installed:Configured}
                             -> WebServiceDeployerPreJSE{Start:Instantiated}
                            
                            WebServiceDeployerPostJSE
                             -> WarDeployer{Configured:** NOT FOUND **}
                             -> WebAppParsingDeployer{Create:** NOT FOUND **}
                             -> WebAppParsingDeployer{Start:** NOT FOUND **}
                            
                            WebServiceDeployerPreJSE
                             -> WebAppParsingDeployer{Start:** NOT FOUND **}
                             -> WarDeployer{Configured:** NOT FOUND **}
                             -> WebAppParsingDeployer{Create:** NOT FOUND **}
                            
                            
                            *** CONTEXTS IN ERROR: Name -> Error
                            
                            WarDeployer -> ** NOT FOUND **
                            
                            WebAppParsingDeployer -> ** NOT FOUND **
                            
                            
                            19:49:59,752 INFO [ServerImpl] JBoss (Microcontainer) [5.0.0.Beta3 (build: SVNTag=JBoss_5_0_0_Beta3 date=200712171832)] Started in 24s:687ms
                            

                            have you tried trunk against jbossas? I'm looking into what has changed.


                            • 13. Re: Serialization, NoSuchMethodException in ProfileServiceUn
                              Scott Stark Master

                              It was the change in the jboss-structure.xml that broke the jbossweb.deployer.

                              • 14. Re: Serialization, NoSuchMethodException in ProfileServiceUn
                                Scott Stark Master

                                Still seeing a marshalling problem:

                                Caused by: java.lang.NoSuchMethodException: class org.jboss.resource.connectionmanager.JBossManagedConnectionPool.access$000 - [class org.jboss.resource.connectionmanager.JBossManagedConnectionPool]
                                 at org.jboss.reflect.plugins.introspection.ReflectionUtils.findExactMethod(ReflectionUtils.java:240)
                                 at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.readObject(ReflectMethodInfoImpl.java:129)
                                 at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
                                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                                 at java.lang.reflect.Method.invoke(Method.java:585)
                                 at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:946)
                                 ... 157 more
                                


                                We are returning too much information, the org.jboss.resource.connectionmanager.JBossManagedConnectionPool should not be seen by the client. Am I the only one seeing these marshalling errors?


                                1 2 Previous Next