Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / August 2004

Tip: Looking for answers? Try searching our database.

Exception in thread "main" javax.naming.NameNotFoundException: HelloHome not bound

Thread view: 
bard - 28 Feb 2004 11:07 GMT
I'm studing Mastering2 EJB exercise but I have a Problem when I run the client:

Exception in thread "main" javax.naming.NameNotFoundException: HelloHome not bound
    [java]     at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
    [java]     at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
    [java]     at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
    [java]     at org.jnp.server.NamingServer.lookup(NamingServer.java:282)
    [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.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(TCPTransport.java:460)
    [java]     at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
    [java]     at java.lang.Thread.run(Thread.java:534)
    [java]     at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
    [java]     at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.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 JavaBeans 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:34,069 INFO  [MainDeployer] Starting deployment of package: file:/home/raffaele/jboss-3.2.3/server/default/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
bard - 02 Mar 2004 12:02 GMT
Why aniyone help me?
I need your helps.
Thanks bard
Marek Lange - 09 Mar 2004 13:26 GMT
> I'm studing Mastering2 EJB exercise but I have a Problem when I run the client:
> Exception in thread "main" javax.naming.NameNotFoundException: HelloHome not bound

>     <jndi-name>HelloLocalHome</jndi-name>
>         Object obj = ctx.lookup("HelloHome");

You see the difference?

-marek
nix0286 - 19 Aug 2004 09:54 GMT
got the solution for the above question. if any body is intrested mail me
at niravmalavia@yahoo.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.