9 Replies Latest reply on Mar 13, 2005 9:04 AM by Manuel Moser

    Error launching a command line Client

    Cristian programador Newbie

      I developed a simple EJB, and I can execute a client from eclipse, tryin "run as aplication" but when I try to run it from a command line client I have this error:

      Exception in thread "main" java.lang.NoClassDefFoundError: cliente (wrong name:
      at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source)
      at java.security.SecureClassLoader.defineClass(Unknown Source)
      at java.net.URLClassLoader.defineClass(Unknown Source)
      at java.net.URLClassLoader.access$100(Unknown Source)
      at java.net.URLClassLoader$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClassInternal(Unknown Source)

      I attach libraris on eclipse's project, I don't know what can I do to attach it when I run the client from command line.

      Thank you!

        • 1. Re: Error launching a command line Client
          Manuel Moser Newbie

          I Have the same problem... I also tried with ANT but then i get some other erorrs... plz help


          • 2. Re: Error launching a command line Client
            Darran Lofthouse Master

            Newj2ee, Your classpath is wrong when you are trying to run from the command line. Can you decribe exacty how you are trying to start the client (Directory structures, commands entered etc..).

            • 3. Re: Error launching a command line Client
              Manuel Moser Newbie

              sorry for my first post here.. i forgot to explain the problem..

              I developed a simple "Hello World" program where the main calls a
              function which prints out "World" and a interceptor prints out "Hello".

              ok. in eclipse this works fine. Then i downloaded JBoss AOP from here (is this the right one?) and ANT 1.6.

              Then i tried to write a build.xml file with which i want to Compile the programm, precompile with AOPC, build a jar file and run it.

              I get no errors at compiling and precompiling and creating the jar file.

              But when i try to run the jar file i get this errors:


              i realy don't know what this means... I use no package in this project.

              Here is the .xml file

              <?xml version="1.0"?>
              <project name="HelloAOP" default="compile">
              <target name="prepare" >
               <property environment="env"/>
               <property name="src.dir" value="${basedir}/src"/>
               <property name="src.resources" value="${basedir}/src/resources"/>
               <property name="jboss.home" value="${env.JBOSS_HOME}"/>
               <property name="build.dir" value="${basedir}/build"/>
               <property name="build.classes.dir" value="${build.dir}/classes"/>
               <path id="javassist.classpath">
               <pathelement path="${jboss.home}/lib/javassist.jar"/>
               <path id="trove.classpath">
               <pathelement path="${jboss.home}/lib/trove.jar"/>
               <path id="concurrent.classpath">
               <pathelement path="${jboss.home}/lib/concurrent.jar"/>
               <path id="jboss.common.classpath">
               <pathelement path="${jboss.home}/lib/jboss-common.jar"/>
               <path id="jboss.aop.classpath">
               <pathelement path="${jboss.home}/lib/jboss-aop.jar"/>
               <path id="lib.classpath">
               <path refid="javassist.classpath"/>
               <path refid="trove.classpath"/>
               <path refid="jboss.aop.classpath"/>
               <path refid="jboss.common.classpath"/>
               <path refid="concurrent.classpath"/>
               <path id="classpath">
               <path refid="lib.classpath"/>
               <path refid="jboss.aop.classpath"/>
               <property name="build.classpath" refid="jboss.aop.classpath"/>
               <taskdef name="aopc" classname="org.jboss.aop.ant.AopC" classpathref="jboss.aop.classpath"/>
               <mkdir dir="${build.dir}"/>
               <mkdir dir="${build.classes.dir}"/>
              <target name="compile" depends="prepare" >
               <javac srcdir="${src.dir}"
               <available property="jboss.aop.classpath" value="classpath" file="${jboss.home}/lib/jboss-aop.jar" />
              <target name="aopc" depends="compile">
               <aopc compilerclasspathref="classpath" verbose="true">
               <classpath path="./build/classes/"/>
               <src path="./build/classes/"/>
               <aoppath path="jboss-aop.xml"/>
               <aopclasspath path="${jboss.home}/lib/jboss-aspect-library.jar"/>
              <target name="jar" depends="aopc">
               <jar jarfile="build/HelloAOP.jar" basedir="${build.dir}/classes">
               <fileset dir=".">
               <include name="jboss-aop.xml"/>
               <attribute name="Built-By" value="${user.name}"/>
               <section name="HelloAOP">
              <target name="run">
              <java classname="HelloAOP"
               <arg value="-h"/>
               <pathelement location="build/HelloAOP.jar"/>
               <pathelement path="${java.class.path}"/>

              PS: I am a real beginner with JBoss and Ant.

              plz help :-)

              • 4. Error launching a command line Client
                Cristian programador Newbie

                At first, thanks for your answer ;)

                I'm trying to run the client from a ms-dos command line. I go to the client's directory and I try to start the client doing this:

                java Client

                later I try this other one:

                java -cp (and next, path libraries) Client

                In Eclipse's Workspace I found a .Classpath file with the following code:

                <?xml version="1.0" encoding="UTF-8"?>
                 <classpathentry kind="src" path="src"/>
                 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
                 <classpathentry exported="true" kind="con" path="org.jboss.ide.eclipse.jdt.core.classpath.j2ee-1.3"/>
                 <classpathentry kind="lib" path="E:/PFC/jboss_home/server/default/lib/log4j.jar"/>
                 <classpathentry sourcepath="E:/PFC/jboss_home/server/default/lib/jnpserver.jar" kind="lib" path="E:/PFC/jboss_home/server/default/lib/jnpserver.jar"/>
                 <classpathentry kind="lib" path="E:/PFC/jboss_home/client/jbossall-client.jar"/>
                 <classpathentry kind="lib" path="E:/PFC/jboss_home/server/default/appserver.jar"/>
                 <classpathentry kind="output" path="bin"/>

                I also try to add this paths in the Classpath system, but it doesn't works.
                I have the client in this path:
                and I try to run it from the same path

                Any idea for help me? Thanks!!!!!!!!!!!!

                • 5. Re: Error launching a command line Client
                  Manuel Moser Newbie


                  it looks like we have the same problem. did u also trx to download the Jboss AOP? I tried to use this jar files .. but same result.


                  • 6. Error launching a command line Client
                    Cristian programador Newbie

                    I Found The solution!!! :P

                    for launch the client at the command line, it's necesary:

                    1- have in the classpath system variable the location of the Workspace of the project

                    2- Have in the classpath system variable the location at the file .jar Contains descripcion of Clients Server ( in my Case i work with Jboos and this file is Jbossall-client.jar)

                    3- when you start the cliente:

                    java pakeges_Name.Client_name

                    in my case the package contais the client it's : Calculadora.Ejb

                    then y srtart the client whit the followin :

                    Java Calculadora.Ejb.Client

                    • 7. Re: Error launching a command line Client
                      Manuel Moser Newbie

                      i tried it but now i get this error:

                      java.lang.Error: java.lang.NoSuchMethodException: org.jboss.aop.AspectManager.(java.lang.ClassLoader)

                      my batch file:

                      set CLASSPATH=D:\progis\eclipse\eclipse\workspace\;D:\Progis\eclipse\eclipse\plugins\org.jboss.ide.eclipse.jdt.aop.core_1.0.1\jboss-aop.jar;D:\Progis\eclipse\eclipse\workspace\HelloAOP;D:\Progis\eclipse\eclipse\plugins\org.jboss.ide.eclipse.jdt.aop.core_1.0.1\jboss-common.jar;D:\Progis\eclipse\eclipse\plugins\org.jboss.ide.eclipse.jdt.aop.core_1.0.1\javassist.jar;D:\Progis\eclipse\eclipse\plugins\org.jboss.ide.eclipse.jdt.aop.core_1.0.1\jboss-aspect-library.jar
                      java -Djava.system.class.loader=org.jboss.aop.standalone.SystemClassLoader -Djava.system.class.loader=org.jboss.util.loading.Translator -Djava.system.class.loader=org.jboss.aop.AspectManager -Djboss.aop.path=jboss-aop.xml helloaop.helloaop
                      java helloaop.helloaop

                      • 8. Re: Error launching a command line Client
                        Darran Lofthouse Master


                        "Metalliza" wrote:
                        i tried it but now i get this error:

                        Metalliza, your problems do not relate to the problems that NewJ2ee was experiencing.

                        NewJ2ee is writing a command client client to invoke a session bean, you are writing a command line client to make use of AOP. The only similarity is that you are both writing command line clients.

                        If you have downloaded JBoss AOP there is a bin folder that contains a number of scripts to use for running AOP code either dynamically or precompiled.

                        Chapter 10 of the reference guide also contains enough information to run stand alone AOP applications, just follow it to the letter making use of the libraries downloaded with the AOP distribution.

                        • 9. Re: Error launching a command line Client
                          Manuel Moser Newbie

                          thx! it works now with ant.. i don't really know why but that doesn't matter :-)