3 Replies Latest reply on Feb 1, 2011 7:24 AM by Carlo de Wolf

    Help, my extension isn't starting

    Carlo de Wolf Master

      With a wrong module.xml you Extension will be unable to start and show a stacktrace not unlike:

      12:52:11,273 ERROR [org.jboss.msc] MSC-00001: Failed to start service jboss.as.server-controller: org.jboss.msc.service.StartException in service jboss.as.server-controller: Failed to start service
          at org.jboss.msc.service.ServiceInstanceImpl$StartTask.run(ServiceInstanceImpl.java:1207)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_22]
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_22]
          at java.lang.Thread.run(Thread.java:662) [:1.6.0_22]
      Caused by: java.util.ServiceConfigurationError: org.jboss.as.server.Extension: Provider org.jboss.as.ejb3.EJB3Extension not found
          at java.util.ServiceLoader.fail(ServiceLoader.java:214) [:1.6.0_22]
          at java.util.ServiceLoader.access$400(ServiceLoader.java:164) [:1.6.0_22]
          at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:350) [:1.6.0_22]
          at java.util.ServiceLoader$1.next(ServiceLoader.java:421) [:1.6.0_22]
          at org.jboss.as.model.ModelXmlParsers.parseExtensions(ModelXmlParsers.java:432)
          at org.jboss.as.model.ModelXmlParsers.parseServerRootElement(ModelXmlParsers.java:180)
          at org.jboss.as.model.ModelXmlParsers$3.readElement(ModelXmlParsers.java:108)
          at org.jboss.as.model.ModelXmlParsers$3.readElement(ModelXmlParsers.java:106)
          at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:91)
          at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:59)
          at org.jboss.as.server.mgmt.StandaloneServerConfigurationPersister.load(StandaloneServerConfigurationPersister.java:109)
          at org.jboss.as.server.ServerControllerService.start(ServerControllerService.java:137)
          at org.jboss.msc.service.ServiceInstanceImpl$StartTask.run(ServiceInstanceImpl.java:1163)
      

       

      In this thread I'll write up the steps needed to debug such an issue.

        • 1. Re: Help, my extension isn't starting
          Carlo de Wolf Master

          First configure logging.properties to TRACE log org.jboss.modules.

          1. Add org.jboss.modules to the logger names that need to be configured.
          2. Set logger.org.jboss.modules.level to TRACE
          3. Do not forget to comment out the threshold of the FileHandler (or ConsoleHandler)

           

          Your logging.properties will then look like:

          # Additional logger names to configure (root logger is always configured)
          loggers=org.jboss.as.config,org.jboss.modules
          
          # Dump system environment at boot by default
          logger.org.jboss.as.config.level=DEBUG
          
          logger.org.jboss.modules.level=TRACE
          
          # Root logger level
          logger.level=${jboss.boot.server.log.level:INFO}
          # Root logger handlers
          logger.handlers=FILE,CONSOLE
          
          # Console handler configuration
          handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
          handler.CONSOLE.properties=autoFlush
          handler.CONSOLE.level=${jboss.boot.server.log.console.level:INFO}
          handler.CONSOLE.autoFlush=true
          handler.CONSOLE.formatter=PATTERN
          
          # File handler configuration
          handler.FILE=org.jboss.logmanager.handlers.FileHandler
          #handler.FILE.level=DEBUG
          handler.FILE.properties=autoFlush,fileName
          handler.FILE.autoFlush=true
          handler.FILE.fileName=${org.jboss.boot.log.file:boot.log}
          handler.FILE.formatter=PATTERN
          
          # Formatter pattern configuration
          formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
          formatter.PATTERN.properties=pattern
          formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n
          
          • 2. Re: Help, my extension isn't starting
            Carlo de Wolf Master

            Boot up either standalone or the domain and take a look at boot.log. There will be a stacktrace similar to:

             

            13:10:53,891 TRACE [org.jboss.modules] Failed to define class org.jboss.as.ejb3.EJB3Extension in Module "org.jboss.as.ejb3:main" from local module loader @7d2452e8 (roots: /home/carlo/work/jboss-as/build/target/jboss-7.0.0.Alpha2/modules): java.lang.LinkageError: Failed to link org/jboss/as/ejb3/EJB3Extension (Module "org.jboss.as.ejb3:main" from local module loader @7d2452e8 (roots: /home/carlo/work/jboss-as/build/target/jboss-7.0.0.Alpha2/modules))
                at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:374) [:1.0.0.Beta13]
                at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:250) [:1.0.0.Beta13]
                at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:70) [:1.0.0.Beta13]
                at org.jboss.modules.Module.loadModuleClass(Module.java:486) [:1.0.0.Beta13]
                at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:178) [:1.0.0.Beta13]
                at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:270) [:1.0.0.Beta13]
                at org.jboss.modules.ConcurrentClassLoader.access$400(ConcurrentClassLoader.java:42) [:1.0.0.Beta13]
                at org.jboss.modules.ConcurrentClassLoader$LoaderThread.run(ConcurrentClassLoader.java:339) [:1.0.0.Beta13]
            Caused by: java.lang.NoClassDefFoundError: org/jboss/as/server/Extension
                at java.lang.ClassLoader.defineClass1(Native Method) [:1.6.0_22]
                at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) [:1.6.0_22]
                at java.lang.ClassLoader.defineClass(ClassLoader.java:616) [:1.6.0_22]
                at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) [:1.6.0_22]
                at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:370) [:1.0.0.Beta13]
                ... 7 more
            Caused by: java.lang.ClassNotFoundException: org.jboss.as.server.Extension from [Module "org.jboss.as.ejb3:main" from local module loader @7d2452e8 (roots: /home/carlo/work/jboss-as/build/target/jboss-7.0.0.Alpha2/modules)]
                at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:186) [:1.0.0.Beta13]
                at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:270) [:1.0.0.Beta13]
                at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:52) [:1.0.0.Beta13]
                ... 12 more
            

             

            Clearly this shows that org.jboss.as.server is the missing dependency.

            • 3. Re: Help, my extension isn't starting
              Carlo de Wolf Master

              Why is this such a hassle?

               

              For that we need to take a look in the JDK source ServiceLoader.java:

                  public S next() {
                      if (!hasNext()) {
                           throw new NoSuchElementException();
                      }
                      String cn = nextName;
                      nextName = null;
                      try {
                           S p = service.cast(Class.forName(cn, true, loader)
                                 .newInstance());
                           providers.put(cn, p);
                           return p;
                      } catch (ClassNotFoundException x) {
                           fail(service,
                                "Provider " + cn + " not found");
                      } catch (Throwable x) {
                           fail(service,
                                "Provider " + cn + " could not be instantiated: " + x,
                                x);
                      }
                      throw new Error();        // This cannot happen
                  }
              

               

              If it encounters a ClassNotFoundException it doesn't emmit which class it can not find. Also the original exception is swallowed, so any diagnostic information within is lost.

               

              They got one thing right though: fail. ;-)