my dog learned polymorphism*
The moose likes EJB and other Java EE Technologies and the fly likes How to declare session bean with local view in ejb-jar.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to declare session bean with local view in ejb-jar.xml" Watch "How to declare session bean with local view in ejb-jar.xml" New topic
Author

How to declare session bean with local view in ejb-jar.xml

kurt hanni
Ranch Hand

Joined: Aug 11, 2007
Posts: 140

How come this does not work?

no jndi name is created on startup. I cannot access it using
@EJB SampleBeanLocal bean;
It throws javax.naming.NameNotFoundException



but this does work, a jndi-name is created and can be accessed using @EJB


SCJA, SCJP, SCJD, SCMAD, SCWCD, SCBCD, SCDJWS, SCEA, SOA, Spring Certified, OCP MySQL 5 Developer, PMP
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

I assume that in no-interface view you changed your code to this:


right? I guess that you use explicit name of the bean, so you need to use this name when accessing it using @EJB annotation (beanName attribute or lookup attribute).

When you use the local business view, did you try looking the EJB using JNDI name (lookup(-) method - not the @EJB annotation).
Also, what if you use annotations instead of ejb-jar.xml (@Stateful @Local and @Statful @LocalBean respectively) - will it work?

What EJB container do you use?

Cheers!


OCP Java SE 6 Programmer, OCM Java SE 6 Developer, OCE Java EE 6 JSPSD, OCE Java EE 6 EJBD, OCE Java EE 6 JPAD, Spring 3.0 Core Professional.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9962
    
163

It should be <business-local> instead of <local>


[My Blog] [JavaRanch Journal]
kurt hanni
Ranch Hand

Joined: Aug 11, 2007
Posts: 140

Jaikiran Pai wrote:It should be <business-local> instead of <local>


stupid me! its working now thanks thanks
kurt hanni
Ranch Hand

Joined: Aug 11, 2007
Posts: 140

whats the difference of using <local> and <business-local> when using it to define the session view,

code samples that I was following was using <local>/<remote>, but this not work
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9962
    
163

kurt hanni wrote:whats the difference of using <local> and <business-local> when using it to define the session view,



See these:

http://www.coderanch.com/t/475601/EJB-JEE/java/Confused-getting-reference-interface#2131276
http://www.coderanch.com/t/414957/EJB-JEE/java/EJBObject#1828744
kurt hanni
Ranch Hand

Joined: Aug 11, 2007
Posts: 140

thanks again Jaikiran, that cleared it up.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to declare session bean with local view in ejb-jar.xml
 
Similar Threads
LocalHome Interfaces ClassNotFoundException
accessing entity bean from session bean
Ejb Proxy Problem
Accessing local EJBs (JNDI problem)
InitialContext for EJB 2.x JNDI on Glassfish v2ur2 under Windows Vista