-1

Synopsis: I am trying to add around advice to my domain model, but my app won't deploy to tomcat because of an odd verification error.

Constraints: LTW is not an option here, so I'm using the aspectj-maven-plugin to provide CTW.

I am using IntelliJ-Idea and I'm deploying an exploded war, which I build on the command-line using maven (mvn clean install -DskipTests). I have disabled IntelliJ's automatic make, so the only compilation that's happening is through the command line.

When I deploy my application I get the following stacktrace:

java.lang.VerifyError: (class: org/chaosengineers/ddd/services/PersistenceService, method: persistNewWord signature: (Ljava/lang/String;)Lorg/chaosengineers/ddd/photons/WordStorePhoton;) Incompatible argument to function
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2398)
    at java.lang.Class.getDeclaredConstructors(Class.java:1838)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:230)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:972)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:945)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:910)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:853)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:768)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:795)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:723)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:196)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1045)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:949)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:910)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:853)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:768)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:795)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:723)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:196)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1045)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:949)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
    at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1553)
    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 org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:762)
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:622)
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:569)
    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 org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:762)
    at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1454)
    at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:74)
    at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1295)
    at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1387)
    at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:818)
    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.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:303)
    at sun.rmi.transport.Transport$1.run(Transport.java:159)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:680)
Software Engineer
  • 15,457
  • 7
  • 74
  • 102

3 Answers3

0

A VerifyError can be a result of a different library version found in classpath than used for compilation. Please check if this might be the case with any of your libraries including aspectjrt.jar, but also others. There is no AspectJ stuff in your callstack, so maybe it is not related to that at all.

P.S.: (off-topic) What is the reason to use such an outdated AspectJ version?

kriegaex
  • 63,017
  • 15
  • 111
  • 202
  • The error isn't coming from a library, it's from one of my own classes, which, like I said, I'm compiling once using maven and deploying in exploded form using intellij. – Software Engineer Jun 13 '13 at 14:07
  • I'm using the maven aspectj plugin, and it uses the older version of aspectj. I'm not sure it's that outdated -- it's only a minor version old. – Software Engineer Jun 13 '13 at 16:06
  • Why are you downvoting my answer? I still think it might be correct. Or prove the opposite, please. – kriegaex Jun 13 '13 at 18:42
  • Sorry @kriegaex, both my comments (above) were directed at your answer. The stacktrace clearly shows that the error is being produced by one of my own classes (org.chaosengineers -- the class definition is available via the source link). And, I clearly say that I'm compiling the code once, via maven, and deploying it in place (as an exploded war) via intellij without further compilation. Therefore, it cannot possibly be a simple versioning problem. I downvoted the answer because it's not a possible explanation, given the question. – Software Engineer Jun 14 '13 at 22:04
0

It actually looks like a spring configuration error. What is happening is spring is trying to wire the bean and is unable to find a constructor that fits.

It looks like it is trying to auto wire up PersistenceService. I think it is expecting a String but instead it is getting a WordStorePhoton. (or the other way around).

(class: org/chaosengineers/ddd/services/PersistenceService, method: persistNewWord signature: (Ljava/lang/String;)Lorg/chaosengineers/ddd/photons/WordStorePhoton;)

I would recommend instead of using @autowire for this particular bean, quickly create a spring config file and define the bean explicitly.

But it is definitely Spring causing the error. It's trying to create the bean and can't find the right constructor.

Eric
  • 1,023
  • 1
  • 15
  • 27
  • Thanks @Eric, I've just tried this but it made no difference at all. I'm interested though in why you think it's a spring/constructor problem? I'm interested because that was the exact nature of the previous problem that I solved by putting an [at]Component annotation on the aspect. – Software Engineer Jun 15 '13 at 02:33
  • @EngineerDollery, When I read the stack trace, Spring is failing on the Autowire. So when it autowires, it uses reflection to find a constructor for the class, which you can see at the top of your stacktrace. And while in your case, it appears that it found constructors, it couldn't find a match by signature, and thus the error you were seeing. – Eric Jun 15 '13 at 21:44
  • @EngineerDollery, Regarding interfaces: ah, I think I had assumed that you were using interfaces. That is fairly standard practices when using DI. This SO question is partially helpful http://stackoverflow.com/questions/12899372/spring-why-do-we-autowire-the-interface-and-not-the-implemented-class But when using DI, you really do want to use Interfaces because that gives you the power to swap implementations at runtime, which is one of the biggest benefits of DI. – Eric Jun 15 '13 at 21:48
  • Yes, of course you're right. The problem it turned out wasn't in my real system. I'd thrown together a quick prototype ('toy') system to learn how to configure the CTW without the hassle involved in doing that in my day-job system, and of course I'd cut corners without thinking because real engineering 'rigor' wasn't necessary :) Thanks for the help. – Software Engineer Jun 15 '13 at 22:12
0

Ok, after days of hard work I think I've found the correct answer. The problem went away when I introduced interfaces for my services. Therefore, I think the compiler (either javac or ajc, but most likely the latter) was corrupting the vtable in the bytecode, but the introduction of the interface somehow corrected the problem. I haven't gone as far as decompiling the bytecode to prove this is what actually happened, but the fact remains that introducing an interface fixed the issue.

Software Engineer
  • 15,457
  • 7
  • 74
  • 102