5 Replies Latest reply on Aug 28, 2004 3:46 PM by theute

    Classpath problem when compiling customized Modules

      Hi, sorry for this cross-posting. While looking through this devel forum, I realize that my post may have been more relevant here.

      This is the post on "http://www.jboss.org/index.html?module=bb&op=viewtopic&t=53467" :

      I'll update this page once I try the suggestions given by theute.

      I have this module GetAttrs that extends ModuleSupport; it's been successfully deployed.
      The compilation is done using the build.xml provided by the source, "nukes-1.1.0-RC3-src/nukes/build.xml".

      Nukes
      |-nukes/src/main
      | |- org.jboss.nukes.addons.modules.linkmodule
      | |-GetAttrs.java
      |
      |- nukes/build.xml
      |
      |- ldapjdk.jar

      I have written an LDAP client class; it's successfully compiled and run. The librariy I use is ldapjdk.jar.

      When I merge the code and compile using the "nukes/build.xml", I got these error messages:
      [javac] Nukes/nukes/src/main/org/jboss/nukes/addons/modules/linkmodule/GetAttrModule.java:9: package netscape.ldap does not exist
      [javac] import netscape.ldap.*;
      [javac] ^
      [javac] Nukes/nukes/src/main/org/jboss/nukes/addons/modules/linkmodule/GetAttrModule.java:23: cannot resolve symbol
      [javac] symbol : class LDAPConnection
      [javac] location: class org.jboss.nukes.addons.modules.linkmodule.GetAttrModule
      [javac] LDAPConnection ld = null;
      [javac] ^

      I have added ldapjdk.jar to my Nukes java build path and the directory "netscape/ldap" exists in the ldapjdk.jar.

      When I use init.verbose=true, the target in ant shows the following:

      buildmagic:init:show-environment:
      [echo] build.compiler: ${build.compiler}
      [echo] java.home: /usr/local/opt/j2sdk/j2sdk1.4.2_04/jre
      [echo] java.class.path: /usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-antlr.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-apache-bsf.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-apache-resolver.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-commons-logging.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-commons-net.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-icontract.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-jai.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-jakarta-bcel.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-jakarta-log4j.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-jakarta-oro.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-jakarta-regexp.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-javamail.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-jdepend.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-jmf.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-jsch.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-junit.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-launcher.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-netrexx.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-nodeps.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-starteam.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-stylebook.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-swing.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-trax.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-vaj.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-weblogic.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-xalan1.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-xalan2.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.apache.ant_1.6.1/lib/ant-xslp.jar:/usr/local/opt/ide/eclipse-SDK-3.0/plugins/org.eclipse.ant.ui_3.0.0/lib/remoteAnt.jar:/usr/local/opt/j2sdk/j2sdk1.4.2_04/lib/tools.jar
      [echo] java.version: 1.4.2_04
      [echo] java.vendor: Sun Microsystems Inc.
      [echo] java.vm.version: 1.4.2_04-b05
      [echo] java.vm.name: Java HotSpot(TM) Client VM
      [echo] java.vm.info: mixed mode

      So the ldapjdk.jar is not in the ${java.class.path}, can somebody help point out where is this variable specified? I read through buildmagic.ent and the dependent files, but I saw no part that calls this variable. May have missed something here.

      I guess I need to modify the classpath. So I've gone to "Nukes/tools/etc/buildfragments" and modified ${classpath} in task.properties but it doesn't work. I tweaked some classpath variables but I still got the error message.

      So here I am posting the message to the forum.

      Has somebody met this problem? Is it possible to create our own module with our own libraries without modifying the build scripts that come with the source? This will make the module hard to maintain with the subsequent releases of Nukes.

        • 1. Re: Classpath problem when compiling customized Modules

           


          Ok, i will try to help but the build is pretty complex:
          You don't have to modify anything but the build.xml of your project

          I think (i could and proably am wrong but it may worth the try if you couldn't fix your problem) that you just have to add your library to the target "configure" it the "library.classpath" path.

          Let me know if it worked, otherwise i will try to look closer. Or maybe someone else can tell you.

          _________________
          Regards,
          Thomas Heute


          Thanks to theute, I've tried his suggestions and it works.

          However, after re-building the src and deploying it, I can't access the modules. It turns out the jmx-console doesn't register the modules. It's possible that there's something wrong with my modifications of the jboss-service.xml.

          These are the steps I've done:

          1. this is the new modification I've made to $NUKES_HOME/nukes/build.xml where $NUKES_HOME is "path_to/nukes-1.1.0-RC3-src/".

           <!-- Configure thirdparty libraries -->
           <call target="configure-libraries"/>
           <path id="library.classpath">
           <fileset dir="${jboss.home}/client" includes="*.jar"/>
           <fileset dir="${jboss.home}/lib" includes="*.jar"/>
           <fileset dir="${jboss.home}/server/default/lib" includes="*.jar"/>
           <fileset dir="/opt/java/lib/addons" includes="*.jar"/>
           <path refid="apache.commons.classpath"/>
           <path refid="apache.lucene.classpath"/>
           <path refid="dom4j.dom4j.classpath"/>
           <path refid="informa.rss.classpath"/>
           <path refid="javassist.classpath"/>
           <path refid="jregex.jregex.classpath"/>
           <path refid="sourceforge.dnsjava.classpath"/>
           </path>
          


          In /opt/java/lib/addons I've put ldapjdk.jar and ldapsp.jar.

          2. Modify $NUKES_HOME/nukes/output/resources/nukes-sar/META-INF/jboss-service.xml

          I've put these lines to declare the new Modules: TemplateModule, LinkModule and GetAttrModule:

           <mbean
           code="org.jboss.nukes.addons.modules.linkmodule.LinkModule"
           name="nukes.modules:name=LinkModule"
           xmbean-dd=""
           xmbean-code="org.jboss.nukes.component.NukesMBean">
           <depends>nukes.modules:name=core</depends>
           <xmbean>
           <attribute name="DisplayName">Link Module</attribute>
           <attribute name="Description">The Link Module</attribute>
           </xmbean>
           </mbean>
          
           <mbean
           code="org.jboss.nukes.addons.modules.linkmodule.TemplateModule"
           name="nukes.modules:name=TemplateModule"
           xmbean-dd=""
           xmbean-code="org.jboss.nukes.component.NukesMBean">
           <depends>nukes.modules:name=core</depends>
           <xmbean>
           <attribute name="DisplayName">Template Module</attribute>
           <attribute name="Description">The Template Module</attribute>
           </xmbean>
           </mbean>
          
           <mbean
           code="org.jboss.nukes.addons.modules.linkmodule.GetAttrModule"
           name="nukes.modules:name=GetAttrModule"
           xmbean-dd=""
           xmbean-code="org.jboss.nukes.component.NukesMBean">
           <depends>nukes.modules:name=core</depends>
           <xmbean>
           <attribute name="DisplayName">Get Attribute Module</attribute>
           <attribute name="Description">The Get Attribute Module</attribute>
           </xmbean>
           </mbean>
          
          


          3. The next step is to re-build the module and deploy it.

          Problem is I don't see the module on the jboss jmx-console. I checked that nukes-lib.jar contains the classes of the modules with the new jboss-service.xml.

          Thanks for the reply.

          nb. I'm not too sure now whether I may post this on the devel forum or on the nukes user forum. Maybe the more exprerienced nukes users could point out? Thanks




          • 2. Re: Classpath problem when compiling customized Modules
            theute

            First, you should not put your stuff in "nukes" directory but create your own, as nukes is reserved to the 'core'

            If you do so, Nukes would start whatever you do in your module.

            You may want to restart JBoss, if you didn't try yet.

            • 3. Re: Classpath problem when compiling customized Modules

              Thanks for pointing that out.

              I may have overlooked something. I'll spend some time on it first.

              • 4. Re: Classpath problem when compiling customized Modules

                I've restarted the jboss and put the classes into a separate directory, however the problems are still there.

                Each time I create a new package and deploy it, I will get these errors:

                02:03:40,934 INFO [MainDeployer] Starting deployment of package: file:/usr/local/opt/jboss-3.2.3_nukes-1.0.0/server/default/nukes/nukes-mod02.sar
                02:03:40,973 WARN [NestedThrowable] Duplicate throwable nesting of same base type: class org.jboss.deployment.DeploymentException is assignable from: class org.jboss.deployment.DeploymentException
                02:03:40,973 ERROR [MainDeployer] could not create deployment: file:/usr/local/opt/jboss-3.2.3_nukes-1.0.0/server/default/nukes/nukes-mod02.sar
                org.jboss.deployment.DeploymentException: create operation failed for package file:/usr/local/opt/jboss-3.2.3_nukes-1.0.0/server/default/nukes/nukes-mod02.sar; - nested throwable: (org.jboss.deployment.DeploymentException: - nested throwable: (java.lang.reflect.UndeclaredThrowableException))
                at org.jboss.deployment.SARDeployer.create(SARDeployer.java:202)
                at org.jboss.deployment.MainDeployer.create(MainDeployer.java:786)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:641)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
                at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                at $Proxy6.deploy(Unknown Source)
                at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
                at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:476)
                at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:201)
                at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:212)
                at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:191)
                Caused by: org.jboss.deployment.DeploymentException: - nested throwable: (java.lang.reflect.UndeclaredThrowableException)
                at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:139)
                at org.jboss.system.ServiceController.install(ServiceController.java:225)
                at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                at $Proxy4.install(Unknown Source)
                at org.jboss.deployment.SARDeployer.create(SARDeployer.java:183)
                ... 15 more
                Caused by: java.lang.reflect.UndeclaredThrowableException
                at org.jboss.system.ServiceCreator.install(ServiceCreator.java:181)
                at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigurator.java:151)
                at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:114)
                ... 24 more
                Caused by: java.lang.NoClassDefFoundError: netscape/ldap/LDAPException
                at java.lang.Class.getDeclaredConstructors0(Native Method)
                at java.lang.Class.privateGetDeclaredConstructors(Class.java:1610)
                at java.lang.Class.getConstructor0(Class.java:1922)
                at java.lang.Class.getConstructor(Class.java:1019)
                at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:846)
                at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:291)
                at org.jboss.system.ServiceCreator.install(ServiceCreator.java:110)
                ... 26 more

                I've read and re-read my deployment descriptor ( I got similar errors when it's wrong ) and it seems to have no error.

                looks like the last portion complains about being unable to find "netscape/ldap/LDAPException" .

                I have put the "ldapjdk.jar" into $JBOSS_HOME/server/default/lib/ so what's missing here? should I put the library in other jboss directory?

                I use eclipse with "nukes-1.1.0-RC3-src" to write and compile the modules. However I deploy them into "jboss-3.2.3_nukes-1.0.0". Is this a possible cause for the errors?

                • 5. Re: Classpath problem when compiling customized Modules
                  theute

                  It is hard for me to say without having your work environment and sources.

                  Definitely, deploying in nukes-1.0.0 is not a good idea but i guess you recompiled and redeployed nukes.ear so it's not a real problem. But make sure to delete default/nukes directory and default/deploy/nukes.ear file and re deploy everything then start JBoss.

                  The .jar should be in the package created by ant if you used the build script and your application should find it.

                  If you send me your package i can try to deploy it on my configuration if you want.