public class SchedulePanelSource implements TestPanelSource {
@Dependency
private IMockScheduleService mockScheduleService;
public Panel getTestPanel(String panelId) { .. some code in
here .. }
}
I was getting serialization exceptions because mockScheduleService is
a non-serializable mock object. I decided to use Salve's @Dependency
annotation to fix this.
At this point I configured my application to use Salve and the
breakpoint in
SalveConfigurator.setApplicationContext(ApplicationContext context)
gets hit. However, SpringBeanLocator.locate(Key key) is never called
and mockScheduleService is never injected.
How can I fix this?
Thanks.
-igor
> --
> You received this message because you are subscribed to the Google Groups "Salve" group.
> To post to this group, send email to salve...@googlegroups.com.
> To unsubscribe from this group, send email to salve-disc+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/salve-disc?hl=en.
>
>
Any other ideas?
Thanks.
On Mar 21, 11:38 pm, Igor Vaynberg <igor.vaynb...@gmail.com> wrote:
> salve is a bytecode instrumentor. make sure that the instrumentors run
> either as an ide plugin (eclipse/ide) or as a maven2 plugin
>
> -igor
>
-igor
I also put the following Salve libraries on the classpath: salve-
agent-2.1-SNAPSHOT.jar, salve-depend-2.1-SNAPSHOT.jar, salve-depend-
inst-2.1-SNAPSHOT.jar, salve-depend-spring-2.1-SNAPSHOT.jar, salve-
inst-2.1-SNAPSHOT.jar and salve-depend-spring-inst-2.1-SNAPSHOT.jar.
I added the following code to extract field value using reflection and
it prints out null for the field value.
public class SchedulePanelSource implements TestPanelSource
{
private final Schedule schedule;
@Dependency
private IMockScheduleService mockScheduleService;
@Override
public Panel getTestPanel(String panelId) {
Field[] fieldlist = getClass().getDeclaredFields();
for (Field field : fieldlist) {
try {
final Object fieldValue = field.get(this);
Logger.getLogger(this.getClass().getName()).info(field.getName() + " =
" + fieldValue); // THIS PRINTS NULL FOR fieldValue
} catch (IllegalArgumentException ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null,
ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null,
ex);
}
}
return new SchedulePanel(panelId);
}
}
On Mar 22, 1:07 am, Igor Vaynberg <igor.vaynb...@gmail.com> wrote:
> there is an easy way to check if the classes are being instrumented,
> make a method that tries to retrieve the @dependency field via
> reflection. if the field is still there the class is not instrumented.
> make sure salve2.xml is configured properly, see examples in the wiki.
>
> -igor
>
-igor
I noticed that no errors are logged or exceptions thrown if I delete
salve2.xml altogether. Does Salve java agent log anything if it's
unable to find salve2.xml? If so, how can I enable that logging?
Thanks,
Alec
On Mar 22, 11:20 pm, Igor Vaynberg <igor.vaynb...@gmail.com> wrote:
> the fact that the field is still there means salve instrumentors did
> not instrument your class. so it is either that salve2.xml does not
> have the right package and is skipping your classes, or the jvm agent
> is not running for the classloader
>
> -igor
>
> On Mon, Mar 22, 2010 at 8:44 AM, alecswan <alecs...@gmail.com> wrote:
> > I made sure that META-INF/salve2.xml is on the classpath. BTW, you may
> > want to updatehttp://code.google.com/p/salve/wiki/ConfiguringInstrumentation2
-igor
NetBeans does not seem to have a separate instrumenting plugin, but it
does allow me to specify VM options used when running "main classes
and unit tests".
@Dependency annotation doesn't seem to work for me when running the
web app in Tomcat after adding -javaagent VM option to Tomcat startup
parameters.
Alec
On Mar 23, 9:35 am, Igor Vaynberg <igor.vaynb...@gmail.com> wrote:
> can you try instrumenting using maven or an ide plugin to make sure
> your configuration is correct.
>
> -igor
>
The classes that have @Dependency-annotated fields are in sub-packages
of com.galecsy.lrm.
Could you confirm that I am not missing any Salve libraries on the
classpath: salve-
agent-2.1-SNAPSHOT.jar, salve-depend-2.1-SNAPSHOT.jar, salve-depend-
inst-2.1-SNAPSHOT.jar, salve-depend-spring-2.1-SNAPSHOT.jar, salve-
inst-2.1-SNAPSHOT.jar and salve-depend-spring-inst-2.1-SNAPSHOT.jar
By the way, I am using @Dependency annotation as suggested by your
code on this page http://wicketinaction.com/2008/09/building-a-smart-entitymodel/
Any ideas on how to troubleshoot this further?
Thanks,
Alec
Now I am trying to deploy the web app in Tomcat and getting
java.lang.NoClassDefFoundError: salve/InstrumentationException.
I tried copying some Salve jars (including salve-inst) to TOMCAT/lib
and TOMCAT/common/lib, but that didn't fix the problem. Is there a
wiki page which explains where to put Salve jars in Tomcat?
Thanks,
Alec
On Mar 23, 2:27 pm, alecswan <alecs...@gmail.com> wrote:
> I put a breakpoint in salve.agent.Transformer.mergeConfigs(..) and was
> able to verify that META-INF/salve2.xml is picked up correctly.
> The content of salve2.xml is as follows:
> <config>
> <packages>
> <package>
> <name>com.galecsy.lrm</name>
> <instrumentors>
> <salve.depend.DependencyInstrumentor/>
> </instrumentors>
> </package>
> </packages>
> </config>
>
> The classes that have @Dependency-annotated fields are in sub-packages
> of com.galecsy.lrm.
>
> Could you confirm that I am not missing any Salve libraries on the
> classpath: salve-
> agent-2.1-SNAPSHOT.jar, salve-depend-2.1-SNAPSHOT.jar, salve-depend-
> inst-2.1-SNAPSHOT.jar, salve-depend-spring-2.1-SNAPSHOT.jar, salve-
> inst-2.1-SNAPSHOT.jar and salve-depend-spring-inst-2.1-SNAPSHOT.jar
>
> By the way, I am using @Dependency annotation as suggested by your
> code on this pagehttp://wicketinaction.com/2008/09/building-a-smart-entitymodel/
Any ideas? Thanks.
Using CATALINA_BASE: C:\Program Files\Apache Software Foundation
\apache-tomcat-6.0.20
Using CATALINA_HOME: C:\Program Files\Apache Software Foundation
\apache-tomcat-6.0.20
Using CATALINA_TMPDIR: C:\Program Files\Apache Software Foundation
\apache-tomcat-6.0.20\temp
Using JRE_HOME: C:\Program Files\Java\jdk1.6.0_11
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:
323)
at
sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:
338)
FATAL ERROR in native method: processing of -javaagent failed
Caused by: java.lang.NoClassDefFoundError: salve/
InstrumentationException
at salve.agent.Agent.newTransformer(Agent.java:36)
at salve.agent.Agent.premain(Agent.java:43)
... 6 more
Caused by: java.lang.ClassNotFoundException:
salve.InstrumentationException
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:
301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:
320)
... 8 more
Exception in thread "main"
-igor
In one of the messages on the Wicket mailing list it sounded like you
were using Salve in your webapp. How did you configure it?
Thanks.
-igor
Could you also explain how you instrument your WAR files and compile
time? Is there an Ant task I can use for this?
Thanks
Mar 25, 2010 9:16:43 AM org.apache.catalina.core.StandardContext
listenerStart
SEVERE: Exception sending context initialized event to listener
instance of class
org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.CannotLoadBeanClassException: Error
loading class [salve.depend.spring.SalveConfigurator] for bean with
name 'salve.depend.spring.SalveConfigurator#0' defined in
ServletContext resource [/WEB-INF/config/lrm-service.xml]: problem
with class file or dependent class; nested exception is
java.lang.NoClassDefFoundError: org/springframework/context/
ApplicationContextAware
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:
1144)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:
524)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:
1177)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:
758)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:
422)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:
728)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:
380)
at
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:
255)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:
199)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:
45)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:
3934)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:
4429)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
791)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
771)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
at
org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:
630)
at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:514)
at
org.apache.catalina.startup.HostConfig.check(HostConfig.java:1288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
Mar 25, 2010 9:16:43 AM org.apache.catalina.core.StandardContext
listenerStart
SEVERE: Exception sending context initialized event to listener
instance of class
org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.CannotLoadBeanClassException: Error
loading class [salve.depend.spring.SalveConfigurator] for bean with
name 'salve.depend.spring.SalveConfigurator#0' defined in
ServletContext resource [/WEB-INF/config/lrm-service.xml]: problem
with class file or dependent class; nested exception is
java.lang.NoClassDefFoundError: org/springframework/context/
ApplicationContextAware
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:
1144)
at
org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:
297)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:
524)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:
1177)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:
758)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:
836)
at
com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
at
org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:
1473)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:
422)
at
org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:
824)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:
728)
at
org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:
350)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:
617)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:
380)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:
717)
at
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:
255)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:
199)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
290)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:
45)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
206)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:
3934)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
233)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:
4429)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
191)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
791)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:
525)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
771)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
128)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
109)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
293)
at
org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:
630)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
849)
at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:514)
at org.apache.coyote.http11.Http11Protocol
$Http11ConnectionHandler.process(Http11Protocol.java:583)
at
org.apache.catalina.startup.HostConfig.check(HostConfig.java:1288)
at org.apache.tomcat.util.net.JIoEndpoint
$Worker.run(JIoEndpoint.java:454)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.lang.Thread.run(Thread.java:619)
On Mar 24, 9:50 pm, Igor Vaynberg <igor.vaynb...@gmail.com> wrote:
> i use it on quiet a few projects, but i do not use the jvm agent. i
> instrument the code at build time and include the jars in web-inf/lib.
> never had a problem like this. dont see why tomcat would not be able
> to find the jar. maybe try also putting them into tomcat/endorsed?
>
> -igor
>
> On Wed, Mar 24, 2010 at 8:20 PM, alecswan <alecs...@gmail.com> wrote:
> > All Salve jars are in WEB-INF/lib as well as CATALINA/lib.
>
> > In one of the messages on the Wicket mailing list it sounded like you
> > were using Salve in your webapp. How did you configure it?
>
> > Thanks.
>
> > Igor Vaynberg wrote:
> >> make sure salve-inst.jar is also available inside the war, maybe that
> >> will help. i havent tried tomcat with java agent myself.
>
> >> -igor
>
> ...
>
> read more »
java.lang.NoClassDefFoundError: org/springframework/context/
ApplicationContextAware
i use maven2 plugin to instrument at compile time, and eclipse plugin
to do it when im developing.
-igor
Which maven target does Salve instrumentation?
As a side note, I think it is important to figure out runtime
instrumentation in Tomcat, because it will slow down Salve adoption
otherwise.
Thanks,
Alec
On Mar 25, 9:34 am, Igor Vaynberg <igor.vaynb...@gmail.com> wrote:
> looks like it cannot see your spring jar
>
> java.lang.NoClassDefFoundError: org/springframework/context/
> ApplicationContextAware
>
> i use maven2 plugin to instrument at compile time, and eclipse plugin
> to do it when im developing.
>
> -igor
>
> ...
>
> read more »
since salve's loader is loaded using tomcat's classloader and not the
one used for your war file none of those classes can see the classes
inside your war. im not really sure what to do about this, i did test
the jvm agent with tomcat a while back, but i dont remember hitting
any of these issues. try with salve 1.1 and see if you hit the same
problem.
there are examples on how to configure the maven plugin on the wiki, i
dont remember the exact phase it kicks in.
-igor
I think glassbox.install.dir is required in order to avoid problems
with loading classes I am running into with Salve. Do you have
anything like this in Salve?
Thanks.
Alec
On Mar 25, 10:18 am, Igor Vaynberg <igor.vaynb...@gmail.com> wrote:
> i think the problem you are hitting is this:
>
> since salve's loader is loaded using tomcat's classloader and not the
> one used for your war file none of those classes can see the classes
> inside your war. im not really sure what to do about this, i did test
> the jvm agent with tomcat a while back, but i dont remember hitting
> any of these issues. try with salve 1.1 and see if you hit the same
> problem.
>
> there are examples on how to configure the maven plugin on the wiki, i
> dont remember the exact phase it kicks in.
>
> -igor
>
> ...
>
> read more »
-igor
On Mar 25, 3:00 pm, Igor Vaynberg <igor.vaynb...@gmail.com> wrote:
> no, like i said when i tried it i didnt run into the problems you
> mention. have you tried with 1.1 yet?
>
> -igor
>
> ...
>
> read more »
-igor
This is what I tried next:
1. Put all Salve-1.x jars in WEB-INF/lib and pointed javaagent to
salve-agent-1.2-SNAPSHOT.jar. The following exception was thrown:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Instrumenta
tionImpl.java:323)
at
sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Instrument
ationImpl.java:338)
Caused by: java.lang.NoClassDefFoundError: salve/
InstrumentationException
at salve.agent.Agent.newTransformer(Agent.java:36)
at salve.agent.Agent.premain(Agent.java:43)
... 6 more
Caused by: java.lang.ClassNotFoundException:
salve.InstrumentationException
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:
301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:
320)
... 8 more
FATAL ERROR in native method: processing of -javaagent failed
2. Copied salve-inst-1.2-SNAPSHOT.jar jars in tomcat/endorsed.
Application started up, but no instrumentation was done.
3. Copied all Salve-1.x in tomcat/endorsed.
4. I realized that Salve may not be finding salve.xml and put it in
tomcat/lib/web-inf. This caused the code to get instrumented, but I
got the following error when accessing a Wicket page that used
@Dependency annotation.
Caused by: java.lang.NoClassDefFoundError: org/springframework/context/
ApplicationContext
at
salve.depend.spring.SpringBeanLocator.locate(SpringBeanLocator.java:
68)
at salve.depend.DependencyLibrary.locate(DependencyLibrary.java:99)
5. I realized that I get the above exception because salve-depend-
spring-XXX jars are loaded as a part of the endorsed libraries and
Spring is bundled in my WAR and hence are not visible to salve-depend-
spring-XXX jars. So, I moved salve-depend-spring-XXX jars from
endorsed to my WEB-INF/lib and I was able to access the Wicket page.
Sorry for such a detailed description, I just wasn't sure if I will
get it to work or not.
So, here is the final Tomcat configuration:
1. JAVA_OPTS="-javaagent:C:\lib\salve-agent-1.2-SNAPSHOT.jar"
2. Tomcat/endorsed contains all Salve jars except salve-depend-spring-
XXX jars.
3. Tomcat/lib/META-INF contains salve.xml.
4. WEB-INF/lib contains salve-depend-spring-XXX jars and other Salve
jars, which is probably redundant.
I am sure I could move some jars around to achieve a minimal
configuration. Maybe later.
So, now I will try to switch back to Salve-2.x.
Thanks,
Alec
On Mar 25, 8:40 pm, Igor Vaynberg <igor.vaynb...@gmail.com> wrote:
> yes.
>
> -igor
>
> ...
>
> read more »
-igor
I am not very happy with the setup complexity involved in deployment
time instrumentation and would like to try and instrument my classes
at compile time.
I am using NetBeans and Ant. Could you provide any guidelines on how
to get it to work with Ant?
Thanks.
On Mar 26, 5:37 pm, Igor Vaynberg <igor.vaynb...@gmail.com> wrote:
> nice, let me know how it goes
>
> -igor
>
> ...
>
> read more »
-igor
-igor
-igor
the one area where salve 2.0 is better then 3.0 is that you can access
private fields of outer class from an inner class. in salve 3.0 this
access is not instrumented because aspectj does not instrument
synthetic methods and this is what the compiler uses to create a
getter for the private field that the inner class uses to get the
value.
if you can create a testcase that reproduces your problem that is even
better. keep in mind that while i think everything in 3.0 works i
havent had a chance to use it in production yet (still on 2.0). but
there are plenty of unit tests there.
-igor
-igor
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: Person.addresses, no session or session was closed