dependencies priority not working like Tomcat classloader

hello,

I have a webapp which uses a jar, containing
class B extends A
I also have .class files which contain class A again, in a different version.

Now the Tomcat class loader really works in such a way that it takes class B from the jar, but class A from WEB-INF/classes. But in Idea, even though the classes directory is above the jar in the Dependencies tab, does not. So it shows all sorts of syntax errors in the code which aren't actually for real, and auto-complete, viewing parameter lists etc. doesn't work.

This is a huge problem, because I already have no JavaDoc and no source code for either of those 3 classes.

How can I give a dependency for a module a higher priority than another one? As I said, it is already above it in the list, I moved it.

4 comments

Hi Kai,

Dependencies order is used for classpath construction, i.e. 'top dependencies' are located at classpath before 'bottom dependencies'. That's why the behavior you describe looks like a bug. However, it's possible that that 'wrong dependency' is referenced before the 'right dependency' as a transitive dependency Could you provide a minimal but complete sample project which illustrates the problem?

Denis

0

hello,

testcase is attached.

the src-for-jar and src-for-classes are not actual src directories, I just used them to fabricate the files in classes and lib, which are the 2 dependency directories for which I don't get the priority right.

public class Testcase {
    public static void main( String[] args ) {
        new B().a(); // should not work, because the A in classes has no method a, but Idea shows no error
        new B().a2(); // should work, because the A with this method is in the classes directory, but Idea does show an error
    }
}



Attachment(s):
testcase.zip
0

Reproduced the problem, thanks. Checking the code.

Denis

0

Corresponding ticket has been created - IDEA-101806. Feel free to track its progress.

Denis

0

Please sign in to leave a comment.