You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2012/09/18 02:00:06 UTC
svn commit: r1386915 -
/myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/util/MyFacesObjectInputStream.java
Author: lu4242
Date: Tue Sep 18 00:00:05 2012
New Revision: 1386915
URL: http://svn.apache.org/viewvc?rev=1386915&view=rev
Log:
MYFACES-3581 @EJB injection into a @ViewScoped bean causes CNFE
Modified:
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/util/MyFacesObjectInputStream.java
Modified: myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/util/MyFacesObjectInputStream.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/util/MyFacesObjectInputStream.java?rev=1386915&r1=1386914&r2=1386915&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/util/MyFacesObjectInputStream.java (original)
+++ myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/util/MyFacesObjectInputStream.java Tue Sep 18 00:00:05 2012
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
+import java.lang.reflect.Proxy;
/**
* Tried to deploy v0.4.2 on JBoss 3.2.1 and had a classloading problem again.
@@ -53,4 +54,36 @@ public class MyFacesObjectInputStream
return super.resolveClass(desc);
}
}
+
+ protected Class resolveProxyClass(String[] interfaces)
+ throws IOException, ClassNotFoundException
+ {
+ // Only option that would match the current code would be to
+ // expand ClassLoaderExtension to handle 'getProxyClass', which
+ // would break all existing ClassLoaderExtension implementations
+ Class[] cinterfaces = new Class[interfaces.length];
+ for (int i = 0; i < interfaces.length; i++)
+ {
+ cinterfaces[i] = ClassUtils.classForName(interfaces[i]);
+ }
+
+ try
+ {
+ // Try WebApp ClassLoader first
+ return Proxy.getProxyClass(ClassUtils.getContextClassLoader(), cinterfaces);
+ }
+ catch (Exception ex)
+ {
+ // fallback: Try ClassLoader for MyFacesObjectInputStream (i.e. the myfaces.jar lib)
+ try
+ {
+ return Proxy.getProxyClass(
+ MyFacesObjectInputStream.class.getClassLoader(), cinterfaces);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new ClassNotFoundException(e.toString(), e);
+ }
+ }
+ }
}