Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-3533

classpath problem with camel:dot and provided dependencies

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.0
    • 2.6.0
    • tooling
    • None
    • Running on linux, jdk 1.6. Looks irrelevant.

    • Patch Available

    Description

      camel:dot in is failing with a class not found exception when the application context instantiates a class in a jar with provided scope.

      If in your maven project you have:

      <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.5</version>
      <scope>provided</scope>
      </dependency>

      and in your application context there is, for example, a subclass of ServletContextListener, mvn camel:dot fails with:

      ...
      Caused by: java.lang.ClassNotFoundException:
      javax.servlet.ServletContextListener
      at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
      ... 92 more

      If you change it to:

      <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.5</version>
      <scope>compile</scope>
      </dependency>

      then camel-maven-plugin correctly generates the output. The fact is
      that the servlet-api jar must not be included in the final war.

      I don't know the correct way to fix this. One option would be to add the includePluginDependencies option in the plugin and add the provided jars as runtime dependencies of the plugin.

      The other, very easy to implement, option would be to change the requiresDependencyResolution from runtime to test.

      The third option would be to make the requiresDependencyResolution configurable.

      Attached is a patch for the 2nd option (lazy me).

      Attachments

        1. depends_on_test_classpath.txt
          0.5 kB
          Pablo Gra\~na

        Activity

          People

            njiang Willem Jiang
            gpablo Pablo Gra\~na
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: