Home » Developer & Programmer » JDeveloper, Java & XML » java.lang.NullPointerException while invoke Session Bean (JDeveloper 10.1.3.3 - Embeded OC4J server)
java.lang.NullPointerException while invoke Session Bean [message #439730] Tue, 19 January 2010 05:02
ying
Messages: 143
Registered: May 2002
Senior Member
Hi,

New to EJB, wish to learn and trying to play around the coding base on the tutorial-> http://technology.amis.nl/blog/4260/ejb-dependency-injection-of-session-bean-facade-in-jsf-12-on-weblogic-103-jsf-with-jpa
This tutorial to me is the most simple to understand. But the tutorial not work for me. I have been googling for about two weeks and did a lot of trial base on example given, but none of them solve my problem

The first error found was in the QuestionController

Integer trck = sbean.save(question); //Error found for this "cannot assign value of type void to variable of type java.lang.integer..

The second error found was there has no "lookup". I have tried to add the lookup for invoking the session bean, as below:

try {
final Context context = new InitialContext();
QuestionSessionLocal =
(QuestionSessionLocal)context.lookup("java:comp/env/ejb/local/QuestionSession");//find this from the web.xml ejb-ref

} catch (Exception ex) {
//TODO : bubble up exception or put in log file.
ex.printStackTrace();
}




public void create() {
try {
final Context context = new InitialContext();
QuestionSessionLocal ques = (QuestionSessionLocal)context.lookup("java:comp/env/ejb/local/QuestionSession");//find this from the web.xml ejb-ref
//ques.hello();
// ques.printHello("Michelle");
ques.save(question);
//return "created";
} catch (Exception ex) {
//TODO : bubble up exception or put in log file.
ex.printStackTrace();
}


}
No error for this, but there has no data save into database after submitting

public String create() {
try {
quesbean.save(question);
addSuccessMessage("Your question was successfully submitted.");
} catch (Exception ex) {
addErrorMessage(ex.getLocalizedMessage());
} return "created";
}

No error for this, but there has no data save into database after submitting and error message also didn't get display


public String create() {
try {
final Context context = new InitialContext();
QuestionSessionLocal quesbean = (QuestionSessionLocal)context.lookup("java:comp/env/ejb/local/QuestionSession");//find this from the web.xml ejb-ref
//Integer trck = quesbean.save(question);
quesbean.save(question);
addSuccessMessage("Your question was successfully submitted.");
} catch (Exception ex) {
addErrorMessage(ex.getLocalizedMessage()); }
return "created"; }


public String createPrint() {
try {
final Context context = new InitialContext();
QuestionSessionLocal quesbean = (QuestionSessionLocal)context.lookup("java:comp/env/ejb/local/QuestionSession");//find this from the web.xml ejb-ref
// Integer trck;
// trck = quesbean.save(question);
//quesbean.save(question);
quesbean.printHello("Michelle");
//addSuccessMessage("Your question was successfully submitted.");
addSuccessMessage("Your question was successfully submitted.");
} catch (Exception ex) {
addErrorMessage(ex.getLocalizedMessage()); }
return "created"; }

Error injecting reference; nested exception is: java.lang.InstantiationException: Error injecting reference

If remove the try and catch, there is -> java.lang.NullPointerException error

Please advise.

Ying.

[Updated on: Tue, 19 January 2010 05:05]

Report message to a moderator

Previous Topic: [Urgent]Error when using dbms_java.loadjava
Next Topic: Create oracle xml header
Goto Forum:
  


Current Time: Thu Mar 28 05:31:05 CDT 2024