10 Replies Latest reply on Jun 27, 2014 2:21 PM by praneshinjboss

    Creating custom modules in JBoss 6.2.0 EAP throwing exception

    praneshinjboss

      Hello,

       

      I'm using JBoss 6.2.0 and trying to create a new custom module but throwing exceptions. Please correct me, the way I have created the custom module is correct? If there is any other way of doing it please let me know.

      I hope all system modules are automatically added to create dependency for my custom modules.

       

      1. Created a directory : mkdir -p JBoss_HOME/modules/com/mycompany/appl/main

      2. Placed all my 4 jars inside main dir

      3. Created module.xml under main dir.

       

      <?xml version="1.0" encoding="UTF-8"?>

      <module xmlns="urn:jboss:module:1.1" name="com.mycompany.appl">

          <resources>

              <resource-root path="devicetypeapi.jar"/>

              <resource-root path="deviceatlas-deviceapi-2.0.jar"/>

        <resource-root path="deviceatlas-common-1.0.jar"/>

              <resource-root path="deviceatlas-carrierapi-1.0.1.jar"/>

          </resources>

      </module>

       

      4. Created jboss-deployment-structure under WEB-INF & packed the war deployment file.

       

      <jboss-deployment-structure>

         <deployment>

            <dependencies>

               <module name="com.mycompany.appl.devicetypeapi"/>

               <module name="com.mycompany.appl.deviceatlas-deviceapi-2.0"/>

               <module name="com.mycompany.appl.deviceatlas-common-1.0"/>

               <module name="com.mycompany.appl.deviceatlas-carrierapi-1.0.1"/>

            </dependencies>

         </deployment>

      </jboss-deployment-structure>

       

      5. When I start the server & deploy my application, throwing exceptions, though deployment is successful.

       

      13:29:30,528 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.module.service."deployment.devicetypeapi.war".main: org.jboss.msc.service.StartException in service jboss.module.service."deployment.devicetypeapi.war".main: JBAS018759: Failed to load module: deployment.devicetypeapi.war:main

              at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:91) [jboss-as-server-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]

              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_60]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_60]

              at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_60]

      Caused by: org.jboss.modules.ModuleNotFoundException: com.mycompany.appl.devicetypeapi:main

              at org.jboss.modules.Module.addPaths(Module.java:1030) [jboss-modules.jar:1.3.0.Final-redhat-2]

              at org.jboss.modules.Module.link(Module.java:1386) [jboss-modules.jar:1.3.0.Final-redhat-2]

              at org.jboss.modules.Module.relinkIfNecessary(Module.java:1414) [jboss-modules.jar:1.3.0.Final-redhat-2]

              at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:242) [jboss-modules.jar:1.3.0.Final-redhat-2]

              at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:70) [jboss-as-server-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

              ... 5 more

      13:29:30,858 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 26) JBAS018559: Deployed "devicetypeapi.war" (runtime-name : "devicetypeapi.war")

      13:29:30,873 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report

      JBAS014777:   Services which failed to start:      service jboss.module.service."deployment.devicetypeapi.war".main: org.jboss.msc.service.StartException in service jboss.module.service."deployment.devicetypeapi.war".main: JBAS018759: Failed to load module: deployment.devicetypeapi.war:main

      13:29:30,898 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:10090/management

      13:29:30,899 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:10090

      13:29:30,899 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: JBoss EAP 6.2.0.GA (AS 7.3.0.Final-redhat-14) started (with errors) in 7298ms - Started 139 of 199 services (1 services failed or missing dependencies, 58 services are passive or on-demand)

       

      Thanks,

      Pranesh

        • 1. Re: Creating custom modules in JBoss 6.2.0 EAP throwing exception
          praneshinjboss

          One more thing to add. when creating dirs under JBoss_home/modules for the custom module, does it require to match the same directory structure as in WEB-INF/classes/mycompany/appl ?

          • 2. Re: Creating custom modules in JBoss 6.2.0 EAP throwing exception
            wdfink

            In your case you need to reference only the dependecy <module name="com.mycompany.appl"/>

            As you create one module with 4 jars. If you need the jar's as separate dependencies, i.e. if your applications are not use all, you must create foru different modules.

            1 of 1 people found this helpful
            • 3. Re: Creating custom modules in JBoss 6.2.0 EAP throwing exception
              praneshinjboss
              Thanks Wolf.  I have updated the changes as below and seems that I'm not seeing that errror but still seeing application related error "java.lang.NoClassDefFoundError". I have all the jar files added and code deployed & when testing, Im getting the exception. I assume still it is not finding the class path                            Also, I tried global modules in standalone.xml as below and removed jboss-deployment-structure  from WEB-INF and now its throwing. Why is org.apache.log4j not loading during JBoss startup and please correct me if I have done something different. When I try adding org.apache.log4j, explicitly as global module though per JBoss7, it is loaded as core module, other modules are not loading successively.  What should I make to load all these modules. Please advice.                                                              false            true        Error:  13:18:56,192 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/devicetypeapi].[DeviceTypeServlet]]  JBWEB000236: Servlet.service() for servlet DeviceTypeServlet threw exception: java.lang.ClassNotFoundException: org.apache.log4j
              • 4. Re: Creating custom modules in JBoss 6.2.0 EAP throwing exception
                praneshinjboss

                In addition to that, I have few classes under WEB-INF/appl/directory. The exception showing java.lang.NoClassDefFoundError on  com/dir1/dir2/dir3/common/IValues class but I have that xyz.jar under my custom module dir which has the class files. I'm assuming still JBoss is not finding my modules.

                • 5. Re: Creating custom modules in JBoss 6.2.0 EAP throwing exception
                  wdfink

                  Did you set the dependency and other stuff correct?

                  Maybe

                  remove the module -> you get a module not found

                  remove the jars -> you see a file not found if the module is loaded

                   

                  This might give you a hint if you miss something

                  • 6. Re: Creating custom modules in JBoss 6.2.0 EAP throwing exception
                    praneshinjboss

                    I will try and one more question to understand.

                    Do I need to create custom modules dir in the same name as defined in class files?

                    Ex: If com/dir1/dir2/dir3/common/IValues class is defined, do I need to place all jars, module.xml in custom dir com/dir1/dir2/dir3/common/IValues/main or i can use something like ../modules/myappl/main and reference it?

                    • 7. Re: Creating custom modules in JBoss 6.2.0 EAP throwing exception
                      wdfink

                      No, the package/class names inside the jar's are not relevant.

                      You need to have the directory structure and the module name within the modules.xml in sync.

                      If the module is named "a.b.c" you need to have it together with the jar's in modules/a/b/c/<slot>.

                      The <slot> is for different versions, if you don't define one you need to use main

                      • 8. Re: Creating custom modules in JBoss 6.2.0 EAP throwing exception
                        praneshinjboss

                        Understood. Thanks Wolf for that.

                        I tried creating global modules in standalone.xml, deleted jboss-deployment-structure file and enable -verbose:class to see what modules are loaded and can able to see my modules are getting loaded in server.log. In fact i can able test my application successfully. But if I do the same with jboss-deployment-structure and removing global modules, my libs/modules are not getting loaded and seeing the same no class found exception. I know there is something wrong in my jboss-deployment-structure that modules are not picked up.

                        Any suggestions finally on that would be great helpful?

                         

                        <jboss-deployment-structure>

                           <deployment>

                              <dependencies>

                                 <module name="com.mycompany.appl.devicetypeapi"/>

                                 <module name="com.mycompany.appl.deviceatlas-deviceapi-2.0"/>

                                 <module name="com.mycompany.appl.deviceatlas-common-1.0"/>

                                 <module name="com.mycompany.appl.deviceatlas-carrierapi-1.0.1"/>

                                 <module name="javax.api"/>

                              </dependencies>

                           </deployment>

                        </jboss-deployment-structure>

                         

                        module.xml

                        <?xml version="1.0" encoding="UTF-8"?>

                        <module xmlns="urn:jboss:module:1.1" name="com.mycompany.appl">

                            <resources>

                                <resource-root path="devicetypeapi.jar"/>

                                <resource-root path="deviceatlas-deviceapi-2.0.jar"/>

                          <resource-root path="deviceatlas-common-1.0.jar"/>

                                <resource-root path="deviceatlas-carrierapi-1.0.1.jar"/>

                            </resources>

                        </module>

                        • 9. Re: Creating custom modules in JBoss 6.2.0 EAP throwing exception
                          wdfink

                          As I said earlier the structure is incorrect.

                          You need to have only one module dependency like this:

                              <dependencies>

                                  <module name="com.mycompany.appl"/>

                              </dependencies>

                          the javax.api should be automatic as described here Implicit module dependencies for deployments

                           

                          The module folder must be modules/com/mycompany/appl/main in this case.

                          • 10. Re: Creating custom modules in JBoss 6.2.0 EAP throwing exception
                            praneshinjboss

                            Awesome. I re-modified and is working now. Many Thanks Wolf.