aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes EJB 3 issue : Not able to look up the Stateless session bean on WebLogic 10 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB 3 issue : Not able to look up the Stateless session bean on WebLogic 10" Watch "EJB 3 issue : Not able to look up the Stateless session bean on WebLogic 10" New topic
Author

EJB 3 issue : Not able to look up the Stateless session bean on WebLogic 10

Cotton Gear
Greenhorn

Joined: Jun 02, 2008
Posts: 8
I am a beginner in EJB 3 and trying to execute a simple EJB 3 Stateless session bean on WebLogic 10.

Here are the details of my code and the exceptions i get :

---------------------------------------------------------------------------
package com.mycompany.ejb3application.ejb.session;

import javax.ejb.Stateless;

@Stateless(name="UserSession", mappedName="UserSession")
public class UserSession implements UserSessionLocal, UserSessionRemote {

public void sayHello(){
System.out.println("..........Hello Sujith !!......");
}
}
---------------------------------------------------------------------------
package com.mycompany.ejb3application.ejb.session;

import javax.ejb.Remote;

@Remote
public interface UserSessionRemote {
//public void test();
public void sayHello();
}

---------------------------------------------------------------------------
package com.mycompany.ejb3application.ejb.session;

import javax.ejb.Local;

@Local
public interface UserSessionLocal {
//public void test();
public void sayHello();
}
---------------------------------------------------------------------------
package com.mycompany.ejb3applicationclient;

import java.util.Hashtable;

import javax.ejb.EJB;
import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NameClassPair;
import javax.naming.NamingEnumeration;

import com.mycompany.ejb3application.ejb.session.UserSessionRemote;

public class Client {

@EJB(beanName = "UserSessionBean")
static UserSessionRemote userSessionRemote;

public static void main(String[] str) {
try{
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
//Context compEnv = (Context) new InitialContext().lookup("java:comp/env");

// service = (HelloService)new
// InitialContext().lookup("java:comp/env/ejb/HelloService");

InitialContext context = new InitialContext(ht);
NamingEnumeration bindings = context.list(".");
System.out.println();
while (bindings.hasMore()) {
NameClassPair np = (NameClassPair )bindings.next();
System.out.println(np.getName() + ": " + np.getClassName());
}
System.out.println();

//context.list(name)

UserSessionRemote userSessionRemote = (UserSessionRemote)context.lookup("ejb3applicationejb3applicationEJB_jarUserSession_UserSessionRemote");
//UserSessionRemote userSessionRemote = (UserSessionRemote)context.lookup("UserSession#com.mycompany.ejb3application.ejb.session.UserSessionBean");
//UserSessionRemote userSessionRemote = (UserSessionRemote)compEnv.lookup("UserSessionBean/remote");
//UserSessionRemote userSessionRemote = (UserSessionRemote)context.lookup("java:comp/env/ejb/UserSessionBean");
userSessionRemote.sayHello();
}catch(Exception e){
System.out.println("Exception is :" +e );
e.printStackTrace();
}
}
}
---------------------------------------------------------------------------
JNDI Binding and the exceptions on the console :

java com.mycompany.ejb3applicationclient.Client

mejbmejb_jarMejb_EO: weblogic.rmi.cluster.ClusterableRemoteObject
ejb: weblogic.jndi.internal.ServerNamingNode
projDataSource: weblogic.rmi.cluster.ClusterableRemoteObject
weblogic: weblogic.jndi.internal.ServerNamingNode
cgDataSource: weblogic.rmi.cluster.ClusterableRemoteObject
javax: weblogic.jndi.internal.ServerNamingNode
ejb3applicationejb3applicationEJB_jarUserSession_UserSessionRemote: com.mycompany.ejb3application.ejb.session.UserSession_lw784g_UserSe
ssionRemoteImpl
cgDataSource-nonXA: weblogic.rmi.cluster.ClusterableRemoteObject

Exception is :java.lang.ClassCastException: com.mycompany.ejb3application.ejb.session.UserSession_lw784g_UserSessionRemoteImpl_1001_WLS
tub
java.lang.ClassCastException: com.mycompany.ejb3application.ejb.session.UserSession_lw784g_UserSessionRemoteImpl_1001_WLStub
at com.mycompany.ejb3applicationclient.Client.main(Client.java:40)
---------------------------------------------------------------------------

Thanks and Regards,
Aniket P


Each one of us, teach(at least) one. <br />-Mahatma Gandhi
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2709
    
    5

"Aniket P" please check your private messages for an important administrative matter. You can see them by clicking the My Private Messages link above.


SCJP, SCWCD.
|Asking Good Questions|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB 3 issue : Not able to look up the Stateless session bean on WebLogic 10
 
Similar Threads
problem in acessing session bean using jndi
NoInitialContextException
JNDI not creating for EJB Local interfaces example
Context Lookup Failing
EJB 3 Local Lookup not working with Weblogic 10.3 and JDK 1.6_05