I really don't see anything specifically wrong based on the file information
you posted. But, when you changed your classpath, you should have now gotten a
different error message, but since you didn't post the new error, I can't tell
what is still wrong (possibly you are not including your ejb jar file in the
client classpath?).
I decided to post a full EJB. I am using JBoss 4.0.3SP1, Sun JVM 1.5.0_06,
XDoclet 1.2.3 and Ant 1.6.5.
File: src/main/java/peter/HelloBean.java
package peter;
| import java.rmi.RemoteException;
| import javax.ejb.CreateException;
| import javax.ejb.EJBException;
| import javax.ejb.SessionBean;
| import javax.ejb.SessionContext;
| /**
| * @ejb.bean name="Hello" display-name="HelloBean" jndi-name="HelloRemote"
| * type="Stateless" transaction-type="Container" view-type="remote"
| */
| public class HelloBean implements SessionBean {
| private SessionContext ctx;
| public void setSessionContext(SessionContext ctx) throws EJBException,
| RemoteException {
| this.ctx = ctx;
| }
| public void ejbRemove() throws EJBException, RemoteException {}
| public void ejbActivate() throws EJBException, RemoteException {}
| public void ejbPassivate() throws EJBException, RemoteException {}
| public void ejbCreate() throws CreateException {}
| /**
| * @ejb.interface-method view-type="remote"
| * @ejb.transaction type="Supports"
| */
| public String sayHello() throws EJBException {
| return "You say good-bye, but I say hello.";
| }
| }
File: src/main/java/peter/Client.java
package peter;
| import java.util.Hashtable;
| import javax.naming.Context;
| import javax.naming.InitialContext;
| import javax.rmi.PortableRemoteObject;
| public class Client {
| public static void main(String[] args) throws Exception {
| Hashtable env = new Hashtable();
| env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
| env.put(Context.PROVIDER_URL, "localhost:1099");
| Context ctx = new InitialContext(env);
| Object obj = ctx.lookup("HelloRemote");
| HelloRemoteHome home =
(HelloRemoteHome)PortableRemoteObject.narrow(obj, HelloRemoteHome.class);
| HelloRemote hello = home.create();
| System.out.println(hello.sayHello());
| }
| }
File: build.xml
<project name="helloejb" default="all" basedir=".">
| <property environment="env" />
| <property name="dir.java" location="src/main/java" />
| <property name="dir.gen.java" location="target/gen/java" />
| <property name="dir.gen.ejb" location="target/gen/ejb" />
| <property name="dir.class" location="target/classes" />
| <property name="dir.dist" location="target" />
| <property name="jar.name" value="${ant.project.name}.jar" />
| <property name="jar.path" location="${dir.dist}/${jar.name}" />
| <path id="compile.classpath">
| <fileset dir="${env.XDOCLET_HOME}/lib" includes="**/*.jar" />
| <fileset dir="${env.JBOSS_HOME}/client" includes="**/*.jar" />
| </path>
| <target name="all" depends="jar" />
| <target name="clean">
| <delete dir="target" includeemptydirs="true" />
| </target>
| <target name="compile">
| <mkdir dir="${dir.class}" />
| <javac debug="true" srcdir="${dir.java}:${dir.gen.java}"
destdir="${dir.class}">
| <classpath refid="compile.classpath" />
| </javac>
| </target>
| <target name="jar" depends="ejbdoclet, compile">
| <mkdir dir="${dir.dist}" />
| <jar destfile="${jar.path}">
| <fileset dir="${dir.class}" />
| <metainf dir="${dir.gen.ejb}" />
| </jar>
| </target>
| <target name="ejbdoclet">
| <taskdef name="ejbdoclet"
| classname="xdoclet.modules.ejb.EjbDocletTask"
| classpathref="compile.classpath"
| />
| <mkdir dir="${dir.gen.java}" />
| <mkdir dir="${dir.gen.ejb}" />
| <ejbdoclet destdir="${dir.gen.java}" ejbspec="2.1">
| <fileset dir="${dir.java}">
| <include name="**/*Bean.java" />
| </fileset>
| <remoteinterface pattern="{0}Remote" />
| <homeinterface pattern="{0}RemoteHome" />
| <deploymentdescriptor destdir="${dir.gen.ejb}" />
| <jboss version="4.0" destdir="${dir.gen.ejb}" />
| </ejbdoclet>
| </target>
| </project>
To use:
1) Create the above files
2) Set the XDOCLET_HOME and JBOSS_HOME environment variables
3) Build using Ant
4) Copy the ejbhello.jar file to JBOSS_HOME/server/default/deploy
5) Start JBoss
6) Run the client, as follows (assumes Windows, adjust for *nix):
java -cp target\classes;%JBOSS_HOME%\client\jbossall-client.jar peter.Client
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3936670#3936670
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3936670
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user