jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Maven Surefire
  • SUREFIRE-289

Surefire classlaoder loads wrong class when classes are of same package/class name

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Duplicate
  • Affects Version/s: 2.0 (2.2 plugin)
  • Fix Version/s: None
  • Component/s: classloading
  • Labels:
    None
  • Environment:
    Windows, Cygwin
  • Complexity:
    Intermediate

Description

This is a repeat of the comment in SUREFIRE-286

I am having a problem with surefire classloading.

I had to hack the ServiceMix class:

org.apache.servicemix.http.processors.ConsumerProcessor.

I saved the hacked version as the same class name and the same package. This class does compile to target/classes. The ServiceMix jar that contains this class is included in my classpath after the target/classes directory (seen with -X)

When running mvn test, I get a test failure for the Test class that tries to create a ConsumerProcessor. We are expecting it to create "our" version of ConsumerProcessor, but it instead creates the ServiceMix version.

I have tried all the available usage options from the surefire plugin documentation to no avail. Through debug in Eclipse, I see through a watch expression (getClass().getClassLoader()) is always the IsolatedClassLoader, no matter what options we set.

This test passes in Eclipse, so I am pretty sure it is a classloading issue with the surefire plugin.

Thanks for your help in advance.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Hide
    Zip Archive
    cheese.zip
    22/Feb/07 7:46 AM
    4 kB
    Zachary Jones
    1. Java Archive File
      org/.../cheeseburgertest-1.0.jar 2 kB
    2. Java Archive File
      org/cheesetest/1.0/cheesetest-1.0.jar 2 kB
    3. File
      org/cheesetest/1.0/cheesetest-1.0.pom 2 kB
    4. XML File
      org/cheesetest/maven-metadata-local.xml 0.3 kB
    Download Zip
    Show
    Zip Archive
    cheese.zip
    22/Feb/07 7:46 AM
    4 kB
    Zachary Jones
  2. Hide
    Zip Archive
    cheesetest.zip
    22/Feb/07 7:46 AM
    2 kB
    Zachary Jones
    1. XML File
      pom.xml 2 kB
    2. Java Source File
      src/main/java/test/TestClass.java 0.1 kB
    3. Java Source File
      src/test/java/test/TestClassTest.java 0.2 kB
    Download Zip
    Show
    Zip Archive
    cheesetest.zip
    22/Feb/07 7:46 AM
    2 kB
    Zachary Jones

Issue Links

duplicates

Bug - A problem which impairs or prevents the functions of the product. SUREFIRE-61 Incorrect classpath ordering

  • Critical - Crashes, loss of data, severe memory leak.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Zachary Jones added a comment - 22/Feb/07 7:46 AM

Adding a test case to prove this problem.

First unzip the cheese.zip into your local repo. It contains a jar file at cheese/org/cheeseburgertest-1.0.jar
cheeseburgertest-1.0.jar contains a class "test/TestClass" that has a method String sayCheese() which returns "CheeseBurger!".

Unizip the cheesetest.zip anywhere and run "mvn install". cheesetest is a simple project that contains a duplicate "test/TestClass" whose sayCheese method returns "Cheese!".

When it runs the test "test/TestClassTest", it asserts that sayCheese returns "Cheese!". But as you will see, the test fails and the surefire report shows "CheeseBurger!" was returned instead.

If you do an eclipse:eclipse and run the test in Eclipse, the test will pass as expected..

Show
Zachary Jones added a comment - 22/Feb/07 7:46 AM Adding a test case to prove this problem. First unzip the cheese.zip into your local repo. It contains a jar file at cheese/org/cheeseburgertest-1.0.jar cheeseburgertest-1.0.jar contains a class "test/TestClass" that has a method String sayCheese() which returns "CheeseBurger!". Unizip the cheesetest.zip anywhere and run "mvn install". cheesetest is a simple project that contains a duplicate "test/TestClass" whose sayCheese method returns "Cheese!". When it runs the test "test/TestClassTest", it asserts that sayCheese returns "Cheese!". But as you will see, the test fails and the surefire report shows "CheeseBurger!" was returned instead. If you do an eclipse:eclipse and run the test in Eclipse, the test will pass as expected..
Hide
Permalink
Michael Joyce added a comment - 15/Jun/07 4:38 AM

This appears to be a duplicate of SUREFIRE-61

Show
Michael Joyce added a comment - 15/Jun/07 4:38 AM This appears to be a duplicate of SUREFIRE-61
Hide
Permalink
Michael Joyce added a comment - 15/Jun/07 4:39 AM

These both seem to be caused by incorrect classloading for tests.

Show
Michael Joyce added a comment - 15/Jun/07 4:39 AM These both seem to be caused by incorrect classloading for tests.
Hide
Permalink
Dan Fabulich added a comment - 24/Nov/07 2:05 PM

duplicate of SUREFIRE-61

Show
Dan Fabulich added a comment - 24/Nov/07 2:05 PM duplicate of SUREFIRE-61

People

  • Assignee:
    Unassigned
    Reporter:
    Zachary Jones
Vote (2)
Watch (3)

Dates

  • Created:
    22/Feb/07 5:59 AM
    Updated:
    24/Nov/07 2:05 PM
    Resolved:
    24/Nov/07 2:05 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.