Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

accesing ejb deployed in weblogic from tomcat

 
alec stewart stewart
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
all friends
i have an ejb deployed on weblogic 8.1 now how do i call this ejbs from my tomcat
i am trying to follow the below code but its not working
Properties prop=new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
prop.put(Context.PROVIDER_URL,"t3://localhost:7001");
Context ctx=new InitialContext(prop);
Object ref=ctx.lookup("OrderManagement1");
System.out.println(" look up done");
orderManagementHome home=(orderManagementHome)javax.rmi.PortableRemoteObject.narrow(ref,orderManagementHome.class);
orderManagement1 orderManagement=home.create();
orderManagement.placeOrder("Cedric","J2EE server programming",1000);
orderManagement.add("recepient","message");
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post your error message, it's very important.
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the code breaking? Try to test each step you made about discovering the bean (test against null). My first guess is that the lookup fails, so the JNDI name of the bean is not the one you use for retrieval.
 
alec stewart stewart
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am able to access ejb from tomcat when they are on the same machine.
the moment i try to access the same ejb from tomcat but from a different machine its states a problem in the inital context thing which is as follows

Properties prop=new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
System.out.println("got initial context factory");
prop.put(Context.PROVIDER_URL,"t3://localhost:7001");
Context ctx=new InitialContext(prop);
Object ref=ctx.lookup("OrderManagement1");
System.out.println(" look up done");
orderManagementHome home=(orderManagementHome)javax.rmi.PortableRemoteObject.narrow(ref,orderManagementHome.class);
orderManagement1 orderManagement=home.create();
orderManagement.add("recepient","message");
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.coderanch.com/t/314497/EJB-JEE/java/connect-between-EJB-anothe-EJB
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

prop.put(Context.PROVIDER_URL,"t3://localhost:7001");

is it clear why you can access the EJB on the same machine?
You need to put the provider URL from the remote machine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic