Code Comments
Programming Forum and web based access to our favorite programming groups.I'm studing Mastering2 EJB exercise but I have a Problem when I run the clie
nt:
Exception in thread "main" javax.naming.NameNotFoundException: HelloHome not
bound
[java] at org.jnp.server.NamingServer.getBinding(NamingServer.java:4
95)
[java] at org.jnp.server.NamingServer.getBinding(NamingServer.java:5
03)
[java] at org.jnp.server.NamingServer.getObject(NamingServer.java:50
9)
[java] at org.jnp.server.NamingServer.lookup(NamingServer.java:282)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method
)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAc
cessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Delegating
MethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:324)
[java] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.
java:261)
[java] at sun.rmi.transport.Transport$1.run(Transport.java:148)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at sun.rmi.transport.Transport.serviceCall(Transport.java:144
)
[java] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTrans
port.java:460)
[java] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(T
CPTransport.java:701)
[java] at java.lang.Thread.run(Thread.java:534)
[java] at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromSe
rver(StreamRemoteCall.java:247)
[java] at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemot
eCall.java:223)
[java] at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
[java] at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
[java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java
:528)
[java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java
:507)
[java] at javax.naming.InitialContext.lookup(InitialContext.java:347
)
[java] at src.HelloClient.main(HelloClient.java:38)
jboss.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN"
"http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
<jboss>
<enterprise-beans>
<ejb-name>Hello</ejb-name>
<jndi-name>HelloLocalHome</jndi-name>
<configuration-name>Standard Stateless SessionBean</configuration-name>
</enterprise-beans>
</jboss>
ejb-jar.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBean
s 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>Hello</ejb-name>
<home>examples.HelloHome</home>
<remote>examples.Hello</remote>
<local-home>examples.HelloLocalHome</local-home>
<local>src.HelloLocal</local>
<ejb-class>examples.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>
HelloClient.java is:
package src;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Properties;
import javax.rmi.PortableRemoteObject;
import src.Hello;
import src.HelloHome;
/**
* This class is an example of client code which invokes
* methods on a simple stateless session bean.
*/
public class HelloClient {
public static void main(String[] args) throws Exception {
/*
* Setup properties for JNDI initialization.
*
* These properties will be read-in from
* the command-line.
*/
Properties props = System.getProperties();
/*
* Obtain the JNDI initial context.
*
* The initial context is a starting point for
* connecting to a JNDI tree. We choose our JNDI
* driver, the network location of the server, etc
* by passing in the environment properties.
*/
Context ctx = new InitialContext(props);
/*
* Get a reference to the home object - the
* factory for Hello EJB Objects
*/
Object obj = ctx.lookup("HelloHome");
/*
* Home objects are RMI-IIOP objects, and so
* they must be cast into RMI-IIOP objects
* using a special RMI-IIOP cast.
*
* See Appendix X for more details on this.
*/
HelloHome home = (HelloHome)
javax.rmi.PortableRemoteObject.narrow(
obj, HelloHome.class);
/*
* Use the factory to create the Hello EJB Object
*/
Hello hello = home.create();
/*
* Call the hello() method on the EJB object. The
* EJB object will delegate the call to the bean,
* receive the result, and return it to us.
*
* We then print the result to the screen.
*/
System.out.println(hello.hello());
/*
* Done with EJB Object, so remove it.
* The container will destroy the EJB object.
*/
hello.remove();
}
}
I'm using Ant to compile and create jar file. When jar file is created, and
when I put Hello.jar file in jboss deploy directory, the server give 11:09:3
4,069 INFO [MainDeployer] Starting deployment of package: file:/home/ra
ffaele/jboss-3.2.3/server/defau
lt/deploy/Hello.jar
11:09:34,074 INFO [MainDeployer] Deployed package: file:/home/raffaele/
jboss-3.2.3/server/default/deploy/Hello.jar
and I go to http://localhost:8080/jmx-console/index.jsp jboss.j2ee, nothing
happened.
The build.xml file is
?xml version="1.0"?>
<!--Esempio: Hello World-->
<project name="JBoss" default="ejbjar" basedir=".">
<property environment="env"/>
<property name="src.dir" value="${basedir}"/>
<property name="src.resources" value="${basedir}/deployment/META-INF"/>
<property name="jboss.home" value="${env.JBOSS_HOME}"/>
<property name="build.dir" value="${basedir}/build"/>
<property name="build.classes.dir" value="${build.dir}/classes"/>
<!-- Build classpath -->
<path id="classpath">
<fileset dir="${jboss.home}/client">
<include name="**/*.jar"/>
</fileset>
<pathelement location="${build.classes.dir}"/>
<pathelement location="${basedir}/jndi"/>
</path>
<property name="build.classpath" refid="classpath"/>
<!--Provo a compilare-->
<target name="compila" depends="prepara" description="compila i file .java">
<javac srcdir="${src.dir}/src"
destdir="${build.classes.dir}"
debug="on"
deprecation="on"
optimize="off"
includes="**">
<classpath refid="classpath"/>
</javac>
</target>
<!--Costruisco la dirctory-->
<target name="prepara">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.classes.dir}"/>
</target>
<target name="ejbjar" depends="compila">
<jar jarfile="build/Hello.jar">
<fileset dir="${src.resources}">
<include name="**/*.xml"/>
</fileset>
<fileset dir="${build.classes.dir}">
<include name="*/*.class"/>
</fileset>
</jar>
<copy file="build/Hello.jar" todir="${jboss.home}/server/default/deploy
"/>
</target>
<!--Provo ad eseguire-->
<target name="run.Client" depends="ejbjar">
<java classname="src/HelloClient" fork="yes" dir=".">
<classpath refid="classpath"/>
</java>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
<delete file="${jboss.home}/server/default/deploy/Hello.jar"/>
</target>
<target name="clean.db" depends="clean">
<delete dir="${jboss.home}/server/default/data/hypersonic"/>
</target>
</project>
PLEASE, can anyone help me? I'm desperate.
Thanks very much in advance
bard
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.