sens2010 / run-jetty-run

Automatically exported from code.google.com/p/run-jetty-run
0 stars 0 forks source link

Plugin deploys wrong maven dependency #171

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
We have the following maven project structure:

- Project A has a dependency to project B version 0.0.2-SNAPSHOT
- Project A has a dependency to project C version 0.0.1
- Project C has a dependency to project B version 0.0.1

Project B is inside the eclipse workspace and using the m2eclipse plugin and 
workspace resolution, eclipse does resolve the correct version (0.0.2-SNAPSHOT) 
 during compilation.

However, if Project A is deployed to jetty using the run-jetty-run plugin it 
will load dependency "project B" in version 0.0.1, and not 0.0.2-SNAPSHOT.

The output during startup is something similar to this:

ProjectClassLoader: 
entry=/Users/sobert/.m2/repository/com/example/projectB/0.0.1/projectB-0.0.1.jar
...
Excluded entry=/Users/sobert/Documents/workspace/projectB/target/test-classes

Thus during runtime, jetty is loading the classes from projectB version 0.0.1, 
and not 0.0.2-SNAPSHOT.

When i start the app using "mvn jetty:run" from the commandline, the correct 
version of the dependency is loaded.

System info:

Eclipse Java EE IDE for Web Developers.
Version: Kepler Release
Build id: 20130320-2352

Run Jetty Run Feature (Require) 1.3.3.201301020723  

OSX 10.8.3
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

Original issue reported on code.google.com by r.gruend...@gmail.com on 7 Jun 2013 at 4:33

GoogleCodeExporter commented 9 years ago
I've got a similar problem but with transitive release versions (of spring) 
being loaded. The POM resolves to use use one version but the RJR plugin adds a 
different version to the classpath.

Original comment by simon.jo...@blackpepper.co.uk on 11 Dec 2013 at 1:56

GoogleCodeExporter commented 9 years ago
I have the same issue.

If I go to Run > Run Configurations and look at the "Webapp Classpath" section, 
I can see that the correct version is detected and checked. However when I run 
the app, the wrong version is added to the classpath.

Original comment by Gui...@gmail.com on 13 Mar 2014 at 1:41

GoogleCodeExporter commented 9 years ago
Does anyone have a workaround? I've tried setting the dependency directly in 
the war project, using dependencyManagement but nothing worked.

Original comment by Gui...@gmail.com on 13 Mar 2014 at 1:49

GoogleCodeExporter commented 9 years ago
Same problem here, but in my case run-jetty-run plugin is adding test 
transitive dependencies to classpath, and this is causing a huge problem with 
diferent versions of the same jdbc driver being loaded.
The jars jetty is loading doesn't appear on the "depedency management" on the 
pom. I don't know why jetty is including them.

Any clues on how to fix this?

Original comment by bruno...@gmail.com on 14 Mar 2014 at 5:09

GoogleCodeExporter commented 9 years ago
Hmm, so many people with same problem, I worked around by creating a target 
folder with all dependencies and excluding everything else. There is also a 
plugin to copy all dependencies to a custom dir that alone should be in 
classpath.

Original comment by krishna81m on 21 Oct 2014 at 4:09

GoogleCodeExporter commented 9 years ago
I worked around by dropping RunJettyRun completely.

My life is so much better now! I create a simple Main class:

public class JettyMain
{
    public static void main(String[] args) throws Exception
    {
        Server server = new Server(8080);
        WebAppContext context = new WebAppContext();
        context.setContextPath("/your_project");
        context.setResourceBase("src/main/webapp");
        server.setHandler(context);

        server.start();
        server.join();
    }
}

Using this, I can easily start an embedded Jetty using whatever version I want. 
I can also easily debug.
Plus the startup time is much faster!

Here's hoping this helps others.

Original comment by Gui...@gmail.com on 21 Oct 2014 at 12:20