ClassNotFoundException for maven provided dependencies

Peter

I have a web application that depends on another maven project that has some provided dependencies in its pom file.

<dependency>
    <groupId>org.codehaus.jackson</groupId>
    <artifactId>jackson-mapper-asl</artifactId>
    <version>1.9.12</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>org.codehaus.jackson</groupId>
    <artifactId>jackson-jaxrs</artifactId>
    <version>1.9.12</version>
    <scope>provided</scope>
</dependency>

When I deploy my war to JBoss, I get ClassNotFoundExceptions for JsonSerializer and Deserializer which are in the jackson-mapper-asl jar.

Caused by: java.lang.ClassNotFoundException: org.codehaus.jackson.map.JsonDeserializer from [Module "deployment.biz.modit.tit.gop.education.teacherportlets.createtest-0.0.1-SNAPSHOT.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]
... 26 more

If I'm not mistaken provided means that the runtime or in my case application server will provide the jar. The jackson-mapper-asl jar is installed on the JBoss server as a module. I thought the problem was caused by mismatching version numbers but updating the jars in the jboss modules and updating the module.xml-s didn't help. I tried deploying it copying it into the deployments folder because it helped before with the ojdbc driver but that didn't help either. Could you suggest something?

Shreyos Adikari

Change <scope>provided</scope> to <scope>compile</scope>.

Compile -This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.

Provided - This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.

Refer http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Maven provided dependencies

From Dev

Why aren't 'provided' Maven dependencies 'transitive'?

From Dev

Maven - import transitively provided dependencies into project

From Dev

How to copy provided Maven dependencies into a chosen directory?

From Dev

Maven assembly plugin: how to include provided dependencies of transitive dependencies

From Dev

Maven assembly plugin: how to include provided dependencies of transitive dependencies

From Dev

Maven: How to have jar-with-dependencies exclude "provided" dependencies?

From Dev

How to create maven uber jar which includes dependencies with scope provided

From Dev

Intellij doesn't add maven provided scoped dependencies to the classpath

From Dev

How do I filter resources provided by dependencies in Maven?

From Dev

How to exclude transitive dependencies with scope provided with maven-assembly-plugin?

From Dev

Gradle provided dependencies with Intellij

From Dev

How to get specific version dependencies jars from maven artifactory repository who has "Provided" scope

From Dev

Should jars have "provided" dependencies?

From Dev

Eclipse bundling provided dependencies into apk

From Dev

Maven: optional provided scope?

From Dev

Maven: optional provided scope?

From Dev

Maven exec plugin ClassNotFoundException

From Dev

ClassNotFoundException with Maven and Java

From Dev

Maven compile cause ClassNotFoundException

From Dev

Maven build failure classNotFoundException

From Dev

Maven exec plugin ClassNotFoundException

From Dev

ClassNotFoundException in maven project of spring

From Dev

Maven + Tycho, adding Maven dependencies

From Dev

Maven (commandline): No compiler is provided in this environment

From Dev

Random "No compiler provided" error Maven

From Dev

Maven: multiple versions for provided dependency

From Dev

Maven + Tycho: unresolved dependencies

From Dev

Maven resolving versions of dependencies

Related Related

  1. 1

    Maven provided dependencies

  2. 2

    Why aren't 'provided' Maven dependencies 'transitive'?

  3. 3

    Maven - import transitively provided dependencies into project

  4. 4

    How to copy provided Maven dependencies into a chosen directory?

  5. 5

    Maven assembly plugin: how to include provided dependencies of transitive dependencies

  6. 6

    Maven assembly plugin: how to include provided dependencies of transitive dependencies

  7. 7

    Maven: How to have jar-with-dependencies exclude "provided" dependencies?

  8. 8

    How to create maven uber jar which includes dependencies with scope provided

  9. 9

    Intellij doesn't add maven provided scoped dependencies to the classpath

  10. 10

    How do I filter resources provided by dependencies in Maven?

  11. 11

    How to exclude transitive dependencies with scope provided with maven-assembly-plugin?

  12. 12

    Gradle provided dependencies with Intellij

  13. 13

    How to get specific version dependencies jars from maven artifactory repository who has "Provided" scope

  14. 14

    Should jars have "provided" dependencies?

  15. 15

    Eclipse bundling provided dependencies into apk

  16. 16

    Maven: optional provided scope?

  17. 17

    Maven: optional provided scope?

  18. 18

    Maven exec plugin ClassNotFoundException

  19. 19

    ClassNotFoundException with Maven and Java

  20. 20

    Maven compile cause ClassNotFoundException

  21. 21

    Maven build failure classNotFoundException

  22. 22

    Maven exec plugin ClassNotFoundException

  23. 23

    ClassNotFoundException in maven project of spring

  24. 24

    Maven + Tycho, adding Maven dependencies

  25. 25

    Maven (commandline): No compiler is provided in this environment

  26. 26

    Random "No compiler provided" error Maven

  27. 27

    Maven: multiple versions for provided dependency

  28. 28

    Maven + Tycho: unresolved dependencies

  29. 29

    Maven resolving versions of dependencies

HotTag

Archive