Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 363237

Summary: Put endorsed libraries before the JRE on the eclipse classpath
Product: z_Archived Reporter: jhite
Component: m2eAssignee: Project Inbox <m2e.core-inbox>
Status: CLOSED INVALID QA Contact:
Severity: enhancement    
Priority: P3 CC: adietish, adrianboimvaser, eclipse.dserodio, fbricon, igor, jhite, jtk499, manderse, mpaesold, reschifl
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description jhite CLA 2011-11-08 17:39:33 EST
Build Identifier: 20110916-0149

Both JAXB and JAX-WS have newer versions that are commonly used with JRE's that have an old version of the interface. This can be overridden using Java's endorsed mechanism, bu either putting the library in <java-home>\lib\endorsed or by adding it to the java.endorsed.dirs property. I work with multiple projects, each one may use different versions of the JAXB and JAX-WS interfaces, so putting the libraries in my <java-home>\lib\endorsed is no good. I would prefer to have some method of adding them to the classpath in eclipse before the JRE. 

Reproducible: Always

Steps to Reproduce:
Try to create a project that overrides some interfaces distributed with java (without adding them to the jre's endorsed folder), such as JAXB or JAX-WS. It's possible to make the maven project compile, but it will not compile in eclipse.
Comment 1 jhite CLA 2011-11-08 17:45:50 EST
Even making the m2e plugin not re-order the eclipse classpath would help. I could then just move the "Maven Dependencies" before the JRE in eclipse classpath. It's not pretty or ideal, but solves my problem.
Comment 2 Fred Bricon CLA 2011-11-12 18:08:55 EST
Couldn't we create a new Classpath Library (Endorsed Library?), that would  always be put before the JRE one?
Comment 3 Max Rydahl Andersen CLA 2011-11-13 05:40:01 EST
(In reply to comment #2)
> Couldn't we create a new Classpath Library (Endorsed Library?), that would 
> always be put before the JRE one?

I like that idea, but what in pom.xml would be used to define "Endorsed library" to make m2e configure this correctly ?
Comment 4 Igor Fedorenko CLA 2011-11-13 09:52:35 EST
(In reply to comment #3)
> (In reply to comment #2)
> > Couldn't we create a new Classpath Library (Endorsed Library?), that would 
> > always be put before the JRE one?
> 
> I like that idea, but what in pom.xml would be used to define "Endorsed
> library" to make m2e configure this correctly ?

If use of endorsed libraries is the way to solve the problem on command line, then adding the same libraries to JRE classpath (i.e. via Installed JREs preference page) is perfectly reasonable way to achieve the same effect inside IDE. 

A better/proper solution to the problem would require finding pom.xml representation for dependencies that needs to appear on classpath before JRE libraries and making all command-line tools and IDEs support the new notion. I do not believe m2e-only solution that does not work for command-line build is a good idea.
Comment 5 Fred Bricon CLA 2011-11-13 13:14:02 EST
(In reply to comment #4)
> (In reply to comment #3)
> > (In reply to comment #2)
> > > Couldn't we create a new Classpath Library (Endorsed Library?), that would 
> > > always be put before the JRE one?
> > 
> > I like that idea, but what in pom.xml would be used to define "Endorsed
> > library" to make m2e configure this correctly ?
> 
> If use of endorsed libraries is the way to solve the problem on command line,
> then adding the same libraries to JRE classpath (i.e. via Installed JREs
> preference page) is perfectly reasonable way to achieve the same effect inside
> IDE. 
> 
But then you'd have a workspace wide custom JRE classpath, assuming you'd add the custom directory to existing Execution Environment(s). That might cause unexpected behavior on other maven projects in your workspace. The maven-compiler-plugin allows you to add this endorsed libraries specifically to your project build. Having a new Classpath Library per project would - I believe, but I may be wrong - lead to the same result, without impeding on other projects' classpath.   

> A better/proper solution to the problem would require finding pom.xml
> representation for dependencies that needs to appear on classpath before JRE
> libraries and making all command-line tools and IDEs support the new notion. I
> do not believe m2e-only solution that does not work for command-line build is a
> good idea.
Why are you saying it doesn't work for command-line build? Endorsed libraries are currently supported in maven builds using a combination of maven-dependency-plugin:copy and the <compilerArgument> property of maven-compiler-plugin configuration. I agree though a better native support should be added to maven, as well as some improvments in JDT. But how long do you think it will take before we see that happen?
Comment 6 jhite CLA 2011-11-14 11:46:02 EST
(In reply to comment #5)
> Why are you saying it doesn't work for command-line build? Endorsed libraries
> are currently supported in maven builds using a combination of
> maven-dependency-plugin:copy and the <compilerArgument> property of
> maven-compiler-plugin configuration. I agree though a better native support
> should be added to maven, as well as some improvments in JDT. But how long do
> you think it will take before we see that happen?

That's basically how our command line build works now. I just don't know how you could determine that the maven-dependency-plugin:copy is being used to setup endorsed libraries, unless copying to target/endorsed is a well known and accepted convention.
Comment 7 Fred Bricon CLA 2012-05-10 07:27:50 EDT
For those interested, I'm implementing this feature under the JBoss Tools umbrella (for now) : https://issues.jboss.org/browse/JBIDE-11738?focusedCommentId=12691763&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12691763

I attached an archived update site on JIRA, so you can try. Current implementation doesn't copy the files to the endorsed lib, that needs to be done via a CLI build first.
Comment 8 Fred Bricon CLA 2012-05-29 12:43:54 EDT
JBoss Tools 3.3.0.CR1 update site contains aforementioned configurator : http://download.jboss.org/jbosstools/updates/JBossTools-3.3.0.CR1.core/
Comment 9 Igor Fedorenko CLA 2014-01-23 20:44:02 EST
Closing old/stale bugzilla entries.
Comment 10 Denis Roy CLA 2021-04-19 13:22:53 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/