Win a copy of OCP Oracle Certified Professional Java SE 11 Developer Practice Tests this week in the OCP forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

java.rmi.RemoteException: NullPointerException

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

I am new in EJB. Trying to run a client application which uses EJB 2.0 with Stateless session bean and WebLogic 7.0 application server. Codes are written using JDK 1.3.1.

Here's part of my client code showing the method where the Bean is been created and it's method been called -

public void callClient(String[] args) {

// Initializing variable with the argument value
int intMaxAttempts = Integer.parseInt(args[0]);

try {
// Create the client's context object
mContext = getInitialContext();
LOG.debug("Context created");
System.out.println("Context created");
// Find the Bean's home interface
LogConnStatApiHome mLogConnStatApiHome = (LogConnStatApiHome) mContex
t.lookup(LOG_CONN_STAT_API_HOME);
LOG.debug("Home interface found");
System.out.println("Home interface found");
// Create the Bean
mLogConnStatApiRemote = mLogConnStatApiHome.create();
LOG.debug("Bean created");
// Now execute the method from the Bean
System.out.println("Now calling mLogConnStatApiRemote.logConnStat(" +
intMaxAttempts + ")");
mLogConnStatApiRemote.logConnStat(intMaxAttempts); } catch (RemoteException re) {

LOG.error("Remote Exception:", re);
System.out.println("Remote Exception: " + re);

} catch (NamingException ne) {
LOG.error("Naming Exception: ", ne);
System.out.println("Naming Exception: " + ne);
} catch (Exception e) {
LOG.error("Exception: ", e);
System.out.println("Exception: " + e);
}
LOG.debug("connectToBean ended"); /*


} // callClient()

*
* Main method
*/
public static void main(String[] args) {
LOG.debug("Starting the main()");
LOG.info("creating LogConnStatApiClient object");
// Invoking the constructor
LogConnStatApiClient logConnStatApiClient = new LogConnStatApiClient();
LOG.info("LogConnStatApiClient object method callclient is executed");
logConnStatApiClient.callClient(args);
LOG.info("main ended");

}


It seems to be failing at statement -
mLogConnStatApiRemote.logConnStat(intMaxAttempts);

Here's the other EJB codes -

Home:

import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;


public interface LogConnStatApiHome extends EJBHome {


public LogConnStatApiRemote create() throws CreateException, RemoteException
;

}

Remote:
import javax.ejb.*;
import java.rmi.RemoteException;
import com.sbcld.tldapi.common.exception.*;


public interface LogConnStatApiRemote extends EJBObject {

public void logConnStat(int intMaxAttempts) throws RemoteException;

}

SessionBean:
public class LogConnStatApiBean implements SessionBean {

public void ejbCreate()throws RemoteException {
LOG.info("CheckDbConnApiBean.ejbCreate Invoked");
}

public void ejbActivate() throws RemoteException {
LOG.info("CheckDbConnApiBean.ejbActivate Invoked");
}

public void ejbRemove() throws RemoteException {
LOG.info("CheckDbConnApiBean.ejbRemove Invoked");
}
public void ejbPassivate()throws RemoteException {
LOG.info("CheckDbConnApiBean.ejbPassivate Invoked");
}

public void setSessionContext(SessionContext ctx) throws RemoteException {//
setContext(ctx);
}
public void logConnStat(int intMaxAttempts) throws RemoteException, Client
Exception {
public void logConnStat(int intMaxAttempts) {
try {
// Call the API constructor that would call the DBHelper
// constructor which to do the database connection
LogConnStatApi logConnStatApi = new LogConnStatApi(intMaxAttempts); // Seems to be failing here
// Now call the method of the API to carry out a simple
// SQL query
try {


logConnStatApi.DoDbConnection();

} catch (SQLException sqlEx1) {

LOG.debug("Exception in executing the SQL query");

}

...


Here's the log output with the error -

java.rmi.RemoteException: EJB Exception: ; nested exception is:
java.lang.NullPointerException

Start server side stack trace:
java.rmi.RemoteException: EJB Exception: ; nested exception is:
java.lang.NullPointerException
java.lang.NullPointerException
at java.lang.String.<init>(String.java:455)
at com.sbcld.tldapi.util.cfg.Encryption.decryptAsString(Encryption.java:
229)
at com.sbcld.tldapi.db.DBHelper.dbConnect(DBHelper.java:150)
at com.sbcld.tldapi.db.DBHelper.<init>(DBHelper.java:92)
at com.sbcld.tldapi.macro.logconnstat.LogConnStatApi.<init>(LogConnStatA
pi.java:23)
at com.sbcld.tldapi.ejb.logconnstatapi.LogConnStatApiBean.logConnStat(Lo
gConnStatApiBean.java:59)
at com.sbcld.tldapi.ejb.logconnstatapi.LogConnStatApiBean_7g5yxl_EOImpl.
logConnStat(LogConnStatApiBean_7g5yxl_EOImpl.java:46)
at com.sbcld.tldapi.ejb.logconnstatapi.LogConnStatApiBean_7g5yxl_EOImpl_
WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:785)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
a:308)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
End server side stack trace

I am running the client app through a shell script passing an integer value as an argument.
I am new EJB. Also, want to mention I am using other classes for getting the JNDI naming and database connectivity etc. Can't figure out what could be the reason this application is failing -
java.rmi.RemoteException: EJB Exception: ; nested exception is:
java.lang.NullPointerException


Really would appreciate if I can get any idea, lead in troubleshooting this problem.

Thanking you all!
 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This has nothing to do with the EJB technology. There is a nullpointer in your code. Check the line com.sbcld.tldapi.util.cfg.Encryption.decryptAsString(Encryption.java:
229) and check the imput that you are providing to it.
 
Tariq Ahsan
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Amit!

I had the same hunch based on the error message outputs. I am new to EJB.But was trying to check for some reason it could have been an EJB related issue. I will now focus my troubleshooting in the area you mentioned.

Appreciated for your reply.
 
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic