Nice work.
I create a custom ApplicationContext in the 'init' lifecycle method.
Will the fix still help? Should I pull the source now?

On 5/2/06, Guillaume Nodet <[EMAIL PROTECTED]> wrote:

I have just fixed an issue wrt to classloading.
The current thread context classloader was not set to the component
class loader when the component was created.
Did you initialize your spring stuff at creation time from the
component constructor ?
If yes, you may want to give a try to the latest svn head...

Cheers,
Guillaume Nodet

On 5/2/06, Guillaume Nodet <[EMAIL PROTECTED]> wrote:
> You may try the following things:
>   * set the thread classloader to the classloader of the component
> (though this should have already been done by ServiceMix)
>   * change the classloader so that it delegates to the component
> before trying the parent classloader: this will ensure spring is
> loaded from the component class loader (you have to put it in the
> component class path)
>   * use xbean as done inside the servicemix-common / XbeanDeployer (it
works)
>
> It seems really strange as all ServiceMix components use spring to
> load service unit as an xbean / spring configuration file.
> I think that the spring application context may have some property to
> override the classloader to use: maybe you have to set it explicitely
> to your thread context classloader.
>
> Cheers,
> Guillaume Nodet
>
> On 5/1/06, Hossam Karim <[EMAIL PROTECTED]> wrote:
> > Well, it is not working, Spring can't find the classes although they
are in
> > the components class path, and the loading takes place in the 'init'
method
> >
> > -----Original Message-----
> > From: Guillaume Nodet [mailto:[EMAIL PROTECTED]
> > Sent: Monday, May 01, 2006 2:22 PM
> > To: [email protected]
> > Subject: Re: Class loading problem
> >
> > You should include the jars where the beans are in the component
classpath.
> > If you want to do that at bootstrap time, you need to include them in
> > the bootstrap classloader that you define in your jbi descriptor.
> > This classloader has servicemix container classloader as a parent and
> > includes all the jars listed in the bootstrap classloader defined in
> > the jbi descriptor.
> > Spring should use the thread context class loader to load beans, so it
> > should work even if spring is in the parent class loader (the
> > container one).
> >
> > Cheers,
> > Guillaume Nodet
> >
> > On 5/1/06, Hossam Karim <[EMAIL PROTECTED]> wrote:
> > > So if I am loading some beans XML source that comes with the
component
> > > installation artifact, is it expected that Spring can normally load
the
> > > beans, or should a special procedure be taken according to your
> > > understanding of SM class loading mechanism?
> > >
> > >
> > > -----Original Message-----
> > > From: Guillaume Nodet [mailto:[EMAIL PROTECTED]
> > > Sent: Monday, May 01, 2006 10:07 AM
> > > To: [email protected]
> > > Subject: Re: Class loading problem
> > >
> > > ServiceMix has the spring jars inside its classpath, so it is also
> > > available to the components.  But if you want your component to be
> > > container independant, you have to include it.
> > >
> > > Cheers,
> > > Guillaume Nodet
> > >
> > > On 4/29/06, Hossam Karim <[EMAIL PROTECTED]> wrote:
> > > > I guess you mean the component class loader. Do I really need to
do
> > that,
> > > > add the library to the runtime and deploy it again with the
component
> > > > installation artifact? This means also that Spring libraries have
to be
> > in
> > > > the component class path as well in order to create the beans.
> > > >
> > > > -----Original Message-----
> > > > From: Guillaume Nodet [mailto:[EMAIL PROTECTED]
> > > > Sent: Friday, April 28, 2006 11:03 PM
> > > > To: [email protected]
> > > > Subject: Re: Class loading problem
> > > >
> > > > Did you put your jar in the bootstrap class loader (in your jbi
> > > descriptor)
> > > > ?
> > > > Not only in the runtime class loader ?
> > > >
> > > > Cheers,
> > > > Guillaume Nodet
> > > >
> > > > On 4/28/06, Hossam Karim <[EMAIL PROTECTED]> wrote:
> > > > > BTW, I set the bean reader to use the component's class loader,
but
> > > still
> > > > > Spring can't find the class.
> > > > >
> > > > > On 4/28/06, Hossam Karim <[EMAIL PROTECTED]> wrote:
> > > > > >
> > > > > > Thanks Guillaume and congratulations,
> > > > > >
> > > > > > OK, then. I am not going to argue about why this is not the
case in
> > > the
> > > > > > JBoss environment since it is not supported.
> > > > > > Now I moved the shared code to the lib directory, so the
Bootstrap
> > is
> > > > > > initialized. The component implementation base class is also
in this
> > > > shared
> > > > > > code, I am trying to load some beans from the shared code, and
the
> > > bean
> > > > > > class comes with the component installation artifact, so I am
asking
> > > the
> > > > JBI
> > > > > > class loader to load resources available only to the component
class
> > > > loader
> > > > > > which is also NOT JBI complaint, right?
> > > > > > Do you suggest a solution for this?
> > > > > >
> > > > > > INFO - AbstractBootstrapAdapter.init(17) | init
> > > > > > INFO - AbstractBootstrapAdapter.onInstall(30) | onInstall
> > > > > > INFO - AbstractBootstrapAdapter.cleanUp(21) | cleanUp
> > > > > > INFO - ComponentMBeanImpl.start(206) | Starting component:
> > > > > > com.gaiati.jbi.component.csi.CsiBinding
> > > > > > INFO - ComponentMBeanImpl.init(184) | Initializing component:
> > > > > > com.gaiati.jbi.component.csi.CsiBinding
> > > > > > INFO - AbstractComponentAdapter.getLifeCycle (35) |
getLifeCycle
> > > > > > INFO - AbstractComponentAdapter.init(45) | init
> > > > > > ERROR - ComponentMBeanImpl.start(215) | Could not start
component
> > > > > > org.springframework.beans.factory.BeanDefinitionStoreException
:
> > Error
> > > > > > registering bean with name 'serviceUnitManager' defined in
resource
> > > > loaded
> > > > > > through InputStream: Bean class
> > > > > > com.gaiati.jbi.component.csi.CsiServiceUnitManager] not found;
> > nested
> > > > > > exception is java.lang.ClassNotFoundException:
> > > > > > com.gaiati.jbi.component.csi.CsiServiceUnitManager
> > > > > > java.lang.ClassNotFoundException:
> > > > > > com.gaiati.jbi.component.csi.CsiServiceUnitManager
> > > > > >         at
> > > > > >
org.apache.servicemix.jbi.loaders.ParentFirstClassLoader.loadClass(
> > > > > > ParentFirstClassLoader.java:83)
> > > > > >
> > > > > >         at
> > > > > >
org.apache.servicemix.jbi.loaders.InstallationClassLoader.loadClass(
> > > > > > InstallationClassLoader.java :99)
> > > > > >         at
> > > java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
> > > > > >         at java.lang.Class.forName0(Native Method)
> > > > > >         at java.lang.Class.forName(Class.java:242)
> > > > > >         at org.springframework.util.ClassUtils.forName
> > > (ClassUtils.java
> > > > > > :108)
> > > > > >         at
> > > > > >
> > > >
> > >
> >
org.springframework.beans.factory.support.BeanDefinitionReaderUtils.createBe
> > > > anDefinition
> > > > > > (BeanDefinitionReaderUtils.java:65)
> > > > > >         at
> > > > > >
> > > >
> > >
> >
org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBe
> > > > anDefinitionElement(
> > > > > > DefaultXmlBeanDefinitionParser.java:426)
> > > > > >         at
> > > > > >
> > > >
> > >
> >
org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBe
> > > > anDefinitionElement
> > > > > > (DefaultXmlBeanDefinitionParser.java:392)
> > > > > >         at
> > > > > >
> > > >
> > >
> >
org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBe
> > > > anDefinitions(
> > > > > > DefaultXmlBeanDefinitionParser.java:307)
> > > > > >         at
> > > > > >
> > > >
> > >
> >
org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.registe
> > > > rBeanDefinitions
> > > > > > (DefaultXmlBeanDefinitionParser.java:191)
> > > > > >         at
> > > > > >
> > > >
> > >
> >
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDe
> > > > finitions(
> > > > > > XmlBeanDefinitionReader.java:295)
> > > > > >         at
> > > > > >
> > > >
> > >
> >
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefi
> > > > nitions
> > > > > > (XmlBeanDefinitionReader.java:223)
> > > > > >         at
> > > > > >
> > > >
> > >
> >
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefini
> > > > tions(
> > > > > > XmlBeanDefinitionReader.java:173)
> > > > > >         at
> > > > > >
> > > >
> > >
> >
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefini
> > > > tions
> > > > > > (XmlBeanDefinitionReader.java:148)
> > > > > >         at
> > > > com.gaiati.jbi.component.support.AbstractComponentAdapter.init(
> > > > > > AbstractComponentAdapter.java:60)
> > > > > >         at
> > > org.apache.servicemix.jbi.framework.ComponentMBeanImpl.init(
> > > > > > ComponentMBeanImpl.java:192)
> > > > > >         at
> > > > org.apache.servicemix.jbi.framework.ComponentMBeanImpl.doStart(
> > > > > > ComponentMBeanImpl.java :279)
> > > > > >         at
> > > org.apache.servicemix.jbi.framework.ComponentMBeanImpl.start(
> > > > > > ComponentMBeanImpl.java:208)
> > > > > >         at
> > > > org.apache.servicemix.jbi.framework.InstallationService.install
> > > > > > (InstallationService.java:377)
> > > > > >
> > > > > >         at
> > > > org.apache.servicemix.jbi.framework.InstallationService.install
> > > > > > (InstallationService.java:342)
> > > > > >         at
> > > > > >
> > >
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(
> > > > > > AutoDeploymentService.java:220)
> > > > > >         at
> > > > org.apache.servicemix.jbi.framework.AutoDeploymentService$2.run
> > > > > > (AutoDeploymentService.java:507)
> > > > > >         at
org.apache.geronimo.connector.work.WorkerContext.run(
> > > > > > WorkerContext.java:291)
> > > > > >         at
> > > > EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown
> > Source)
> > > > > >         at java.lang.Thread.run(Thread.java:595)
> > > > > >
> > > > > > On 4/28/06, Guillaume Nodet <[EMAIL PROTECTED] > wrote:
> > > > > > >
> > > > > > > AFAIK, this is not JBI compliant.
> > > > > > > See section 7.3 of the jbi spec.
> > > > > > >
> > > > > > > Cheers,
> > > > > > > Guillaume Nodet
> > > > > > >
> > > > > > > On 4/28/06, Hossam Karim <[EMAIL PROTECTED]> wrote:
> > > > > > > > Hi All,
> > > > > > > >   I have a class loading problem that is only happening
when
> > > running
> > > > > > > SM in
> > > > > > > > standalone mode. When SM is hosted inside JBoss, there is
no
> > > > problem.
> > > > > > > > The situation is like this:
> > > > > > > > I have component with its Bootstrap implementation class
> > extending
> > > a
> > > > > > > class
> > > > > > > > in an installed shared library. The component is
referencing the
> > > > > > > shared
> > > > > > > > library in its deployment descriptor. I install the shared
> > library
> > > > > > > first
> > > > > > > > then install the component, NoClassDefFoundError exception
is
> > > thrown
> > > > > > > upon
> > > > > > > > installation.
> > > > > > > >
> > > > > > > > Here is the trace:
> > > > > > > >
> > > > > > > > INFO - AutoDeploymentService$2.run(504) | Directory:
install:
> > > > Archive
> > > > > > > > changed: processing csi-0.1.jar ...
> > > > > > > > ERROR - InstallationService.initializeInstaller(528) |
> > Deployment
> > > of
> > > > > > > > Component failed
> > > > > > > > java.lang.NoClassDefFoundError:
> > > > > > > > com/gaiati/jbi/component/support/AbstractBootstrapAdapter
> > > > > > > >         at java.lang.ClassLoader.defineClass1(Native
Method)
> > > > > > > >         at java.lang.ClassLoader.defineClass
> > > (ClassLoader.java:620)
> > > > > > > >         at java.security.SecureClassLoader.defineClass(
> > > > > > > > SecureClassLoader.java:124)
> > > > > > > >         at
> > java.net.URLClassLoader.defineClass(URLClassLoader.java
> > > > > > > :260)
> > > > > > > >         at
> > > > java.net.URLClassLoader.access$100(URLClassLoader.java:56)
> > > > > > > >         at
> > java.net.URLClassLoader$1.run(URLClassLoader.java:195)
> > > > > > > >         at java.security.AccessController.doPrivileged
(Native
> > > > Method)
> > > > > > > >         at
> > > > java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> > > > > > > >         at
> > > > > > > >
> > > org.apache.servicemix.jbi.loaders.InstallationClassLoader.findClass(
> > > > > > > > InstallationClassLoader.java:88)
> > > > > > > >         at
> > > > > > > >
> > > org.apache.servicemix.jbi.loaders.ParentFirstClassLoader.loadClass(
> > > > > > > > ParentFirstClassLoader.java:74)
> > > > > > > >         at
> > > > > > > >
> > > org.apache.servicemix.jbi.loaders.InstallationClassLoader.loadClass(
> > > > > > > > InstallationClassLoader.java :99)
> > > > > > > >         at
> > > > > > > >
> > > >
org.apache.servicemix.jbi.framework.InstallerMBeanImpl.createBootstrap
> > > > > > > (
> > > > > > > > InstallerMBeanImpl.java:84)
> > > > > > > >         at
> > > > org.apache.servicemix.jbi.framework.InstallerMBeanImpl.<init>(
> > > > > > >
> > > > > > > > InstallerMBeanImpl.java:74)
> > > > > > > >         at
> > > > > > > >
> > > > > > >
> > > >
> > >
> >
org.apache.servicemix.jbi.framework.InstallationService.initializeInstaller
> > > > > > > (
> > > > > > > > InstallationService.java:520)
> > > > > > > >         at
> > > > > > > >
> > > > > > >
> > > >
> > >
> >
org.apache.servicemix.jbi.framework.InstallationService.doInstallComponent
(
> > > > > > > > InstallationService.java:475)
> > > > > > > >         at
> > > > > > > >
> > > > > > >
> > > >
org.apache.servicemix.jbi.framework.InstallationService.doInstallArchive
> > > > > > > (
> > > > > > > > InstallationService.java:427)
> > > > > > > >         at
> > > > > > >
org.apache.servicemix.jbi.framework.InstallationService.install (
> > > > > > > > InstallationService.java:349)
> > > > > > > >         at
> > > > > > >
org.apache.servicemix.jbi.framework.InstallationService.install(
> > > > > > > > InstallationService.java:342)
> > > > > > > >         at
> > > > > > > >
> > > > > > >
> > > >
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(
> > > > > > > > AutoDeploymentService.java:220)
> > > > > > > >         at
> > > > > > >
org.apache.servicemix.jbi.framework.AutoDeploymentService$2.run(
> > > > > > > > AutoDeploymentService.java:507)
> > > > > > > >         at
org.apache.geronimo.connector.work.WorkerContext.run
> > (
> > > > > > > > WorkerContext.java:291)
> > > > > > > >         at
> > > > EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run
> > > > > > > (Unknown
> > > > > > > > Source)
> > > > > > > >         at java.lang.Thread.run(Thread.java:595)
> > > > > > > >
> > > > > > > > Any thoughts?
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>

Reply via email to