Hi
Please find my responses inline.
glassfish_at_javadesktop.org wrote:
> Thanks Siva, this give me more insight on my problem, however...
>
>>> I getting a strange, classloader related problem.
>>>
>>> My deployment consists of one RAR and one EAR
>>> - RAR is genericjmsra + Activemq. (I put all deps
>> into the rar, including log4j, jcl)
>>> - EAR is our own application.
>>> Two deployment both include commons-logging +
>> log4j.
>>> When deploying the ear, log4j.xml in .rar is used,
>> rather than the one
>>> included in the ear (I include log4j.xml in the
>> myejb.jar, which included in the ear)
>>> So, as I can see, the classloader universe is
>> shared for both the ear and the rar,
>>> Am I right??
>>>
>> The standalone resource adapter [RAR] is loaded by
>> the connector
>> classloader as shown in fig2-1 at
>> https://glassfish.dev.java.net/nonav/javaee5/docs/DG/b
>> eade.html
>>
>> and hence classes/resources in the resource adapter
>> would be loaded in
>> precedence to classes in the ear.
>
> You're right, I missed, thanks very much !!
>
>
>>> If I want to enclose my application (ear) specific
>> log4j.xml in the .ear, what can I do.
>>
>> Does the response at
>> https://glassfish.dev.java.net/servlets/ReadMsg?list=u
>> sers&msgNo=590 help?
>
> No, I've try to repackage, but doesn't help..
>
> I guess the problem I have met is, connector classloader is the parent
> of App Classloader.
>
> Does application classloader (for one EAR) delegate using the standard approach
> (ie, delegate to parent classloader first?)
Yes.
>
> If yes, and if connector classloader have loaded one class (LogFactory) when deploying
> the RA module, subsequently, when loading of the EAR trigger a resolve of LogFactory.
> The EAR will using the instance of LogFactory which are loaded by the connector classloader.
>
That is right.
> In the above scenario, the LogFactory will load Log4jAdapter, and then the log4j.xml
> when loading the rar.
>
Right. Does your connector module logs messages using log4j?
> Though, the above stuff is simply guess of mine, but is it correct?
> Actually, I know, the clasaloader chain is a complex topic~
>
> IF this is cause of my problem, is it possible to enforce some control,
> which class loaded by connector classloader is NOT visible to the Application (EAR)?
No all the classes of standalone resource adapters are visible to EARs
>
> OR,
>
> Can I package the rar inside the EAR.
> If package RAR inside EAR is legal and supported,
> then, both the EJB module and RAR module will live in the same Classloader
> universe.. and my problem can also be solved...
> Is it viable?
>
Yes you can and it is referred to as an embedded resource adapter. Such a
resource adapter is visible only to that application.
http://docs.sun.com/app/docs/doc/819-4721/6n6rrfqm1?a=view
Please refer to this application.xml for an example of an ear with an
embedded rar.
http://fisheye5.cenqua.com/browse/glassfish/appserv-tests/devtests/connector/embeddedConnector1.5/app/META-INF/application.xml?r=1.1
>>> Also, I've read the developer guide which talks
>> about classloader universe.
>>> Is it true that, if I deploy an EAR, all the lib
>> inside is loaded with one AppClassLoader?
>>
>> Are you referring to the libraries in your EAR's
>> library-directory? If yes,
>> then yes these libraries are loaded by one
>> classloader, the application's
>> classloader.
>
> Originally, I put all jars in the ear (top level, not lib/, but I've now put the jars in lib/).
> BTW, both are supported in Glassfish, am I right??
>
No, placing a jar at the top-level directory or lib and expecting the
container to pick it up is ideally not portable. Please try using the Java
EE 5's library-directory element in application.xml instead. More details
at
http://javahowto.blogspot.com/2006/10/use-library-directory-in-javaee-5-apps.html
Thanks
--Siva.
>>> How about RAR, it haven't mentioned about RAR?
>>>
>> The classes of a standalone resource adapter is
>> loaded by "a" classloader
>> instance in the connector classloader. The Connector
>> ClassLoader is not a
>> conventional JAR or URL ClassLoader but is a chain of
>> classloader and that
>> is how we achieve loading and unloading of multiple
>> standalone resource
>> adapter classloaders while still maintaining
>> isolation between individual
>> standalone resource adapters
>
> Interesting :)
>
>>> Finally, if my rar consists of a few dependency,
>> should I package all the dep of the RAR
>>> into one unit.
>>> Just put all dep into the rar?
>> Yes this should work. If the dependencies are also
>> used by multiple
>> applications in your domain and not only by the
>> resource adapter, you could
>> consider using the approaches outlined in the
>> question "How do I control
>> visibility scope of my libraries" in
>> http://blogs.sun.com/sivakumart/entry/classloaders_in_
>> glassfish_an_attempt
>
> Thanks again, I've read this before :)
> But looks like it doesn't solve me problem here..
>
>
> Best regards,
> Zarick
> [Message sent by forum member 'zarick' (zarick)]
>
> http://forums.java.net/jive/thread.jspa?messageID=212015
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>