NoSuchMethodError when calling 'context.addModelsForPackage()

Description

The problem is whenever code comes across following snippet i am running into a exception:

aemContext.addModelsForPackage("com.company.guidedtour.services.models.components.content.general");

java.lang.NoSuchMethodError: org.apache.sling.models.annotations.Model.adapters()[Ljava/lang/Class;
at org.apache.sling.models.impl.ModelPackageBundleListener.addingBundle(ModelPackageBundleListener.java:103)
at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:467)
at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:414)
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:443)
at org.apache.sling.testing.mock.osgi.MockBundleContext.sendBundleEvent(MockBundleContext.java:277)
at org.apache.sling.testing.mock.osgi.MockOsgi.sendBundleEvent(MockOsgi.java:58)
at org.apache.sling.testing.mock.sling.context.ModelAdapterFactoryUtil.addModelsForPackage(ModelAdapterFactoryUtil.java:59)
at org.apache.sling.testing.mock.sling.context.SlingContextImpl.addModelsForPackage(SlingContextImpl.java:302)
at com.company.services.models.components.content.general.TourSlidesComponentUseTest.setUp(TourSlidesComponentUseTest.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.internal.runners.MethodRoadie.runBefores(MethodRoadie.java:133)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:96)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:294)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:127)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.access$100(PowerMockJUnit47RunnerDelegateImpl.java:59)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner$LastRuleTestExecutorStatement.evaluate(PowerMockJUnit47RunnerDelegateImpl.java:148)
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:91)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:282)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:50)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:122)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:106)
at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Following the output of mvn dependency:tree -s=../settings.xml
[INFO] Scanning for projects...
Downloading: http://nexusprod:8080/nexus/content/repositories/snapshots/com/sforce/cd/CD-parent/1.0.3-SNAPSHOT/maven-metadata.xml
Downloaded: http://nexusprod:8080/nexus/content/repositories/snapshots/com/sforce/cd/CD-parent/1.0.3-SNAPSHOT/maven-metadata.xml (599 B at 1.2 KB/sec)
Downloading: http://nexusprod:8080/nexus/content/repositories/snapshots/org/com.company.aemapache/maven/plugins/maven-deploy-plugin/maven-metadata.xml
Downloading: http://nexusprod:8080/nexus/content/groups/public/org/apache/maven/plugins/maven-deploy-plugin/maven-metadata.xml
Downloading: http://nexusprod:8080/nexus/content/repositories/releases/org/apache/maven/plugins/maven-deploy-plugin/maven-metadata.xml
Downloaded: http://nexusprod:8080/nexus/content/groups/public/org/apache/maven/plugins/maven-deploy-plugin/maven-metadata.xml (704 B at 6.7 KB/sec)
Downloading: http://nexusprod:8080/nexus/content/repositories/snapshots/org/apache/maven/plugins/maven-enforcer-plugin/maven-metadata.xml
Downloading: http://nexusprod:8080/nexus/content/repositories/releases/org/apache/maven/plugins/maven-enforcer-plugin/maven-metadata.xml
Downloading: http://nexusprod:8080/nexus/content/groups/public/org/apache/maven/plugins/maven-enforcer-plugin/maven-metadata.xml
Downloaded: http://nexusprod:8080/nexus/content/groups/public/org/apache/maven/plugins/maven-enforcer-plugin/maven-metadata.xml (797 B at 8.7 KB/sec)
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building com.company.aem - company-services 2.0.4-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] — maven-dependency-plugin:2.8:tree (default-cli) @ project-services —
[INFO] com.company.aemroject-services:bundle:2.0.4-SNAPSHOT
[INFO] +- org.apache.sling:org.apache.sling.models.api:jar:1.1.0rovided
[INFO] +- org.apache.sling:org.apache.sling.models.impl:jar:1.1.0rovided
[INFO] | - commons-beanutils:commons-beanutils:jar:1.8.3rovided
[INFO] | - commons-logging:commons-logging:jar:1.1.1rovided
[INFO] +- org.apache.sling:org.apache.sling.api:jar:2.9.0rovided
[INFO] +- org.apache.sling:org.apache.sling.jcr.jcr-wrapper:jar:2.0.0rovided
[INFO] +- org.apache.jackrabbit:jackrabbit-jcr-commons:jar:2.8.0rovided
[INFO] +- javax.inject:javax.inject:jar:1rovided
[INFO] +- com.adobe.aem:uber-jar:jar:apis:6.1.0rovided
[INFO] +- com.company.aem:company-master-services:jar:2.0.3rovided
[INFO] +- org.apache.felix:org.apache.felix.framework:jar:4.4.1:compile
[INFO] +- org.apache.felix:org.apache.felix.scr.annotations:jar:1.9.6rovided
[INFO] +- org.osgi:org.osgi.core:jar:4.2.0rovided
[INFO] +- org.slf4j:slf4j-api:jar:1.6.4rovided
[INFO] +- com.google.code.gson:gson:jar:2.3:test
[INFO] +- org.mockito:mockito-all:jar:1.10.19:test
[INFO] +- io.wcm:io.wcm.testing.aem-mock:jar:1.5.0:test
[INFO] | +- org.apache.sling:org.apache.sling.testing.jcr-mock:jar:1.1.10:test
[INFO] | | - javax.jcr:jcr:jar:2.0rovided
[INFO] | +- org.apache.sling:org.apache.sling.testing.sling-mock:jar:1.6.0:test
[INFO] | | +- org.apache.sling:org.apache.sling.resourceresolver:jar:1.2.6:test
[INFO] | | | - org.apache.sling:org.apache.sling.serviceusermapper:jar:1.0.0:test
[INFO] | | +- org.apache.sling:org.apache.sling.jcr.api:jar:2.2.0:test
[INFO] | | +- org.apache.sling:org.apache.sling.commons.mime:jar:2.1.8:test
[INFO] | | +- org.apache.sling:org.apache.sling.commons.json:jar:2.0.6:test
[INFO] | | +- org.apache.sling:org.apache.sling.commons.classloader:jar:1.3.0:test
[INFO] | | +- org.apache.sling:org.apache.sling.settings:jar:1.2.2:test
[INFO] | | +- org.apache.sling:org.apache.sling.i18n:jar:2.2.4:test
[INFO] | | +- commons-collections:commons-collections:jar:3.2.1:test
[INFO] | | +- commons-lang:commons-lang:jar:2.5:test
[INFO] | | +- org.reflections:reflections:jar:0.9.9:test
[INFO] | | | +- org.javassist:javassist:jar:3.18.2-GA:test
[INFO] | | | - com.google.code.findbugs:annotations:jar:2.0.1:test
[INFO] | | - org.mortbay.jetty:servlet-api:jar:3.0.20100224:test
[INFO] | +- org.apache.sling:org.apache.sling.testing.resourceresolver-mock:jar:1.1.10:test
[INFO] | +- io.wcm:io.wcm.testing.junit-commons:jar:1.0.4:test
[INFO] | +- com.day.commons:day-commons-gfx:jar:2.1.28:test
[INFO] | | - com.day.commons:day-commons-any:jar:2.0.0:test
[INFO] | | - com.day.commons:day-commons-text:jar:1.1.3:test
[INFO] | +- com.adobe.aem:aem-api:jar:6.0.0.1:test
[INFO] | - org.slf4j:slf4j-simple:jar:1.7.5:test
[INFO] +- org.hamcrest:hamcrest-all:jar:1.3:test
[INFO] +- junit-addons:junit-addons:jar:1.4:test
[INFO] | +- xerces:xercesImpl:jar:2.6.2:test
[INFO] | - xerces:xmlParserAPIs:jar:2.6.2:test
[INFO] +- junit:junit:jar:4.12:test
[INFO] | - org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.powermockowermock-module-junit4:jar:1.6.2:test
[INFO] | - org.powermockowermock-module-junit4-common:jar:1.6.2:test
[INFO] | +- org.powermockowermock-core:jar:1.6.2:test
[INFO] | - org.powermockowermock-reflect:jar:1.6.2:test
[INFO] | - org.objenesis:objenesis:jar:2.1:test
[INFO] +- org.powermockowermock-api-mockito:jar:1.6.2:test
[INFO] | - org.powermockowermock-api-support:jar:1.6.2:test
[INFO] +- org.powermockowermock-api-easymock:jar:1.6.2:test
[INFO] | - cglib:cglib-nodep:jar:2.2.2:test
[INFO] +- org.apache.sling:org.apache.sling.jcr.resource:jar:2.5.4:test
[INFO] +- org.apache.sling:org.apache.sling.testing.osgi-mock:jar:1.7.2:test
[INFO] | +- org.osgi:org.osgi.compendium:jar:4.1.0:test
[INFO] | +- org.apache.sling:org.apache.sling.commons.osgi:jar:2.2.0:test
[INFO] | +- org.apache.commons:commons-lang3:jar:3.0.1rovided
[INFO] | - commons-io:commons-io:jar:2.4:test
[INFO] +- com.google.guava:guava:jar:15.0:test
[INFO] +- ch.qos.logback:logback-classic:jar:1.0.10:test
[INFO] | - ch.qos.logback:logback-core:jar:1.0.10:test
[INFO] - org.testng:testng:jar:6.8.7:test
[INFO] +- org.beanshell:bsh:jar:2.0b4:test
[INFO] +- com.beust:jcommander:jar:1.27:test
[INFO] - org.yaml:snakeyaml:jar:1.12:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.401 s
[INFO] Finished at: 2016-02-25T10:15:30-08:00
[INFO] Final Memory: 20M/377M
[INFO] ------------------------------------------------------------------------

Activity

Show:
Stefan Seifert
February 26, 2016, 8:56 AM

no problem - glad you could solve it

D
February 25, 2016, 11:09 PM

Please close this issue, looks like this is issue with with my local build.

Cannot Reproduce

Assignee

Unassigned

Reporter

D

Labels

None

Components

Priority

Major