• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about accessing EJB components in OC4J

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,

I have written and deployed a stateless session bean in OC4J. Now I want to use a servlet, which is hosted in tomcat, to act as an EJB client to this session bean in OC4J.

However, I fail to get the remote reference when the servlet perform JNDI lookup for the remote reference. The exception is something like 'Cannot create object.....'

Do anyone have the experience of getting EJB remote reference from OC4J by using servlet act as a EJB client hosted in tomcat ?

If yes, can you tell me about the correct procedures in getting it done ?

Thank you for your kind attention

Yours faithfully,
Benny
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm doing the same. Please give more information on the steps you are doing. I will be able to help you.
 
Benny Tang
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have deployed a stateless session bean EmployeeEJB in OC4J. I have tested that the servlet, which is within the same OC4J, can obtain the remote home reference to the EmployeeEJB.

But when I wrote another servlet, which is located in Apache tomcat, to obtain the remote home reference to EmployeeEJB. It fails when the program starts to lookup through JNDI. Part of exception that I got is shown as follow:

javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.EjbFactory.getObjectInstance(EjbFactory.java:184)

The following shows the coding which I try to obtain the remote reference for the EJB

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.rmi.RMIInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "admin");
env.put(Context.SECURITY_CREDENTIALS, "pho5930");
env.put(Context.PROVIDER_URL, "ormi://192.168.32.129:23791/employee");

try{
Context context = new InitialContext(env);

Object homeObject = context.lookup("java:comp/env/EmployeeBean");

// Narrow the reference to EmployeeHome.
EmployeeHome home =
(EmployeeHome) PortableRemoteObject.narrow(homeObject, EmployeeHome.class);

// Create remote object and narrow the reference to Employee.
Employee remote =
(Employee) PortableRemoteObject.narrow(home.create(), Employee.class);

Can you know the reason why I got this exception ?
 
Deepak Raina
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your settings seem to be fine. What is the entry for the bean in your ejb deployment descripters ejb-jar.xml and orion-ejb-jar.xml file?
Also, make sure you have kept oc4jclient.jar in your web application's or tomcat's classpath.
 
Benny Tang
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have kept the oc4jclient.jar under tomcat's common library. That's ok.

But I don't know the two xml files you mentioned as I just deployed the example, which is downloaded from otn.oracle.com. This example is about the stateless session bean. I follow the instruction of the example to deploy in OC4J.

Can you tell me more detail which configuration files required for the EJB client (i.e. The servlet I used in tomcat) to obtain the remote home
reference to the EJB ?

If anyone know any resource about using EJB deployed in OC4j from tomcat, please let me know.

Thank you for your kind attention.

Thanks,
Benny
 
Deepak Raina
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These configuration files are required for OC4J only. This will be there in the ear file or jar file you would have deployed in OC4J. Check in those configuration file for the jndi name of the ejb. post your configuration files and also give the exact error you are getting.
 
reply
    Bookmark Topic Watch Topic
  • New Topic