• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

calling EJB from JSP in Web logic urgent please help me

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my project i have an EJB module and Web Module(JSP).

If i am calling the EJB from the ordinary client (Java Program) for some database related tasks it is working.

But i want the EJB should be called from the Web module.

Things i had done are :
1) I have created a Connection Pool.
2) I have created a Data Source
3) I have deployed the EJB module in the Deployments -> EJB Modules
4) I have deployed the Web module in the Deployments -> Web Application
Modules.
5) My JNDI name for the EJB is MyRemote
6) My JNDI name for the Data Source is RemoteDB


The following is the code snippet in the JSP file

Properties p=new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL,"t3://localhost:7001");
Context ctx=new InitialContext(p);
DataSource ds=(DataSource)ctx.lookup("RemoteDB");
Connection con=ds.getConnection();

I have called database directly also (for checking purpose).


To call the EJB i have written the following code snippet.


Properties pt=new Properties();
pt.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
pt.put(Context.PROVIDER_URL,"t3://localhost:7001");
Context ic=new InitialContext(pt);
Object objref=initial.lookup("MyRemote");

RemoteUserHome home=(RemoteUserHome)PortableRemoteObject.narrow(objref,RemoteUserHome.class);
RemoteUser cfn1=home.create(serno,firstname,lastname,gender,id,password,security,ans,birth,Integer.parseInt(zip),code);
------------------------------------------------------------------------
When i run the program the following error is occuring :

Compilation of 'C:\bea\user_projects\mydomain\.\myserver\.wlnotdelete\extract\myserver_remote_remote\jsp_servlet\__insertrecord.java' failed:

C:\bea\user_projects\mydomain\.\myserver\.wlnotdelete\extract\myserver_remote_remote\jsp_servlet\__insertrecord.java:200: cannot resolve symbol
probably occurred due to an error in /InsertRecord.jsp line 73:
Object objref=initial.lookup("MyRemote");

C:\bea\user_projects\mydomain\.\myserver\.wlnotdelete\extract\myserver_remote_remote\jsp_servlet\__insertrecord.java:202: cannot resolve symbol
probably occurred due to an error in /InsertRecord.jsp line 75:
RemoteUserHome home=(RemoteUserHome)PortableRemoteObject.narrow(objref,RemoteUserHome.class);

C:\bea\user_projects\mydomain\.\myserver\.wlnotdelete\extract\myserver_remote_remote\jsp_servlet\__insertrecord.java:202: cannot resolve symbol
probably occurred due to an error in /InsertRecord.jsp line 75:
RemoteUserHome home=(RemoteUserHome)PortableRemoteObject.narrow(objref,RemoteUserHome.class);

C:\bea\user_projects\mydomain\.\myserver\.wlnotdelete\extract\myserver_remote_remote\jsp_servlet\__insertrecord.java:202: cannot resolve symbol
probably occurred due to an error in /InsertRecord.jsp line 75:
RemoteUserHome home=(RemoteUserHome)PortableRemoteObject.narrow(objref,RemoteUserHome.class);

C:\bea\user_projects\mydomain\.\myserver\.wlnotdelete\extract\myserver_remote_remote\jsp_servlet\__insertrecord.java:203: cannot resolve symbol
probably occurred due to an error in /InsertRecord.jsp line 76:
RemoteUser cfn1=home.create(serno,firstname,lastname,gender,id,password,security,ans,birth,Integer.parseInt(zip),code);

C:\bea\user_projects\mydomain\.\myserver\.wlnotdelete\extract\myserver_remote_remote\jsp_servlet\__insertrecord.java uses or overrides a deprecated API.

Full compiler error(s):
C:\bea\user_projects\mydomain\.\myserver\.wlnotdelete\extract\myserver_remote_remote\jsp_servlet\__insertrecord.java:200: cannot resolve symbol
symbol : variable initial
location: class jsp_servlet.__insertrecord
Object objref=initial.lookup("MyRemote"); //[ /InsertRecord.jsp; Line: 73]
^
C:\bea\user_projects\mydomain\.\myserver\.wlnotdelete\extract\myserver_remote_remote\jsp_servlet\__insertrecord.java:202: cannot resolve symbol
symbol : class RemoteUserHome
location: class jsp_servlet.__insertrecord
RemoteUserHome home=(RemoteUserHome)PortableRemoteObject.narrow(objref,RemoteUserHome.class); //[ /InsertRecord.jsp; Line: 75]
^
C:\bea\user_projects\mydomain\.\myserver\.wlnotdelete\extract\myserver_remote_remote\jsp_servlet\__insertrecord.java:202: cannot resolve symbol
symbol : class RemoteUserHome
location: class jsp_servlet.__insertrecord
RemoteUserHome home=(RemoteUserHome)PortableRemoteObject.narrow(objref,RemoteUserHome.class); //[ /InsertRecord.jsp; Line: 75]
^
C:\bea\user_projects\mydomain\.\myserver\.wlnotdelete\extract\myserver_remote_remote\jsp_servlet\__insertrecord.java:202: cannot resolve symbol
symbol : class RemoteUserHome
location: class jsp_servlet.__insertrecord
RemoteUserHome home=(RemoteUserHome)PortableRemoteObject.narrow(objref,RemoteUserHome.class); //[ /InsertRecord.jsp; Line: 75]
^
C:\bea\user_projects\mydomain\.\myserver\.wlnotdelete\extract\myserver_remote_remote\jsp_servlet\__insertrecord.java:203: cannot resolve symbol
symbol : class RemoteUser
location: class jsp_servlet.__insertrecord
RemoteUser cfn1=home.create(serno,firstname,lastname,gender,id,password,security,ans,birth,Integer.parseInt(zip),code); //[ /InsertRecord.jsp; Line: 76]
^
Note: C:\bea\user_projects\mydomain\.\myserver\.wlnotdelete\extract\myserver_remote_remote\jsp_servlet\__insertrecord.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
5 errors

Thu Sep 21 08:59:33 GMT+05:30 2006
 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it's typo in your code.
Instead


initial.lookup(..)


it should be

ic.lookup(..)



And one more thing, when you can EJB from the WEB-APP you don't really have to provide Context parameter like PROVIDER_URL and INITIAL_CONTEXT_FACTORY, a simple


Context ic= new InitialContext()



should do.
 
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apart from ic.lookup point, for compilation the web module needs EJB Home interface and Remote interface classes to be available on the classpath. You may have these files in a zip or jar file and add it to the server classpath.
 
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic