aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes NullPointerException on create Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "NullPointerException on create" Watch "NullPointerException on create" New topic
Author

NullPointerException on create

chuck keuper
Greenhorn

Joined: Mar 17, 2004
Posts: 22
I am trying to add a record into a table and I keep on getting a NullPointerException. Any help would be greatly appreciated!!

This is the code from the main.

EcrChangeDocsTestClient1 client = new EcrChangeDocsTestClient1();
int sChangeDocId = 6;
int sChangeCaseId = 1;
Date sChangeDt = new Date();
Integer sChangePriorityLvl = new Integer(1);
Integer sIsActive = new Integer(1);
int sMasterDocId = 1;
String sNotes = new String("okay");
String sReasonChg = new String("Why not");
Integer sSeverity = new Integer(1);

try {
EcrChangeDocsRemote ecrChg = client.create(sChangeCaseId, sChangeDt, sChangePriorityLvl, sIsActive, sMasterDocId, sNotes, sReasonChg, sSeverity);
ecrChg.setChangeCaseId(sChangeCaseId);
ecrChg.setChangeDt(sChangeDt);
ecrChg.setChangePriorityLvl(sChangePriorityLvl);
ecrChg.setIsActive(sIsActive);
ecrChg.setMasterDocId(sMasterDocId);
ecrChg.setNotes(sNotes);
ecrChg.setReasonChg(sReasonChg); ....

This is the code from the bean.

public EcrChangeDocsPK ejbCreate(int sChangeCaseId, java.util.Date sChangeDt, java.lang.Integer sChangePriorityLvl, java.lang.Integer sIsActive, int sMasterDocId, java.lang.String sNotes, java.lang.String sReasonChg, java.lang.Integer sSeverity) throws CreateException {

int primaryKey = 0;
primaryKey = this.generatePrimaryKey();

setChangeDocId(primaryKey);
setChangeCaseId(sChangeCaseId);
setChangeDocId(primaryKey);
setChangeDt(sChangeDt);
setChangePriorityLvl(sChangePriorityLvl);
setIsActive(sIsActive);
setMasterDocId(sMasterDocId);
setNotes(sNotes);
setReasonChg(sReasonChg);
setSeverity(sSeverity);

return new EcrChangeDocsPK(primaryKey);
}

This is the error.

-- Calling create(1, Thu Jun 24 13:26:36 MDT 2004, 1, 1, 1, okay, Why not, 1)
-- Failed: create(1, Thu Jun 24 13:26:36 MDT 2004, 1, 1, 1, okay, Why not, 1)
java.rmi.ServerException: java.rmi.RemoteException: null; nested exception is:
java.lang.NullPointerException
at com.inprise.ejb.EJBHome$RemoteStrategyImpl.getSystemException(EJBHome.java:851)
at com.inprise.ejb.Dispatcher.doInvoke(Dispatcher.java:1407)
at com.inprise.ejb.Dispatcher.invokeSecurityCheck(Dispatcher.java:1023)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:816)
at com.inprise.ejb.Dispatcher.create(Dispatcher.java:630)
at com.inprise.ejb.EntityHome.create(EntityHome.java:98)
at com.inprise.ejb.EJBHome.invoke(EJBHome.java:355)
at com.inprise.ejb.EJBHome.access$300(EJBHome.java:6)
at com.inprise.ejb.EJBHome$RemoteStrategyImpl.invoke(EJBHome.java:740)
at com.synesis7.mcsi3.admin.versioncontrol.EcrChangeDocsRemoteHomePOAInvokeHandler.create(EcrChangeDocsRemoteHomePOAInvokeHandler.java:96)
at com.synesis7.mcsi3.admin.versioncontrol.EcrChangeDocsRemoteHomePOAInvokeHandler.create(EcrChangeDocsRemoteHomePOAInvokeHandler.java:144)
at com.synesis7.mcsi3.admin.versioncontrol.EcrChangeDocsRemoteHomePOA._invoke(EcrChangeDocsRemoteHomePOA.java:118)
at com.synesis7.mcsi3.admin.versioncontrol.EcrChangeDocsRemoteHomePOA._invoke(EcrChangeDocsRemoteHomePOA.java:44)
at com.inprise.vbroker.poa.POAImpl.invoke(POAImpl.java:2693)
at com.inprise.vbroker.poa.ActivationRecord.invoke(ActivationRecord.java:109)
at com.inprise.vbroker.poa.ServerInterceptorManager$ARWrapper.invoke(ServerInterceptorManager.java:110)
at com.inprise.vbroker.GIOP.GiopProtocolAdapter.doRequest(GiopProtocolAdapter.java:824)
at com.inprise.vbroker.IIOP.ServerProtocolAdapter.doRequest(ServerProtocolAdapter.java:68)
at com.inprise.vbroker.GIOP.GiopProtocolAdapter.dispatchMessage(GiopProtocolAdapter.java:1106)
at com.inprise.vbroker.orb.TPDispatcherImpl$TPDispatcher.run(TPDispatcherImpl.java:106)
at com.inprise.vbroker.orb.ThreadPool$PoolWorker.run(ThreadPool.java:76)
Caused by: java.lang.NullPointerException
at com.borland.ejb.pm.EntityData.modifyObject(EntityData.java:174)
at com.borland.ejb.pm.EntityData.setInt(EntityData.java:534)
at com.synesis7.mcsi3.admin.versioncontrol.EcrChangeDocsBean_PM.setChangeCaseId(EcrChangeDocsBean_PM.java:44)
at com.synesis7.mcsi3.admin.versioncontrol.EcrChangeDocsBean.ejbCreate(EcrChangeDocsBean.java:26)
at com.synesis7.mcsi3.admin.versioncontrol.EcrChangeDocsBean_PM.ejbCreate(EcrChangeDocsBean_PM.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.inprise.ejb.ConcreteMethod.invoke(ConcreteMethod.java:32)
at com.inprise.ejb.EJBContext.invoke(EJBContext.java:166)
at com.inprise.ejb.Dispatcher$EntityCreateMethod.invoke(Dispatcher.java:1618)
at com.inprise.ejb.Dispatcher.doInvoke(Dispatcher.java:1299)
... 19 more
; nested exception is:
java.rmi.RemoteException: null; nested exception is:
java.lang.NullPointerException
at com.synesis7.mcsi3.admin.versioncontrol._EcrChangeDocsRemoteHome_Stub.create(_EcrChangeDocsRemoteHome_Stub.java:376)
at ecr.EcrChangeDocsTestClient1.create(EcrChangeDocsTestClient1.java:105)
at ecr.EcrChangeDocsTestClient1.main(EcrChangeDocsTestClient1.java:913)
Caused by: java.rmi.RemoteException: null; nested exception is:
java.lang.NullPointerException
at com.inprise.vbroker.orb.DelegateImpl.handleReply(DelegateImpl.java:850)
at com.inprise.vbroker.orb.DelegateImpl.invoke(DelegateImpl.java:689)
at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:457)
at com.synesis7.mcsi3.admin.versioncontrol._EcrChangeDocsRemoteHome_Stub.create(_EcrChangeDocsRemoteHome_Stub.java:269)
... 2 more
Caused by: java.lang.NullPointerException
at com.borland.ejb.pm.EntityData.modifyObject(EntityData.java:174)
at com.borland.ejb.pm.EntityData.setInt(EntityData.java:534)
at com.synesis7.mcsi3.admin.versioncontrol.EcrChangeDocsBean_PM.setChangeCaseId(EcrChangeDocsBean_PM.java:44)
at com.synesis7.mcsi3.admin.versioncontrol.EcrChangeDocsBean.ejbCreate(EcrChangeDocsBean.java:26)
at com.synesis7.mcsi3.admin.versioncontrol.EcrChangeDocsBean_PM.ejbCreate(EcrChangeDocsBean_PM.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.inprise.ejb.ConcreteMethod.invoke(ConcreteMethod.java:32)
at com.inprise.ejb.EJBContext.invoke(EJBContext.java:166)
at com.inprise.ejb.Dispatcher$EntityCreateMethod.invoke(Dispatcher.java:1618)
at com.inprise.ejb.Dispatcher.doInvoke(Dispatcher.java:1299)
at com.inprise.ejb.Dispatcher.invokeSecurityCheck(Dispatcher.java:1023)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:816)
at com.inprise.ejb.Dispatcher.create(Dispatcher.java:630)
at com.inprise.ejb.EntityHome.create(EntityHome.java:98)
at com.inprise.ejb.EJBHome.invoke(EJBHome.java:355)
at com.inprise.ejb.EJBHome.access$300(EJBHome.java:6)
at com.inprise.ejb.EJBHome$RemoteStrategyImpl.invoke(EJBHome.java:740)
at com.synesis7.mcsi3.admin.versioncontrol.EcrChangeDocsRemoteHomePOAInvokeHandler.create(EcrChangeDocsRemoteHomePOAInvokeHandler.java:96)
at com.synesis7.mcsi3.admin.versioncontrol.EcrChangeDocsRemoteHomePOAInvokeHandler.create(EcrChangeDocsRemoteHomePOAInvokeHandler.java:144)
at com.synesis7.mcsi3.admin.versioncontrol.EcrChangeDocsRemoteHomePOA._invoke(EcrChangeDocsRemoteHomePOA.java:118)
at com.synesis7.mcsi3.admin.versioncontrol.EcrChangeDocsRemoteHomePOA._invoke(EcrChangeDocsRemoteHomePOA.java:44)
at com.inprise.vbroker.poa.POAImpl.invoke(POAImpl.java:2693)
at com.inprise.vbroker.poa.ActivationRecord.invoke(ActivationRecord.java:109)
at com.inprise.vbroker.poa.ServerInterceptorManager$ARWrapper.invoke(ServerInterceptorManager.java:110)
at com.inprise.vbroker.GIOP.GiopProtocolAdapter.doRequest(GiopProtocolAdapter.java:824)
at com.inprise.vbroker.IIOP.ServerProtocolAdapter.doRequest(ServerProtocolAdapter.java:68)
at com.inprise.vbroker.GIOP.GiopProtocolAdapter.dispatchMessage(GiopProtocolAdapter.java:1106)
at com.inprise.vbroker.orb.TPDispatcherImpl$TPDispatcher.run(TPDispatcherImpl.java:106)
at com.inprise.vbroker.orb.ThreadPool$PoolWorker.run(ThreadPool.java:76)
-- Return value from create(1, Thu Jun 24 13:26:36 MDT 2004, 1, 1, 1, okay, Why not, 1): null.
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
Well, I'm not sure here -- but I see you returning a primary key (object), but still you are setting the primary key earlier as an int. I'm not sure what your logic here is since you didn't post any of it, but you may want to fix that, or check the specs to see if that's what the problem is. Your stack-trace didn't really give me any help.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
chuck keuper
Greenhorn

Joined: Mar 17, 2004
Posts: 22
My logic is to create a row in a database table. I use generatePrimaryKey to return a primaryKey (int). Here is the code for generatePrimaryKey


public int generatePrimaryKey()
{
String query = "SELECT MAX(changeDocId) FROM ChangeDocs";
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
String userName = "userName";
String password = "password";
int primaryKey = 0;

try {
connection = DriverManager.getConnection("jdbc racle:thin:@10.109.0.89:1521 EVEL", userName, password);
preparedStatement.
preparedStatement = connection.prepareCall(query);
preparedStatement.executeQuery();
resultSet = preparedStatement.getResultSet();

if (!resultSet.next()) {
System.out.println("Can not go to next resultSet in generatePrimaryKey of ChangeDoc");
} else {
primaryKey = resultSet.getInt(1);
}
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Exception = " + ex.getStackTrace());
}
return (primaryKey + 1);
}

This particular table has a constraint on it and I have made sure that the changeCaseId in the MasterDoc table is found in the ChangeCase table.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NullPointerException on create
 
Similar Threads
schema name not found in depolyment descriptor
accessing entity bean from session bean
javax ejb ObjectNotFoundException
what's "Can't start a cloned connection while in manual transaction mode"
ejb ql - identifier expected, but 'MEMBER' found