users@glassfish.java.net

Re: ClassLoading problem while migrating application from GF v2 to GF v3

From: Sanjeeb Sahoo <sahoo_at_sun.com>
Date: Fri, 25 Jun 2010 18:42:26 +0530

See response inline..

On Thursday 24 June 2010 09:30 PM, glassfish_at_javadesktop.org wrote:
> Hello all,
>
> I am migrating an application to GFv3 from GFv2 that extensively uses CGLib proxies. It proxies JavaMail classes, which in GFv3 are part of a mail.jar bundle. Of course at first generated proxies were not able to find CGLib, since bundle class loader of the mail bundle does not see classes that are part of a webapp.
No, it is not clear why JavaMail classes looked for CGLib classes. Do
you have the exception stacktrace?
> I solved this problem by deploying CGLib as a bundle, but introduced the new one:
> java.lang.IllegalAccessError: class $javax.mail.internet.MimeBodyPart$MimePartDataHandler$$EnhancerByCGLIB$$bd265e6c_2 cannot access its superclass javax.mail.internet.MimeBodyPart$MimePartDataHandler
>
> CGLib cannot load generated byte code for the proxy (define class) since it cannot access the parent class, which is part of a mail bundle. All classes are available though Class.forName().
>

When you define new classes using CGLib, which class loader do you use?
If you use the class loader used to load CGLib classes, then the proxy
can't locate JavaMail classes. I don't know how CGLib works, but I would
try adding CGLib to war file or ejb-jar and define the proxies using
Thread's context class loader. Give it a try if you have not.
> There are also the second question: is it possible to change javamail impl and java bean activation framework jars for the domain in GF v3, like it was possible before using lib/ext directory ?
>
>
>
No, you can't override Platform APIs using lib/ext or any such
technique. Even if you did something like this in v2, that was not a
supported configuration.

Sahoo
> Thanks in advance,
> Michael
> [Message sent by forum member 'smikesh']
>
> http://forums.java.net/jive/thread.jspa?messageID=475706
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>