How to add spring javaagent to the fuse jsvm?
oren Aug 6, 2009 2:36 PMHello all,
How do I add the spring-agent.jar to my FUSE ESB 4.1.0.2 JVM, so that bundles can use load-time weaving?
My Cygwin start up shell looks like that:
-
#!/bin/bash
...
Debug mode. Hook in an eclipse debugger on port 5005 when the following variable is set.
export SERVICEMIX_DEBUG=true
Enable load-time weaving and other memory options in the bus
export JAVA_OPTS="$JAVA_OPTS -javaagent:/path/to/my/spring-agent.jar"
echo $JAVA_OPTS
bin/servicemix.bat $1
-
Upon running the script, I get
$ sm
-XX:MaxPermSize=256m -Xms256m -Xmx1000m -Dprof=win -DdownloadSources=true -javaa
gent:c:\further\tools\lib\spring-agent.jar
servicemix.bat: Enabling Java debug options: -Xdebug -Xnoagent -Djava.compiler=N
ONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
Listening for transport dt_socket at address: 5005
... which looks fine. However, when I start a bundle that uses <context:load-time-weaver/> in its spring context, I see the error message
smx@root:osgi> Exception in thread "SpringOsgiExtenderThread-67" org.springframe
work.beans.factory.BeanCreationException: Error creating bean with name 'loadTim
eWeaver': Initialization of bean failed; nested exception is java.lang.IllegalSt
ateException: ClassLoader [org.springframework.osgi.util.BundleDelegatingClassLo
ader] does NOT provide an 'addTransformer(ClassFileTransformer)' method. Specify
a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent:
-javaagent:spring-agent.jar
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finish
BeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp
plicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:6
8)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp
plicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:343)
at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCus
tomTCCL(PrivilegedUtils.java:85)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp
plicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.ja
va:308)
at org.springframework.osgi.extender.internal.dependencies.startup.Depen
dencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterAp
plicationContextExecutor.java:138)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.IllegalStateException: ClassLoader [org.springframework.osg
i.util.BundleDelegatingClassLoader] does NOT provide an 'addTransformer(ClassFil
eTransformer)' method. Specify a custom LoadTimeWeaver or start your Java virtua
l machine with Spring's agent: -javaagent:spring-agent.jar
at org.springframework.context.weaving.DefaultContextLoadTimeWeaver.setB
eanClassLoader(DefaultContextLoadTimeWeaver.java:82)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1322)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
... 16 more
which indicates that spring-agent is not found.