• 2 replies
  • Latest Post - ‏2009-09-23T10:40:42Z by SystemAdmin
4672 Posts

Pinned topic newbie trying to implement ejb3 helloworld example on was7

‏2009-09-22T10:29:48Z |
Hi. I have successfully deployed and started an ear to WAS 7 which contains a jar containing the following two classes:

package com.mybiz.server;   

import javax.ejb.Local;   @Local 


interface HelloWorld 

public String getMessage(); 

package com.mybiz.server;   

import javax.ejb.Stateless;   @Stateless 


class HelloWorldImpl 

implements HelloWorld 

public String getMessage() 

"Hello World"; 

Now all I want to do is simply invoke the getMessage, hence I developed the following

package com.mybiz.client;   

import javax.ejb.EJB; 

import com.mybiz.HelloWorld;   


class Client  

private @EJB HelloWorld hello; 



void main(String[] args) 
{ Client client = 

new Client(); client.doTest(); 


void doTest()
{ System.out.println(hello.getMessage()); 

Now what I do next is unclear to me. After reading here my understanding is I need to package my client class into a jar and then a ejb. So I developed my ant script as follows:

<target name=
"makeear">   <ear earfile=
"${build}/jar/HelloWorldServer.ear" appxml=
"${build}/META-INF/application.xml"> <fileset dir=
"${build}/jar"> <include name=
"HelloWorldServer.jar" /> </fileset> </ear>   <ear earfile=
"${build}/jar/HelloWorldClient.ear" appxml=
"${build}/META-INF/application-client.xml"> <fileset dir=
"${build}/jar"> <include name=
"HelloWorldClient.jar" /> </fileset> </ear>   </target>

Within HelloWorldClient.ear the application-client.xml is present but it has been renamed application.xml??? Also what should the contents of the application-client.xml be? My application-client.xml is as follows:

<application-client > </application-client>

When I execute 'launchClient C:\HelloWorld\build\jar\helloWorldClient.ear' I get the error:
WSCL0200E: The Enterprise Archive file C:\HelloWorld\build\jar\helloWorldClient.ear does not contain an Application Client jar file.
Updated on 2009-09-23T10:40:42Z at 2009-09-23T10:40:42Z by SystemAdmin
  • SystemAdmin
    4672 Posts

    Re: newbie trying to implement ejb3 helloworld example on was7

    I have made some changes. I have put HelloWorldClient.jar into HelloWorldServer.ear. Now when I execute 'launchClient C:\HelloWorld\build\jar\HelloWorldServer.ear' i am still getting the same message. I think its probably because of my application-client.xml. I am able to deploy and start the ear successfully. The following is my ant script

    <?xml version=
    "1.0" encoding=
    "UTF-8"?> <project default=
    "build" basedir=
    ".">   <property name=
    "build" value=
    "C:/HelloWorld/build" /> <property name=
    "build.class" value=
    "${build}/class" /> <property name=
    "WSAS.home" value=
    "C:/Program Files/IBM/WebSphere/AppServer" /> <property name=
    "src" value=
    "C:/HelloWorld/src" />   <path id=
    "lib.path"> <pathelement location=
    "${WSAS.home}/lib/*.jar" /> <pathelement location=
    "C:\crs517\lib\javaee.jar" /> </path>   <taskdef name=
    "wsejbdeploy" classname=
    ""> <classpath refid=
    "lib.path" /> </taskdef>   <taskdef name=
    "installapp" classname=
    ""> <classpath refid=
    "lib.path" /> </taskdef>   <target name=
    "build" depends=
    "clean, mkDirStructure,compileservice, copyMetaInf,makejar,makeear,ejbdeploy,install" />   <target name=
    "buildear" depends=
    "makeear" />   <target name=
    "clean"> <delete includeEmptyDirs=
    "true"> <fileset dir=
    "${build}" /> </delete> </target>   <target name=
    "mkDirStructure"> <mkdir dir=
    "${build}" /> <mkdir dir=
    "${build.class}" /> <mkdir dir=
    "${build}/jar" /> <mkdir dir=
    "${build}/META-INF" /> </target>   <target name=
    "compileservice"> <javac srcdir=
    "${src}" destdir=
    "${build.class}"> <classpath refid=
    "lib.path" /> <include name=
    "**/*.java" /> </javac> </target>   <target name=
    "copyMetaInf"> <copy todir=
    "${build}/META-INF"> <fileset dir=
    "${src}/META-INF"> <include name=
    "*" /> </fileset> </copy> </target>     <target name=
    "makejar">   <jar jarfile=
    "${build}/jar/HelloWorldServer.jar"> <fileset dir=
    "${build}"> <include name=
    "class/com/mybiz/server/**/*" /> </fileset> </jar> <jar jarfile=
    "${build}/jar/HelloWorldClient.jar"> <fileset dir=
    "${build}"> <include name=
    "class/com/mybiz/client/**/*" /> <include name=
    "META-INF/application-client.xml"/> </fileset> </jar>   </target>     <target name=
    "makeear">   <ear earfile=
    "${build}/jar/HelloWorldServer.ear" appxml=
    "${build}/META-INF/application.xml"> <fileset dir=
    "${build}/jar"> <include name=
    "HelloWorldServer.jar" /> <include name=
    "HelloWorldClient.jar" /> </fileset> </ear>   </target>   <target name=
    "ejbdeploy">   <wsejbdeploy inputJar=
    "${build}/jar/HelloWorldServer.ear" wasHome=
    "${WSAS.home}" workingDirectory=
    "${build}/jar" outputJar=
    "${build}/jar/HelloWorldServerDeployed.ear" codegen=
    "false" keepGenerated=
    "false" quiet=
    "true" noValidate=
    "false" noWarnings=
    "false" noInform=
    "false" failonerror=
    "true" trace=
    "false" />   </target>   <target name=
    "install">   <installapp wasHome=
    "${WSAS.home}" ear=
    "${build}/jar/HelloWorldServerDeployed.ear" options=
    "-usedefaultbindings" conntype=
    "NONE" failonerror=
    "true" />   </target>   </project>
  • SystemAdmin
    4672 Posts

    Re: newbie trying to implement ejb3 helloworld example on was7

    Right yet more changes but still the same error. I have changed around my ant script as follows

    HelloWorldServer.jar contains HelloWorld .class and HelloWorldImpl.class

    HelloWorldClient.jar contains Client.class and the following
    Manifest-Version: 1.0 Ant-Version: Apache Ant 1.6.5 Created-By: 2.4 (IBM Corporation) Main-Class: com.mybiz.client.Client Class-Path:  HelloWorldServer.jar

    HelloWorldServer.ear contains the above two jars and the following application.xml
    <application> <module> <ejb>HelloWorldServer.jar</ejb> </module> </application>