Uploaded image for project: 'WildFly Core'
  1. WildFly Core
  2. WFCORE-5118

Cannot get resources from ContextClassLoader with Server Lifecycle Events

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 13.0.0.Final
    • 13.0.0.Beta5
    • Management
    • None
    • Hide

      Reproducer

      reproduce.zip
       ├── modules
       │ └── test
       │ └── listener
       │ └── main
       │ ├── module.xml
       │ └── TestService.jar
       └── standalone
       └── configuration
       └── standalone-test.xml
      
      TestService.jar
       ├── test
       │ └── listener
       │ ├── TestListener.class
       │ └── TestListener.java
       └── test.txt
      
      test/listener/TestListener.java
      public class TestListener implements ProcessStateListener {
      
      public void init(ProcessStateListenerInitParameters parameters) {
       System.out.println("-------------------- TestListener init start");
       System.out.println("Find test.txt in ClassLoader 1 : " + Thread.currentThread().getContextClassLoader().getResource("test.txt"));
       System.out.println("Find test.txt in ClassLoader 2 : " + ClassLoader.getSystemClassLoader().getResource("test.txt"));
       System.out.println("-------------------- TestListener init end");
       }
      

      Steps to reproduce
      1. Install JBoss EAP 7.3.x.
      2. Unzip reproduce.zip under the EAP_HOME
      3. Run the EAP 7.3 with standalone-test.xml.

      $ ./standalone.sh -c standalone-test.xml

      4. Cannot find the test.txt which is in the TestService.jar root.

      10:58:06,294 INFO [stdout] (ServerService Thread Pool -- 48) -------------------- TestListener init start
      10:58:06,295 INFO [stdout] (ServerService Thread Pool -- 48) Find test.txt in ClassLoader 1 : null
      10:58:06,295 INFO [stdout] (ServerService Thread Pool -- 48) Find test.txt in ClassLoader 2 : null
      10:58:06,295 INFO [stdout] (ServerService Thread Pool -- 48) -------------------- TestListener init end
      
      Show
      Reproducer reproduce.zip ├── modules │ └── test │ └── listener │ └── main │ ├── module.xml │ └── TestService.jar └── standalone └── configuration └── standalone-test.xml TestService.jar ├── test │ └── listener │ ├── TestListener.class │ └── TestListener.java └── test.txt test/listener/TestListener.java public class TestListener implements ProcessStateListener { public void init(ProcessStateListenerInitParameters parameters) { System .out.println( "-------------------- TestListener init start" ); System .out.println( "Find test.txt in ClassLoader 1 : " + Thread .currentThread().getContextClassLoader().getResource( "test.txt" )); System .out.println( "Find test.txt in ClassLoader 2 : " + ClassLoader .getSystemClassLoader().getResource( "test.txt" )); System .out.println( "-------------------- TestListener init end" ); } Steps to reproduce 1. Install JBoss EAP 7.3.x. 2. Unzip reproduce.zip under the EAP_HOME 3. Run the EAP 7.3 with standalone-test.xml. $ ./standalone.sh -c standalone-test.xml 4. Cannot find the test.txt which is in the TestService.jar root. 10:58:06,294 INFO [stdout] (ServerService Thread Pool -- 48) -------------------- TestListener init start 10:58:06,295 INFO [stdout] (ServerService Thread Pool -- 48) Find test.txt in ClassLoader 1 : null 10:58:06,295 INFO [stdout] (ServerService Thread Pool -- 48) Find test.txt in ClassLoader 2 : null 10:58:06,295 INFO [stdout] (ServerService Thread Pool -- 48) -------------------- TestListener init end

    Description

      Listener application cannot refer to their own resources from ContextClassLoader. In general the TCCL is not assigned to the module of the ProcessStateListener.

      Attachments

        Issue Links

          Activity

            People

              rhn-support-rmartinc Ricardo Martin Camarero
              rhn-support-rmartinc Ricardo Martin Camarero
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: