ejb@glassfish.java.net

Re: JNDI default name

From: Kenneth Saks <Kenneth.Saks_at_Sun.COM>
Date: Mon, 13 Feb 2006 10:37:28 -0500

Hannes Stauss wrote:

>Sorry for boring you with such issues, I just found out that I have omitted
>the @Stateless annotation....
>
Hi Hannes,

   No problem. Glad you figured it out. Just want to point out that
the reason
this works when you add the @Stateless annotation is because we default
the ejb's remote JNDI name to the fully qualified classname of the remote
business interface. However, this is a product feature, not a spec
requirement. It turns out that many Java EE implementations use the
same defaulting rule, so many people assume it's part of the standard.

 --ken

>
>Hannes
>
>On Sunday 12 February 2006 22:04, Hannes Stauss wrote:
>
>
>>Hi!
>>I have a simple stateless session bean:
>>
>>--------------------------------------------------
>>package com.foo.server;
>>
>>import javax.ejb.Remote;
>>
>>@Remote
>>public interface Service {
>>
>> public String sayHello();
>>
>>}
>>
>>
>>package com.foo.server;
>>
>>public class ServiceBean implements Service {
>>
>> public String sayHello() {
>> return "Hello";
>> }
>>
>>}
>>
>>
>>ejb-jar.xml:
>>
>><?xml version="1.0" encoding="UTF-8"?>
>><ejb-jar version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
>>http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd ">
>> <description>Chili Enterprise Systems</description>
>> <display-name>Chili Enterprise Bean</display-name>
>></ejb-jar>
>>
>>
>>and a standalone client:
>>
>>---------------------------------------------------------------------------
>>-- ----------- package com.foo.client;
>>
>>import javax.naming.InitialContext;
>>
>>import com.foo.server.Service;
>>
>>public class Main {
>>
>> private void run() {
>> try {
>> InitialContext context = new InitialContext();
>> Service service = (Service)context.lookup(Service.class.getName());
>> System.out.println(service.sayHello());
>> } catch (Exception e) {
>> e.printStackTrace();
>> }
>> }
>>
>> public static void main(String[] args) {
>> new Main().run();
>> }
>>
>>}
>>
>>
>>When I deploy the module on the server and browse the JNDI tree, there is
>>no JNDI name for my bean. Furthermore I get an NameNotFoundException when
>>running the client:
>>
>>Feb 12, 2006 9:43:21 PM com.sun.corba.ee.spi.logging.LogWrapperBase doLog
>>INFO: "IOP00710299: (INTERNAL) Successfully created IIOP listener on the
>>specified host/port: all interfaces/33938"
>>javax.naming.NameNotFoundException: com.foo.server.Service not found
>> at
>>com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:2
>>03 ) at
>>com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:175
>>)
>>
>>....
>>
>>I have tried with b32, b32f and b36, with netbeans and eclipse. Running
>>sun- JDK1.5.0_06 on a linux box. What is wrong? Why isn't there a JNDI
>>name??
>>
>>Help appreciated! Thanks
>>
>>Hannes
>>
>>-------------------------------------------------------
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net
>>For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net
>For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net
>
>
>