1 2 Previous Next 15 Replies Latest reply on Jul 24, 2009 10:56 AM by Peter Johnson

    Re: ant failed.

    sam wun Newbie

      I still failed with the same error.
      Here is my build.xml:

      <?xml version="1.0"?>
      
      <project name="portlet" basedir="." default="deploy">
       <import file="../build-common-portlet.xml" />
      
       <target name="compile">
       <mkdir dir="docroot/WEB-INF/classes" />
      
       <path id="plugin-lib.classpath">
       <pathelement location="${app.server.classes.portal.dir}" />
       <fileset dir="${app.server.lib.portal.dir}" includes="*.jar" />
       <pathelement location="docroot/WEB-INF/classes" />
       </path>
      
       <javac
       classpathref="plugin.classpath"
       compiler="${javac.compiler}"
       debug="${javac.debug}"
       deprecation="${javac.deprecation}"
       destdir="docroot/WEB-INF/classes"
       nowarn="${javac.nowarn}"
       srcdir="docroot/WEB-INF/src"
       />
      
       <antcall target="build-common-plugin.compile" />
       </target>
      
       <target name="build-lang">
       <antcall target="build-lang-cmd">
       <param name="lang.dir" value="docroot/WEB-INF/src/content/test" />
       <param name="lang.file" value="Language" />
       </antcall>
       </target>
      
      <property name="tst-dir" location="docroot/WEB-INF/src" />
       <property name="TALK" value="false" />
      
       <path id="classpath.base">
       </path>
       <path id="classpath.test">
       <pathelement location="/usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/lib/junit.jar" />
       <pathelement location="${tst-dir}" />
       <path refid="classpath.base" />
       </path>
      
       <target name="compile-test">
       <javac srcdir="${tst-dir}"
       verbose="${TALK}"
       includes="**/*.java"
       >
       <classpath refid="classpath.test"/>
       </javac>
       </target>
      
       <target name="test" depends="compile-test">
       <junit>
       <classpath refid="classpath.test" />
       <formatter type="brief" usefile="false" />
       <test name="com.ip6networks.calling_card_registration.test.Client" />
       </junit>
       </target>
       <target name="test" depends="compile-test">
       <junit>
       <classpath refid="classpath.test" />
       <formatter type="brief" usefile="false" />
       <test name="com.ip6networks.calling_card_registration.test.Client" />
       </junit>
       </target>
      
       <target name="clean-compile-test">
       <delete verbose="${TALK}">
       <fileset dir="${tst-dir}" includes="**/*.class" />
       </delete>
       </target>
       <target name="clean-test" depends="clean-compile-test" />
      
      </project>
      
      


      And here is the first few errors:

      calling_card_reg # ant test
      Buildfile: build.xml
      
      compile-test:
       [javac] Compiling 11 source files
       [javac] /usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/src/com/ip6networks/calling_card_registration/struts/action/CallingCardRegistrationAction.java:29: package com.liferay.portal.struts does not exist
       [javac] import com.liferay.portal.struts.PortletAction;
       [javac] ^
       [javac] /usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/src/com/ip6networks/calling_card_registration/struts/action/CallingCardRegistrationAction.java:34: package javax.portlet does not exist
       [javac] import javax.portlet.ActionRequest;
       [javac] ^
       [javac] /usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/src/com/ip6networks/calling_card_registration/struts/action/CallingCardRegistrationAction.java:35: package javax.portlet does not exist
       [javac] import javax.portlet.ActionResponse;
      ....
      
      


      It doesn't complained the *.java files in the "test" folder.
      Rather, it complained those in the other path. that s why I was asking whether I can restrict ant to compile the files in the "test" directory.

      Thanks for the suggestion.
      Sam

        • 1. Re: Re: ant failed.
          Peter Johnson Master

          For those of you just now joining us, you can catch up on the story by view the first season at: http://www.jboss.org/index.html?module=bb&op=viewtopic&p=

          why I was asking whether I can restrict ant to compile the files in the "test" directory.


          I was going to show you how to change the includes directive to do this, but you should be able to figure that out by looking at the ant documentation - there is an example in there that covers this topic. (If after looking at the docs and trying what you think is the solution, if it does not work post ONLY the javac task that you have, and the Ant output for the javac task, and I will help you with it.)

          What books have you read on Ant? I very much recommend Ant in Action - I have a copy of the first edition, best investment I ever made.

          • 2. Re: ant failed.
            sam wun Newbie

            I read through Ant Documentation, and come up wtih the followoing solution:

             <target name="compile-test">
             <javac srcdir="${tst-dir}"
             verbose="${TALK}"
             includes="/usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/src/com/ip6networks/calling_card_registration/struts/action/*.java"
             >
             <classpath refid="classpath.test"/>
             </javac>
             </target>
            
             <target name="test" depends="compile-test">
             <junit>
             <classpath refid="classpath.test" />
             <formatter type="brief" usefile="false" />
             <test name="com.ip6networks.calling_card_registration.test.Client" />
             </junit>
             </target>
            
             <target name="clean-compile-test">
             <delete verbose="${TALK}">
             <fileset dir="${tst-dir}" includes="**/*.class" />
             </delete>
             </target>
             <target name="clean-test" depends="clean-compile-test" />
            


            But I got the following error again:
            calling_card_reg # ant test
            Buildfile: build.xml
            
            compile-test:
            
            test:
             [junit] Testsuite: com.ip6networks.calling_card_registration.test.Client
             [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
             [junit]
             [junit] Null Test: Caused an ERROR
             [junit] com.ip6networks.calling_card_registration.test.Client
             [junit] java.lang.ClassNotFoundException: com.ip6networks.calling_card_registration.test.Client
             [junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
             [junit] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
             [junit] at java.lang.Class.forName0(Native Method)
             [junit] at java.lang.Class.forName(Class.java:247)
             [junit]
             [junit]
             [junit] Test com.ip6networks.calling_card_registration.test.Client FAILED
            
            BUILD SUCCESSFUL
            Total time: 1 second
            
            


            Thanks
            Sam,

            • 3. Re: Re: ant failed.
              Peter Johnson Master

              I thought you wanted to compile the test directory, not the Struts action directory. To compile only the test directory use:

              <javac srcdir="${tst-dir}"
               verbose="${TALK}"
               includes="com/ip6networks/calling_card_registration/test/*.java"
               >
               <classpath refid="classpath.test"/>
               </javac>


              You could even do this instead:

              <javac srcdir="${tst-dir}"
               verbose="${TALK}"
               includes="**/test/*.java"
               >
               <classpath refid="classpath.test"/>
               </javac>


              I notice that you have a ${TALK} attribute - I hope you are setting that to true because then the javac task will show you which java source files it is compiling. That can help you verify that the includes directive is correct set of files.

              • 4. Re: ant failed.
                sam wun Newbie

                Yeah it works in half way now...getting there...
                I just don't know what I have missing in the Client.java in order to run it with Junit. I searched google , but couldn't found definite/clear answer.
                the following errors shown:

                
                calling_card_reg # ant test
                Buildfile: build.xml
                
                compile-test:
                
                test:
                 [junit] Testsuite: com.ip6networks.calling_card_registration.test.Client
                 [junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0.011 sec
                 [junit]
                 [junit] Testcase: warning(junit.framework.TestSuite$1): FAILED
                 [junit] No tests found in com.ip6networks.calling_card_registration.test.Client
                 [junit] junit.framework.AssertionFailedError: No tests found in com.ip6networks.calling_card_registration.test.Client
                 [junit]
                 [junit]
                 [junit] Test com.ip6networks.calling_card_registration.test.Client FAILED
                
                BUILD SUCCESSFUL
                Total time: 2 seconds
                
                


                The source code for Client.java is shown below:
                package com.ip6networks.calling_card_registration.test;
                
                import com.ip6networks.calling_card_registration.test.Calculator;
                import com.ip6networks.calling_card_registration.test.CalculatorRemote;
                import com.ip6networks.calling_card_registration.test.ServiceLocator;
                
                public class Client
                {
                 public static void main(String[] args) throws Exception
                 {
                 Calculator calculator = getSession();
                 System.out.println("in Client class");
                 System.out.println("1 + 1 = " + calculator.add(1, 1));
                 System.out.println("1 - 1 = " + calculator.subtract(1, 1));
                
                 }
                
                 private static Calculator getSession() throws Exception {
                 Calculator mgr = null;
                 mgr = (Calculator) ServiceLocator.getInstance().getService("Calculator");
                 if (mgr == null) {
                 //throw new SystemErrorException("Unable to connect to service");
                 throw new Exception("Unable to connect to service");
                 } else {
                 return mgr;
                 }
                 }
                }
                
                


                Thanks very much.
                Sam


                • 5. Re: ant failed.
                  sam wun Newbie

                  Hi, I finally got that working.
                  Now the problem is with my Client.java code.

                  Here is the errors I am getting:

                  ...
                  Test:
                   [junit] Testsuite: com.ip6networks.calling_card_registration.test.Client
                   [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 1.497 sec
                   [junit]
                   [junit] ------------- Standard Error -----------------
                   [junit] javax.naming.NamingException: Could not dereference object [Root exception is java.lang.reflect.UndeclaredThrowableException]
                   [junit] at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1463)
                   [junit] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:809)
                  
                  


                  Here is the Client.java source code:
                  package com.ip6networks.calling_card_registration.test;
                  
                  import junit.framework.*;
                  import com.ip6networks.calling_card_registration.test.Calculator;
                  import com.ip6networks.calling_card_registration.test.CalculatorRemote;
                  import com.ip6networks.calling_card_registration.test.ServiceLocator;
                  
                  public class Client extends TestCase
                  {
                  
                   public void testCalculator() throws Exception
                   {
                   Calculator calculator = getSession();
                   System.out.println("in Client class");
                   System.out.println("1 + 1 = " + calculator.add(1, 1));
                   System.out.println("1 - 1 = " + calculator.subtract(1, 1));
                  
                   }
                  
                   private static Calculator getSession() throws Exception {
                   Calculator mgr = null;
                   mgr = (Calculator) ServiceLocator.getInstance().getService("Calculator");
                   if (mgr == null) {
                   //throw new SystemErrorException("Unable to connect to service");
                   throw new Exception("Unable to connect to service");
                   } else {
                   return mgr;
                   }
                   }
                  }
                  
                  


                  Source code for ServiceLocator.java:
                  package com.ip6networks.calling_card_registration.test;
                  
                   import javax.naming.Context;
                   import javax.naming.InitialContext;
                   import java.util.*;
                   import org.apache.commons.logging.LogFactory;
                   import org.apache.commons.logging.Log;
                  
                  public class ServiceLocator {
                   private Map<String, java.lang.Object> cache;
                   private static ServiceLocator ourInstance = new ServiceLocator();
                   private static final Log logger = LogFactory
                   .getLog(ServiceLocator.class);
                  
                   public static ServiceLocator getInstance() {
                   return ourInstance;
                   }
                  
                   private ServiceLocator() {
                   this.cache = Collections.synchronizedMap(
                   new HashMap<String, java.lang.Object>());
                   }
                  
                   public java.lang.Object getService(String serviceName) {
                   String serviceHost = "192.168.1.242";
                   if (this.cache.containsKey(serviceName)) {
                   return this.cache.get(serviceName);
                   }
                  
                   try {
                   java.lang.Object service = this.getContext(
                   serviceHost).lookup(
                   serviceName + "Bean/remote");
                   cache.put(serviceName, service);
                   return service;
                   } catch (Exception e) {
                   e.printStackTrace();
                   logger.error("Unable to bind to service "
                   + serviceName + ". Hostname: " + serviceHost, e);
                   return null;
                   } catch (Throwable e) {
                   e.printStackTrace();
                   logger.error("Unable to bind to service "
                   + serviceName + ". Hostname: " + serviceHost, e);
                   return null;
                   }
                  
                   }
                  
                   public java.lang.Object getService(String serviceName, String serviceHost) {
                   String key = serviceHost + "." + serviceName;
                   if (this.cache.containsKey(key)) {
                   return this.cache.get(key);
                   } else {
                   try {
                   java.lang.Object service = this.getContext(
                   serviceHost).lookup(
                   serviceName + "Bean/remote");
                   cache.put(key, service);
                   return service;
                   } catch (Exception e) {
                   logger.error("Unable to bind to service "
                   + serviceName + ". Hostname: " + serviceHost);
                   return null;
                   }
                   }
                   }
                  
                   private Context getContext(String serviceHost) throws javax.naming.NamingException
                   {
                   Properties properties = new Properties();
                   properties.put(Context.INITIAL_CONTEXT_FACTORY,
                   "org.jnp.interfaces.NamingContextFactory");
                   properties.put(Context.URL_PKG_PREFIXES,
                   "org.jboss.naming:org.jnp.interfaces");
                   properties.put(Context.PROVIDER_URL, serviceHost + ":1099");
                   return new InitialContext(properties);
                   }
                  }
                  
                  

                  If I run this code in the jboss environment (that is /usr/java-source/ejb3-tutorial/source/stateless), it runs well.

                  Thanks
                  Sam

                  • 6. Re: Re: ant failed.
                    Peter Johnson Master

                    Is that the full stack trace?

                    Is the app server running?

                    Looks like you are not including the JBoss AS client JARs in the classpath for running your unit tests.

                    • 7. Re: ant failed.
                      sam wun Newbie

                      The app server is running on another machine.
                      I heard that I need to compile the ejb3 server and client codes in one machine first, then copy the ejb3 client code to the client machine to make this work, is that true?
                      Here is the full trace at the client machine:

                      calling_card_reg # ant test
                      Buildfile: build.xml
                      
                      compile-test:
                       [javac] Compiling 4 source files
                       [javac] [parsing started /usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/src/com/ip6networks/calling_card_registration/test/Calculator.java]
                       [javac] [parsing completed 40ms]
                       [javac] [parsing started /usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/src/com/ip6networks/calling_card_registration/test/CalculatorRemote.java]
                       [javac] [parsing completed 2ms]
                       [javac] [parsing started /usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/src/com/ip6networks/calling_card_registration/test/Client.java]
                       [javac] [parsing completed 9ms]
                       [javac] [parsing started /usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/src/com/ip6networks/calling_card_registration/test/ServiceLocator.java]
                       [javac] [parsing completed 70ms]
                       [javac] [search path for source files: /usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/src]
                       [javac] [search path for class files: /usr/local/diablo-jdk1.6.0/jre/lib/resources.jar,/usr/local/diablo-jdk1.6.0/jre/lib/rt.jar,/usr/local/diablo-jdk1.6.0/jre/lib/sunrsasign.jar,/usr/local/diablo-jdk1.6.0/jre/lib/jsse.jar,/usr/local/diablo-jdk1.6.0/jre/lib/jce.jar,/usr/local/diablo-jdk1.6.0/jre/lib/charsets.jar,/usr/local/diablo-jdk1.6.0/jre/classes,/usr/local/diablo-jdk1.6.0/jre/lib/ext/sunjce_provider.jar,/usr/local/diablo-jdk1.6.0/jre/lib/ext/sunpkcs11.jar,/usr/local/diablo-jdk1.6.0/jre/lib/ext/dnsns.jar,/usr/local/diablo-jdk1.6.0/jre/lib/ext/localedata.jar,/usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/lib/junit.jar,/usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/src,/usr/local/share/java/apache-ant/lib/ant-launcher.jar,/usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg,/usr/local/diablo-jdk1.6.0/jre,/usr/local/jboss5/client/jboss-main-client.jar,/usr/local/jboss5/client/log4j.jar,/usr/local/jboss5/client/getopt.jar,/usr/local/jboss5/client/jboss-j2se.jar,/usr/local/jboss5/client/jmx-client.jar,/usr/local/jboss5/client/jboss-system-client.jar,/usr/local/jboss5/client/jboss-system-jmx-client.jar,/usr/local/jboss5/client/jbosssx-as-client.jar,/usr/local/jboss5/client/jbosssx-client.jar,/usr/local/jboss5/client/jmx-invoker-adaptor-client.jar,/usr/local/jboss5/client/jboss-client.jar,/usr/local/jboss5/client/concurrent.jar,/usr/local/jboss5/client/jboss-deployment.jar,/usr/local/jboss5/client/jboss-messaging-client.jar,/usr/local/jboss5/client/jboss-aop.jar,/usr/local/jboss5/client/jboss-remoting.jar,/usr/local/jboss5/client/javassist.jar,/usr/local/jboss5/client/trove.jar,/usr/local/jboss5/client/jboss-common-core.jar,/usr/local/jboss5/client/jboss-j2ee.jar,/usr/local/jboss5/client/jnp-client.jar,/usr/local/jboss5/client/commons-logging.jar,/usr/local/jboss5/client/jboss-ha-legacy-client.jar,/usr/local/jboss5/client/jbossjmx-ant.jar,/usr/local/jboss5/client/jboss-srp-client.jar,/usr/local/jboss5/client/scout.jar,/usr/local/jboss5/client/jboss-iiop-client.jar,/usr/local/jboss5/client/avalon-framework.jar,/usr/local/jboss5/client/logkit.jar,/usr/local/jboss5/client/jacorb.jar,/usr/local/jboss5/client/logkit-1.2.jar,/usr/local/jboss5/client/avalon-framework-4.1.5.jar,/usr/local/jboss5/client/concurrent-1.3.2.jar,/usr/local/jboss5/client/antlr-2.7.2.jar,/usr/local/jboss5/client/jboss-aspect-jdk50-client.jar,/usr/local/jboss5/client/jbosscx-client.jar,/usr/local/jboss5/client/jboss-jsr77-client.jar,/usr/local/jboss5/client/jboss-appclient.jar,/usr/local/jboss5/client/jboss-ejb3-proxy-clustered-client.jar,/usr/local/jboss5/client/jboss-ejb3-common-client.jar,/usr/local/jboss5/client/jboss-aop-client.jar,/usr/local/jboss5/client/jboss-ejb3-security-client.jar,/usr/local/jboss5/client/jboss-ejb3-proxy-client.jar,/usr/local/jboss5/client/ejb3-persistence.jar,/usr/local/jboss5/client/jboss-ejb3-ext-api-impl.jar,/usr/local/jboss5/client/jboss-ejb3-ext-api.jar,/usr/local/jboss5/client/hibernate-annotations.jar,/usr/local/jboss5/client/jboss-ejb3-core-client.jar,/usr/local/jboss5/client/jbossws-jboss50.jar,/usr/local/jboss5/client/streambuffer.jar,/usr/local/jboss5/client/jbossws-native-jaxws.jar,/usr/local/jboss5/client/wsdl4j.jar,/usr/local/jboss5/client/jbossws-common.jar,/usr/local/jboss5/client/jbossws-framework.jar,/usr/local/jboss5/client/jbossws-native-saaj.jar,/usr/local/jboss5/client/jaxb-xjc.jar,/usr/local/jboss5/client/jaxb-api.jar,/usr/local/jboss5/client/jaxb-impl.jar,/usr/local/jboss5/client/activation.jar,/usr/local/jboss5/client/jsr173_1.0_api.jar,/usr/local/jboss5/client/jaxb1-impl.jar,/usr/local/jboss5/client/jaxws-rt.jar,/usr/local/jboss5/client/jaxws-api.jar,/usr/local/jboss5/client/jsr181-api.jar,/usr/local/jboss5/client/jsr250-api.jar,/usr/local/jboss5/client/saaj-api.jar,/usr/local/jboss5/client/saaj-impl.jar,/usr/local/jboss5/client/jsr173_api.jar,/usr/local/jboss5/client/sjsxp.jar,/usr/local/jboss5/client/resolver.jar,/usr/local/jboss5/client/stax-ex.jar,/usr/local/jboss5/client/stax-utils.jar,/usr/local/jboss5/client/jettison.jar,/usr/local/jboss5/client/jbossws-spi.jar,/usr/local/jboss5/client/jaxws-tools.jar,/usr/local/jboss5/client/relaxngDatatype.jar,/usr/local/jboss5/client/wstx.jar,/usr/local/jboss5/client/FastInfoset.jar,/usr/local/jboss5/client/jbossws-native-jaxws-ext.jar,/usr/local/jboss5/client/stax-api.jar,/usr/local/jboss5/client/jbossws-native-core.jar,/usr/local/jboss5/client/jbossws-native-jaxrpc.jar,/usr/local/jboss5/client/jbossws-native-client.jar,/usr/local/jboss5/client/mail.jar,/usr/local/jboss5/client/jboss-xml-binding.jar,/usr/local/jboss5/client/policy.jar,/usr/local/jboss5/client/antlr.jar,/usr/local/jboss5/client/jboss-logging-jdk.jar,/usr/local/jboss5/client/slf4j-jboss-logging.jar,/usr/local/jboss5/client/jboss-deployers-core.jar,/usr/local/jboss5/client/jboss-deployers-vfs-spi.jar,/usr/local/jboss5/client/xmlsec.jar,/usr/local/jboss5/client/jboss-jaspi-api.jar,/usr/local/jboss5/client/jboss-integration.jar,/usr/local/jboss5/client/jboss-deployers-client-spi.jar,/usr/local/jboss5/client/jboss-metadata.jar,/usr/local/jboss5/client/slf4j-api.jar,/usr/local/jboss5/client/jboss-deployers-vfs.jar,/usr/local/jboss5/client/jboss-serialization.jar,/usr/local/jboss5/client/jboss-security-spi.jar,/usr/local/jboss5/client/jboss-ha-client.jar,/usr/local/jboss5/client/jboss-deployers-client.jar,/usr/local/jboss5/client/jboss-javaee.jar,/usr/local/jboss5/client/jboss-mdr.jar,/usr/local/jboss5/client/jboss-logging-spi.jar,/usr/local/jboss5/client/jboss-deployers-core-spi.jar,/usr/local/jboss5/client/jboss-logging-log4j.jar,/usr/local/jboss5/client/jbossall-client.jar,/usr/local/jboss5/client,/usr/local/share/java/apache-ant/lib/ant-antlr.jar,/usr/local/share/java/apache-ant/lib/ant-apache-bcel.jar,/usr/local/share/java/apache-ant/lib/ant-apache-bsf.jar,/usr/local/share/java/apache-ant/lib/ant-apache-log4j.jar,/usr/local/share/java/apache-ant/lib/ant-apache-oro.jar,/usr/local/share/java/apache-ant/lib/ant-apache-regexp.jar,/usr/local/share/java/apache-ant/lib/ant-apache-resolver.jar,/usr/local/share/java/apache-ant/lib/ant-commons-logging.jar,/usr/local/share/java/apache-ant/lib/ant-commons-net.jar,/usr/local/share/java/apache-ant/lib/ant-jai.jar,/usr/local/share/java/apache-ant/lib/ant-javamail.jar,/usr/local/share/java/apache-ant/lib/ant-jdepend.jar,/usr/local/share/java/apache-ant/lib/ant-jmf.jar,/usr/local/share/java/apache-ant/lib/ant.jar,/usr/local/share/java/apache-ant/lib/ant-jsch.jar,/usr/local/share/java/apache-ant/lib/ant-junit.jar,/usr/local/share/java/apache-ant/lib/ant-netrexx.jar,/usr/local/share/java/apache-ant/lib/ant-nodeps.jar,/usr/local/share/java/apache-ant/lib/ant-starteam.jar,/usr/local/share/java/apache-ant/lib/ant-stylebook.jar,/usr/local/share/java/apache-ant/lib/ant-swing.jar,/usr/local/share/java/apache-ant/lib/ant-testutil.jar,/usr/local/share/java/apache-ant/lib/ant-trax.jar,/usr/local/share/java/apache-ant/lib/ant-weblogic.jar,/usr/local/share/java/apache-ant/lib/xercesImpl.jar,/usr/local/share/java/apache-ant/lib/xml-apis.jar,/usr/local/diablo-jdk1.6.0/lib/tools.jar]
                       [javac] [loading java/lang/Object.class(java/lang:Object.class)]
                       [javac] [loading javax/ejb/Remote.class(javax/ejb:Remote.class)]
                       [javac] [loading junit/framework/TestCase.class(junit/framework:TestCase.class)]
                       [javac] [loading junit/framework/Test.class(junit/framework:Test.class)]
                       [javac] [loading junit/framework/Assert.class(junit/framework:Assert.class)]
                       [javac] [loading java/lang/Exception.class(java/lang:Exception.class)]
                       [javac] [loading javax/naming/Context.class(javax/naming:Context.class)]
                       [javac] [loading javax/naming/InitialContext.class(javax/naming:InitialContext.class)]
                       [javac] [loading org/apache/commons/logging/LogFactory.class(org/apache/commons/logging:LogFactory.class)]
                       [javac] [loading org/apache/commons/logging/Log.class(org/apache/commons/logging:Log.class)]
                       [javac] [loading java/util/Map.class(java/util:Map.class)]
                       [javac] [loading java/lang/String.class(java/lang:String.class)]
                       [javac] [loading javax/naming/NamingException.class(javax/naming:NamingException.class)]
                       [javac] [loading java/lang/annotation/Target.class(java/lang/annotation:Target.class)]
                       [javac] [loading java/lang/annotation/ElementType.class(java/lang/annotation:ElementType.class)]
                       [javac] [loading java/lang/annotation/Retention.class(java/lang/annotation:Retention.class)]
                       [javac] [loading java/lang/annotation/RetentionPolicy.class(java/lang/annotation:RetentionPolicy.class)]
                       [javac] [loading java/lang/annotation/Annotation.class(java/lang/annotation:Annotation.class)]
                       [javac] [checking com.ip6networks.calling_card_registration.test.Calculator]
                       [javac] [wrote /usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/src/com/ip6networks/calling_card_registration/test/Calculator.class]
                       [javac] [checking com.ip6networks.calling_card_registration.test.CalculatorRemote]
                       [javac] [wrote /usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/src/com/ip6networks/calling_card_registration/test/CalculatorRemote.class]
                       [javac] [checking com.ip6networks.calling_card_registration.test.Client]
                       [javac] [loading java/lang/Throwable.class(java/lang:Throwable.class)]
                       [javac] [loading java/lang/System.class(java/lang:System.class)]
                       [javac] [loading java/io/PrintStream.class(java/io:PrintStream.class)]
                       [javac] [loading java/io/FilterOutputStream.class(java/io:FilterOutputStream.class)]
                       [javac] [loading java/io/OutputStream.class(java/io:OutputStream.class)]
                       [javac] [loading java/lang/Error.class(java/lang:Error.class)]
                       [javac] [loading java/lang/RuntimeException.class(java/lang:RuntimeException.class)]
                       [javac] [loading java/lang/StringBuilder.class(java/lang:StringBuilder.class)]
                       [javac] [loading java/lang/AbstractStringBuilder.class(java/lang:AbstractStringBuilder.class)]
                       [javac] [loading java/lang/CharSequence.class(java/lang:CharSequence.class)]
                       [javac] [loading java/io/Serializable.class(java/io:Serializable.class)]
                       [javac] [loading java/lang/Comparable.class(java/lang:Comparable.class)]
                       [javac] [loading java/lang/StringBuffer.class(java/lang:StringBuffer.class)]
                       [javac] [wrote /usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/src/com/ip6networks/calling_card_registration/test/Client.class]
                       [javac] [checking com.ip6networks.calling_card_registration.test.ServiceLocator]
                       [javac] [loading java/lang/Class.class(java/lang:Class.class)]
                       [javac] [loading java/util/HashMap.class(java/util:HashMap.class)]
                       [javac] [loading java/util/AbstractMap.class(java/util:AbstractMap.class)]
                       [javac] [loading java/util/Collections.class(java/util:Collections.class)]
                       [javac] [loading javax/naming/Name.class(javax/naming:Name.class)]
                       [javac] [loading java/util/Properties.class(java/util:Properties.class)]
                       [javac] [loading java/util/Hashtable.class(java/util:Hashtable.class)]
                       [javac] [loading java/util/Dictionary.class(java/util:Dictionary.class)]
                       [javac] [loading org/apache/commons/logging/LogConfigurationException.class(org/apache/commons/logging:LogConfigurationException.class)]
                       [javac] [wrote /usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/src/com/ip6networks/calling_card_registration/test/ServiceLocator.class]
                       [javac] [total 1248ms]
                      
                      test:
                       [junit] Testsuite: com.ip6networks.calling_card_registration.test.Client
                       [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 1.016 sec
                       [junit]
                       [junit] ------------- Standard Output ---------------
                       [junit] in getSession()
                       [junit] ------------- ---------------- ---------------
                       [junit] ------------- Standard Error -----------------
                       [junit] javax.naming.NamingException: Could not dereference object [Root exception is java.lang.reflect.UndeclaredThrowableException]
                       [junit] at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1463)
                       [junit] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:809)
                       [junit] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:673)
                       [junit] at javax.naming.InitialContext.lookup(InitialContext.java:392)
                       [junit] at com.ip6networks.calling_card_registration.test.ServiceLocator.getService(Unknown Source)
                       [junit] at com.ip6networks.calling_card_registration.test.Client.getSession(Unknown Source)
                       [junit] at com.ip6networks.calling_card_registration.test.Client.testCalculator(Unknown Source)
                       [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                       [junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                       [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                       [junit] at java.lang.reflect.Method.invoke(Method.java:597)
                       [junit] at junit.framework.TestCase.runTest(TestCase.java:154)
                       [junit] at junit.framework.TestCase.runBare(TestCase.java:127)
                       [junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
                       [junit] at junit.framework.TestResult.runProtected(TestResult.java:124)
                       [junit] at junit.framework.TestResult.run(TestResult.java:109)
                       [junit] at junit.framework.TestCase.run(TestCase.java:118)
                       [junit] at junit.framework.TestSuite.runTest(TestSuite.java:208)
                       [junit] at junit.framework.TestSuite.run(TestSuite.java:203)
                       [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:420)
                       [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeInVM(JUnitTask.java:1339)
                       [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:831)
                       [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeOrQueue(JUnitTask.java:1785)
                       [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:785)
                       [junit] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
                       [junit] at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
                       [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                       [junit] at java.lang.reflect.Method.invoke(Method.java:597)
                       [junit] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
                       [junit] at org.apache.tools.ant.Task.perform(Task.java:348)
                       [junit] at org.apache.tools.ant.Target.execute(Target.java:357)
                       [junit] at org.apache.tools.ant.Target.performTasks(Target.java:385)
                       [junit] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
                       [junit] at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
                       [junit] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
                       [junit] at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
                       [junit] at org.apache.tools.ant.Main.runBuild(Main.java:758)
                       [junit] at org.apache.tools.ant.Main.startAnt(Main.java:217)
                       [junit] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
                       [junit] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
                       [junit] Caused by: java.lang.reflect.UndeclaredThrowableException
                       [junit] at $Proxy0.createProxyBusiness(Unknown Source)
                       [junit] at org.jboss.ejb3.proxy.objectfactory.session.SessionProxyObjectFactory.createProxy(SessionProxyObjectFactory.java:129)
                       [junit] at org.jboss.ejb3.proxy.objectfactory.session.stateless.StatelessSessionProxyObjectFactory.getProxy(StatelessSessionProxyObjectFactory.java:79)
                       [junit] at org.jboss.ejb3.proxy.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:156)
                       [junit] at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
                       [junit] at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1438)
                       [junit] at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1455)
                       [junit] ... 39 more
                       [junit] Caused by: java.lang.ClassNotFoundException: org.jboss.tutorial.stateless.bean.CalculatorRemote
                       [junit] at org.jboss.remoting.serialization.ClassLoaderUtility.loadClass(ClassLoaderUtility.java:103)
                       [junit] at org.jboss.remoting.loading.RemotingClassLoader.loadClass(RemotingClassLoader.java:86)
                       [junit] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
                       [junit] at java.lang.Class.forName0(Native Method)
                       [junit] at java.lang.Class.forName(Class.java:247)
                       [junit] at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveProxyClass(ObjectInputStreamWithClassLoader.java:250)
                       [junit] at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1531)
                       [junit] at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493)
                       [junit] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
                       [junit] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
                       [junit] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
                       [junit] at org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:119)
                       [junit] at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1792)
                       [junit] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1751)
                       [junit] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
                       [junit] at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
                       [junit] at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
                       [junit] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
                       [junit] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
                       [junit] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
                       [junit] at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObjectVersion2_2(JavaSerializationManager.java:238)
                       [junit] at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:138)
                       [junit] at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:123)
                       [junit] at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.versionedRead(MicroSocketClientInvoker.java:1215)
                       [junit] at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:845)
                       [junit] at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:160)
                       [junit] at org.jboss.remoting.Client.invoke(Client.java:1708)
                       [junit] at org.jboss.remoting.Client.invoke(Client.java:612)
                       [junit] at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:60)
                       [junit] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
                       [junit] at org.jboss.ejb3.proxy.remoting.IsLocalProxyFactoryInterceptor.invoke(IsLocalProxyFactoryInterceptor.java:72)
                       [junit] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
                       [junit] at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)
                       [junit] at $Proxy0.createProxyBusiness(Unknown Source)
                       [junit] at org.jboss.ejb3.proxy.objectfactory.session.SessionProxyObjectFactory.createProxy(SessionProxyObjectFactory.java:129)
                       [junit] at org.jboss.ejb3.proxy.objectfactory.session.stateless.StatelessSessionProxyObjectFactory.getProxy(StatelessSessionProxyObjectFactory.java:79)
                       [junit] at org.jboss.ejb3.proxy.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:156)
                       [junit] at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
                       [junit] at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1438)
                       [junit] at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1455)
                       [junit] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:809)
                       [junit] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:673)
                       [junit] at javax.naming.InitialContext.lookup(InitialContext.java:392)
                       [junit] at com.ip6networks.calling_card_registration.test.ServiceLocator.getService(Unknown Source)
                       [junit] at com.ip6networks.calling_card_registration.test.Client.getSession(Unknown Source)
                       [junit] at com.ip6networks.calling_card_registration.test.Client.testCalculator(Unknown Source)
                       [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                       [junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                       [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                       [junit] at java.lang.reflect.Method.invoke(Method.java:597)
                       [junit] at junit.framework.TestCase.runTest(TestCase.java:154)
                       [junit] at junit.framework.TestCase.runBare(TestCase.java:127)
                       [junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
                       [junit] at junit.framework.TestResult.runProtected(TestResult.java:124)
                       [junit] at junit.framework.TestResult.run(TestResult.java:109)
                       [junit] at junit.framework.TestCase.run(TestCase.java:118)
                       [junit] at junit.framework.TestSuite.runTest(TestSuite.java:208)
                       [junit] at junit.framework.TestSuite.run(TestSuite.java:203)
                       [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:420)
                       [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeInVM(JUnitTask.java:1339)
                       [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:831)
                       [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeOrQueue(JUnitTask.java:1785)
                       [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:785)
                       [junit] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
                       [junit] at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
                       [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                       [junit] at java.lang.reflect.Method.invoke(Method.java:597)
                       [junit] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
                       [junit] at org.apache.tools.ant.Task.perform(Task.java:348)
                       [junit] at org.apache.tools.ant.Target.execute(Target.java:357)
                       [junit] at org.apache.tools.ant.Target.performTasks(Target.java:385)
                       [junit] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
                       [junit] at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
                       [junit] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
                       [junit] at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
                       [junit] at org.apache.tools.ant.Main.runBuild(Main.java:758)
                       [junit] at org.apache.tools.ant.Main.startAnt(Main.java:217)
                       [junit] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
                       [junit] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
                       [junit] at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:72)
                       [junit] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
                       [junit] at org.jboss.ejb3.proxy.remoting.IsLocalProxyFactoryInterceptor.invoke(IsLocalProxyFactoryInterceptor.java:72)
                       [junit] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
                       [junit] at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)
                       [junit] ... 46 more
                       [junit] ------------- ---------------- ---------------
                       [junit] Testcase: testCalculator(com.ip6networks.calling_card_registration.test.Client): Caused an ERROR
                       [junit] Unable to connect to service
                       [junit] java.lang.Exception: Unable to connect to service
                       [junit] at com.ip6networks.calling_card_registration.test.Client.getSession(Unknown Source)
                       [junit] at com.ip6networks.calling_card_registration.test.Client.testCalculator(Unknown Source)
                       [junit]
                       [junit]
                       [junit] Test com.ip6networks.calling_card_registration.test.Client FAILED
                      
                      BUILD SUCCESSFUL
                      Total time: 5 seconds
                      
                      


                      • 8. Re: Re: ant failed.
                        Peter Johnson Master

                         

                        I heard that I need to compile the ejb3 server and client codes in one machine first, then copy the ejb3 client code to the client machine to make this work, is that true?

                        Yes.

                        Always follow the 'caused by' trail - the last one will tell you the root cause for the problem:

                        [junit] Caused by: java.lang.ClassNotFoundException: org.jboss.tutorial.stateless.bean.CalculatorRemote

                        Looks like your classpath doesn't include this class, which appears to be the interface of the EJB (one of the files you hopefully copied over in the text I quoted)

                        • 9. Re: Re: ant failed.
                          sam wun Newbie

                           

                          "PeterJ" wrote:
                          I heard that I need to compile the ejb3 server and client codes in one machine first, then copy the ejb3 client code to the client machine to make this work, is that true?

                          Yes.

                          Always follow the 'caused by' trail - the last one will tell you the root cause for the problem:

                          [junit] Caused by: java.lang.ClassNotFoundException: org.jboss.tutorial.stateless.bean.CalculatorRemote

                          Looks like your classpath doesn't include this class, which appears to be the interface of the EJB (one of the files you hopefully copied over in the text I quoted)


                          I have searched the referece of CalculatorRemote, apart from the "import" statement in the Client.java file, there is actually no use of it.
                          How does this class caused the run-time error like this?

                          Thanks
                          Sam

                          • 10. Re: Re: ant failed.
                            sam wun Newbie

                             

                            "PeterJ" wrote:
                            I heard that I need to compile the ejb3 server and client codes in one machine first, then copy the ejb3 client code to the client machine to make this work, is that true?

                            Yes.

                            Always follow the 'caused by' trail - the last one will tell you the root cause for the problem:

                            [junit] Caused by: java.lang.ClassNotFoundException: org.jboss.tutorial.stateless.bean.CalculatorRemote

                            Looks like your classpath doesn't include this class, which appears to be the interface of the EJB (one of the files you hopefully copied over in the text I quoted)


                            I think I need to make a JAR file include all the local remote interface classes, and then put it to the tomcat/lib/ folder. Can I use tar or jar command bundle the classes? IF not I may need to do it in the JBOSS applicaiton server as follow:
                            Change the EJB3 tutorial (in the JBOSS server) so that when it creates a JAR file, it should make a directory path com/ip6networks/calling_card_registration/... and bundled all classes according this path, then copy the JAR file into tomcat/lib/ folder before running the EJB client app.

                            Thanks
                            Sam

                            • 11. Re: Re: ant failed.
                              Peter Johnson Master

                              That might work. Basically, if you create an EJB3, then the JAR file should contain the local and remote interface classes and the implementation class. The remote interface class needs to be included in the client's classpath - for a simple test it is usually easier to just include it in the client's JAR file. To summarize:

                              somejb.jar:
                              org.xxx.yyy.EjbRemote.class
                              org.xxx.yyy.EjbLocal.class
                              org.xxx.yyy.EjbImpl.class

                              client.jar:
                              org.xxx.yyy.EjbRemote.class
                              org.xxx.yyy.Client.class

                              In Ant, when building the client you can use the 'includes' directive of a fileset to grab **/*Remote.class from the EJB build directory.

                              • 12. Re: Re: ant failed.
                                sam wun Newbie

                                 

                                "PeterJ" wrote:
                                That might work. Basically, if you create an EJB3, then the JAR file should contain the local and remote interface classes and the implementation class. The remote interface class needs to be included in the client's classpath - for a simple test it is usually easier to just include it in the client's JAR file. To summarize:

                                somejb.jar:
                                org.xxx.yyy.EjbRemote.class
                                org.xxx.yyy.EjbLocal.class
                                org.xxx.yyy.EjbImpl.class

                                client.jar:
                                org.xxx.yyy.EjbRemote.class
                                org.xxx.yyy.Client.class

                                In Ant, when building the client you can use the 'includes' directive of a fileset to grab **/*Remote.class from the EJB build directory.


                                Hi, thanks for the suggestion.
                                I have done the following test, it still faield with the same errors (Remote inteface not found):

                                First try:
                                I put the includes directive of fileset for **/*Remote.class in the build.xml file:
                                <property name="tst-dir" location="docroot/WEB-INF/src" />
                                 <property name="TALK" value="true" />
                                
                                 <path id="classpath.base">
                                 </path>
                                 <path id="classpath.test">
                                 <pathelement location="/usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/lib/junit.jar" />
                                 <pathelement location="${tst-dir}" />
                                 <path refid="classpath.base" />
                                 </path>
                                 <fileset dir="${tst-dir}" includes="**/*.class" />
                                
                                 <target name="compile-test">
                                ...
                                


                                Second try:
                                I made a jar file with the following commandline:
                                # jar cvfm calling_card_reg.jar com/ip6networks/calling_card_registration/test/*.class
                                added manifest
                                adding: com/ip6networks/calling_card_registration/test/CalculatorRemote.class(in = 241) (out= 162)(deflated 32%)
                                adding: com/ip6networks/calling_card_registration/test/Client.class(in = 1261) (out= 633)(deflated 49%)
                                adding: com/ip6networks/calling_card_registration/test/ServiceLocator.class(in = 2571) (out= 1218)(deflated 52%)
                                freetimed:classes # pwd
                                /usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/classes
                                # cp calling_card_reg.jar ../lib/
                                # cp calling_card_reg.jar $DEV/../tomcat-6.0.18/lib/
                                


                                But I don't think the jar command is correct because when I use tar to "view" the content of this jar file, there is error:
                                 # tar -ztvf calling_card_reg.jar
                                drwxrwxrwx 0 0 0 0 Jul 22 11:07 META-INF/
                                tar: Bad ZIP file: Unexpected end-of-entry record
                                tar: Error exit delayed from previous errors.
                                


                                I normally can use tar command to view any jar file, but not the one I created.

                                Thanks
                                Sam

                                • 13. Re: Re: ant failed.
                                  Peter Johnson Master

                                  Please quit quoting my posts - it only makes your replies more difficult to read.

                                  Why are you using tar to view the jar file? Use the jar utility instead: jar tf calling_card_reg.jar

                                  Why are you placing the client JAR file into Tomcat? Where are you running your client from?

                                  • 14. Re: ant test failed.
                                    sam wun Newbie

                                    Thanks for the hints.
                                    After copied the jar file to the "current" directory where the "ant test" is running, now I got th following error:

                                    calling_card_reg # ant test
                                    Buildfile: build.xml
                                    
                                    compile-test:
                                    
                                    test:
                                     [junit] Testsuite: com.ip6networks.calling_card_registration.test.Client
                                     [junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0.012 sec
                                     [junit]
                                     [junit] Testcase: warning(junit.framework.TestSuite$1): FAILED
                                     [junit] No tests found in com.ip6networks.calling_card_registration.test.Client
                                     [junit] junit.framework.AssertionFailedError: No tests found in com.ip6networks.calling_card_registration.test.Client
                                     [junit]
                                     [junit]
                                     [junit] Test com.ip6networks.calling_card_registration.test.Client FAILED
                                    
                                    BUILD SUCCESSFUL
                                    Total time: 2 seconds
                                    


                                    here is my Client.java source code:
                                    # cat Client.java
                                    package com.ip6networks.calling_card_registration.test;
                                    
                                    import junit.framework.*;
                                    import com.ip6networks.calling_card_registration.test.Calculator;
                                    import com.ip6networks.calling_card_registration.test.CalculatorRemote;
                                    import com.ip6networks.calling_card_registration.test.ServiceLocator;
                                    
                                    public class Client extends TestCase
                                    {
                                    /*
                                     public static void main(String[] args) throws Exception
                                    */
                                     public void testCalculator() throws Exception
                                     {
                                     Calculator calculator = getSession();
                                     System.out.println("in Client class");
                                     System.out.println("1 + 1 = " + calculator.add(1, 1));
                                     System.out.println("1 - 1 = " + calculator.subtract(1, 1));
                                    
                                     }
                                    
                                     private static Calculator getSession() throws Exception {
                                    System.out.println("in getSession()");
                                     Calculator mgr = null;
                                     mgr = (Calculator) ServiceLocator.getInstance().getService("Calculator");
                                     if (mgr == null) {
                                     //throw new SystemErrorException("Unable to connect to service");
                                     throw new Exception("Unable to connect to service");
                                     } else {
                                     return mgr;
                                     }
                                     }
                                    }
                                    
                                    


                                    Thanks
                                    Sam

                                    1 2 Previous Next