on 09-01-2008 5:31 AM
hi all,
I a working on a sample webdynpro application where am using javabean model which access a bussiness method from ejb containing business logic..Now my problem is that bussiness method of ejb is not geting called..My java bean code is as follows:
public class sampleejbbean {
int num1,num2,res;
SampleejbLocal local = null;
SampleejbLocalHome home = null;
public sampleejbbean() throws CreateException
{
try
{
InitialContext ctx = new InitialContext();
home = (SampleejbLocalHome)ctx.lookup("samplesession");
local = home.create();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void execute()
{
try
{
this.res = local.method1(num1,num2);
System.out.print("result");
System.out.println(res);
}
catch(Exception ex)
{
ex.printStackTrace();
return;
}
Here method1 is my ejb bussiness method..am able to see output display but when i enter inputs am not getting any output..and when we try to excute it a java application it is showing an exception at initial context.
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at com.samplejava.sampleejbbean.<init>(sampleejbbean.java:30)
at com.samplejava.sampleejbbean.main(sampleejbbean.java:98)
Can anyone give me an idea about this.
Thanks in advance,
Anusha
Edited by: anusha sabbineni on Sep 1, 2008 10:02 AM
Hi,
Refers the following docs..
EJBs in Web Dynpro Application Using Wrapper Class
Here Java Bean Model used in web dynpro.
Accessing database table using EJB and web dynpro
Oracle Connectivity with EJB using WebDynpro Application
Hope it will help u.
thanks
Abhilasha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anusha,
InitialContext ctx = new InitialContext();
Replace above line with the following Code:
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
p.put(Context.PROVIDER_URL, "Server IPAddress:Portnumber");
p.put(Context.SECURITY_PRINCIPAL, "username");
p.put(Context.SECURITY_CREDENTIALS, "password");
InitialContext ctx = new InitialContext(p );
//Server IP Address -- give u r server ip address
//Portnumber -- like 50004
//username, password means server user name and server password
and also replace this line:
home = (SampleejbLocalHome)ctx.lookup("samplesession");
as : home = (SampleejbHome)ctx.lookup("samplesession");
and also replace the below two lines :
SampleejbLocal local = null;
SampleejbLocalHome home = null;
with the following Code:
Sampleejb local = null;
SampleejbHome home = null;
becoz remote objects need to be take.
With Regards,
Roop Kumar
Edited by: Roop kumar Annavarapu on Sep 1, 2008 3:49 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anusha Sabbineni,
Add " ejb20.jar " file to Project reference of that Particular Project.
Right click on the Project & Select Properties. In that Properties window select " Java Build Path " on Left side & Select " Libraries " Tab on Top & Click on " Add External JARs " Button and select " ejb20.jar " and Click " Ok " Button on Lower side.
I hope it will solve your Problem.
If You have any more doubts feel free to ask.
With Regards,
Roop Kumar.
Edited by: Roop kumar Annavarapu on Sep 1, 2008 2:41 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.