title: Service Module Loader: java.lang.LinkageError [org.jboss.modules] Failed to define class
body: <p>I'm trying to use metrics for spring by Ryan Tenney on a JBoss server. I'm compiling with maven and everything goes smoothly in the compile, but when I try to run the app on the server, I get link  errors.</p>
  
  <p>Here are the things I've tried.</p>
  
  <ul>
  <li>Cleaning everything: project in eclipse, maven build, removed project from server</li>
  <li>Looked for double-linked dependencies, and resolved any</li>
  <li>Ensured that the correct jars are in the target folder (they are)</li>
  </ul>
  
  <p>Here's the stack trace I'm getting:</p>
  
  <pre><code>2013/09/23 10:40:40,909 WARN  [org.jboss.modules] Failed to define class com.ryantenney.metrics.spring.config.annotation.MetricsConfigurationSupport in Module "deployment.sampleapp.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link com/ryantenney/metrics/spring/config/annotation/MetricsConfigurationSupport (Module "deployment.sampleapp.war:main" from Service Module Loader)
          at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:396) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:243) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:73) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.Module.loadModuleClass(Module.java:527) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:182) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.3.GA]
          at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.7.0_11]
          at java.lang.ClassLoader.defineClass(ClassLoader.java:791) [rt.jar:1.7.0_11]
          at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) [rt.jar:1.7.0_11]
          at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:327) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:391) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:243) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:73) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.Module.loadModuleClass(Module.java:527) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:182) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.3.GA]
          at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_11]
          at java.lang.Class.forName(Class.java:264) [rt.jar:1.7.0_11]
          at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114) [rt.jar:1.7.0_11]
          at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125) [rt.jar:1.7.0_11]
          at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) [rt.jar:1.7.0_11]
          at sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:390) [rt.jar:1.7.0_11]
          at sun.reflect.annotation.AnnotationParser.parseClassValue(AnnotationParser.java:371) [rt.jar:1.7.0_11]
          at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:673) [rt.jar:1.7.0_11]
          at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:480) [rt.jar:1.7.0_11]
          at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:306) [rt.jar:1.7.0_11]
          at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:241) [rt.jar:1.7.0_11]
          at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:88) [rt.jar:1.7.0_11]
          at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70) [rt.jar:1.7.0_11]
          at java.lang.Class.initAnnotationsIfNecessary(Class.java:3089) [rt.jar:1.7.0_11]
          at java.lang.Class.getAnnotations(Class.java:3069) [rt.jar:1.7.0_11]
          at org.springframework.core.type.classreading.AnnotationAttributesReadingVisitor.visitEnd(AnnotationAttributesReadingVisitor.java:131) [spring-core-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.asm.ClassReader.a(Unknown Source) [spring-asm-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.asm.ClassReader.accept(Unknown Source) [spring-asm-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.asm.ClassReader.accept(Unknown Source) [spring-asm-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.core.type.classreading.SimpleMetadataReader.&lt;init&gt;(SimpleMetadataReader.java:54) [spring-core-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80) [spring-core-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:101) [spring-core-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:213) [spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:204) [spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84) [spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73) [spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1335) [spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1325) [spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135) [spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93) [spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493) [spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390) [spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) [spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) [spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) [spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) [spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) [spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124) [spring-web-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93) [spring-web-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130) [spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467) [spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397) [spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442) [spring-webmvc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458) [spring-webmvc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339) [spring-webmvc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306) [spring-webmvc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) [spring-webmvc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
          at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.1.Final.jar:1.0.1.Final]
          at com.example.infra.web.spring.DispatcherServlet.init(DispatcherServlet.java:321) [framework-core-3.2.0.jar:]
          at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.17.Final.jar:]
          at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.17.Final.jar:]
          at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655) [jbossweb-7.0.17.Final.jar:]
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:3873) [jbossweb-7.0.17.Final.jar:]
          at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:89) [jboss-as-web-7.1.3.Final.jar:7.1.3.Final]
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_11]
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_11]
          at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_11]
      Caused by: java.lang.NoClassDefFoundError: org/springframework/context/annotation/ImportAware
          at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.7.0_11]
          at java.lang.ClassLoader.defineClass(ClassLoader.java:791) [rt.jar:1.7.0_11]
          at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) [rt.jar:1.7.0_11]
          at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:327) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:391) [jboss-modules.jar:1.1.3.GA]
          ... 80 more
      Caused by: java.lang.ClassNotFoundException: org.springframework.context.annotation.ImportAware from [Module "deployment.sampleapp.war:main" from Service Module Loader]
          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.3.GA]
          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.3.GA]
          ... 85 more
  </code></pre>
  
  <p>Using metrics for spring version 3.0.0, maven version 3.0.3, JBoss 7.1</p>