Based on your ejb-jar.xml file:
<ejb-jar>
<description>Lek med beans</description>
<display-name>TestAvBeans</display-name>
<enterprise-beans>
<session>
<ejb-name>parfo.Hello</ejb-name>
<home>parfo.HelloHome</home>
<remote>parfo.Hello</remote>
<ejb-class>parfo.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>
>From a client application (note the *client*), you would get a reference to
the the EJBHome using:
Object boundObject = context.lookup("parfo.Hello");
HelloHome helloHome = (HelloHome)PortableRemoteObject.narrow(
boundObject, HelloHome.class);
That is assuming that you don't override the jndi name for the bean in a
jboss.xml file. I don't believe it is spec-compliant (IIRC) to use the
<ejb-name> as the jndi-name, but jBoss does so as a simplification step.
Other servers require you to specify the jndi name for a bean in another
"proprietary" deployment descriptor. For jBoss, this proprietary file is
called jboss.xml:
<jboss>
<enterprise-beans>
<session>
<ejb-name>parfo.Hello</ejb-name>
<jndi-name>parfo/Hello</jndi-name>
</session>
</enterprise-beans>
</jboss>
With this file deployed with your bean, your lookup code would be changed
to:
Object boundObject = context.lookup("parfo/Hello");
So, perhaps you tried all of these options and it still doesn't work.
Perhaps there is a subtle setup error, configuration error, or a bug in the
product. Don't know. I have always used slashes to separate my naming
contexts, but many people use periods as you have. I can't imagine that this
is the source of a bug.
jim
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Pär Fornland
> Sent: Wednesday, March 07, 2001 7:21 PM
> To: 'JBoss-User'
> Subject: [jBoss-User] ouch, newbie trouble
>
>
> Hi guys,
>
> I am investigating how useful EJB can be for the product for
> which I am the
> architect. I know just the big picture of EJB. Downloaded jBoss, and
> guess how pleased I was to see it running immediately. Wrote a
> simple Hello
> World example, and could _deploy_ it successfully immediately too.
> Happiness!
>
> Running Solaris, JDK1.3, jBoss-2.0-FINAL.
>
> Enter: dark clouds
>
> I have been trying for DAYS now to run my client. I've tried
> modifying the
> ejb-jar.xml. I've tried changing names of packages. I've tried adding a
> jboss.xml file. I've tried many ways to write the client. It just won't
> run. (I've searched the archive of this list, but didn't find anything
> similar.)
>
> I get this when I deploy it:
> +++++++++++++++
> [Auto deploy] Auto deploy of
> file:/info/dev-parfo/jBoss-2.0_FINAL/deploy/HelloWorld.ja
> r
> [J2EE Deployer] Stopping module HelloWorld.jar
> [Container factory]
> Undeploying:file:/info/dev-parfo/jBoss-2.0_FINAL/bin/../tmp/deploy
> /HelloWorl
> d.jar/ejb1020.jar
> [Container factory] Undeployed application:
> file:/info/dev-parfo/jBoss-2.0_FINAL/bin/../tmp/deploy/HelloWorld.
> jar/ejb102
> 0.jar
> [J2EE Deployer] Destroying application HelloWorld.jar
> [J2EE Deployer] deployment.cfg file deleted.
> [J2EE Deployer] File tree
> file:/info/dev-parfo/jBoss-2.0_FINAL/tmp/deploy/HelloWorld.jar deleted.
> [J2EE Deployer] Deploy J2EE application:
> file:/info/dev-parfo/jBoss-2.0_FINAL/deploy/HelloWorld.jar
> [J2EE Deployer] Create application HelloWorld.jar
> [J2EE Deployer] Installing EJB package: HelloWorld.jar
> [J2EE Deployer] Starting module HelloWorld.jar
> [Container factory]
> Deploying:file:/info/dev-parfo/jBoss-2.0_FINAL/bin/../tmp/deploy/H
> elloWorld.
> jar/ejb1022.jar
> [Verifier] Verifying
> file:/info/dev-parfo/jBoss-2.0_FINAL/bin/../tmp/deploy/HelloWorld.
> jar/ejb102
> 2.jar
> [Container factory] Deploying parfo.Hello
> [Container factory] Deployed application:
> file:/info/dev-parfo/jBoss-2.0_FINAL/bin/../tmp/deploy/HelloWorld.
> jar/ejb102
> 2.jar
> [J2EE Deployer] J2EE application:
> file:/info/dev-parfo/jBoss-2.0_FINAL/deploy/HelloWorld.jar is deployed.
> +++++++++++++++++
>
>
> Is that correct?
>
> Then when I run my client, I get this error:
> ++++++++++++++++++
> javax.naming.NameNotFoundException: parfo.HelloHome not bound
> at
> sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Str
> eamRemoteC
> all.java:245)
> at
> sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
> at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
> at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
> at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:295)
> at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:279)
> at javax.naming.InitialContext.lookup(InitialContext.java:350)
> at HelloClient.main(HelloClient.java:23)
> +++++++++++++++++
>
>
> My ejb-jar.xml looks like this:
> +++++++++++++
> <?xml version="1.0" encoding="Cp1252"?>
> <ejb-jar>
> <description>Lek med beans</description>
> <display-name>TestAvBeans</display-name>
> <enterprise-beans>
> <session>
> <ejb-name>parfo.Hello</ejb-name>
> <home>parfo.HelloHome</home>
> <remote>parfo.Hello</remote>
> <ejb-class>parfo.HelloBean</ejb-class>
> <session-type>Stateless</session-type>
> <transaction-type>Bean</transaction-type>
> </session>
> </enterprise-beans>
> </ejb-jar>
> ++++++++++++++++++
>
>
> My client code looks like this:
> ++++++++++++++
> import parfo.*;
>
> import javax.ejb.*;
> import javax.naming.*;
> import javax.rmi.*;
> import java.util.*;
>
> public class HelloClient {
> public static void main(String[] args) {
> try {
> System.setProperty("java.naming.factory.initial",
> "org.jnp.interfaces.NamingContextFactory");
> System.setProperty("java.naming.provider.url",
> "localhost:1099");
>
> Properties props = System.getProperties();
> System.out.println("Got props");
>
> Context ctx = new InitialContext(props);
> System.out.println("Got context");
>
> Context context = new InitialContext();
> Object boundObject = context.lookup("java:parfo.HelloHome");
> HelloHome helloHome = (HelloHome) PortableRemoteObject.narrow(
> boundObject, HelloHome.class);
> Hello _hello = helloHome.create();
>
> HelloHome home;
> home = (HelloHome) ctx.lookup("java:parfo/HelloHome");
> System.out.println("Got home object #1");
>
> home = (HelloHome) ctx.lookup("HelloHome");
> System.out.println("Got home object #2");
>
> home = (HelloHome) PortableRemoteObject.narrow(
> ctx, HelloHome.class);
> System.out.println("Got home object #3");
>
> Hello hello = home.create();
>
> System.out.println(hello.hello());
>
> hello.remove();
> }
> catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
> ++++++++++++
>
> and even though I try different ways to get the reference to the Home
> object, none of them work (I comment out different ones to test.)
>
> Any ideas?
>
> Kind regards
> Pär
>
>
> ______________________________________s_p_r_a_y_
> Dr. Pär Fornland
>
>
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
>
>
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]