Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » NPE in remote session(NPE in remote session caused by the reference descriptor that is defined as TRANSIENT in related foreign reference mapping.)
NPE in remote session [message #803104] Mon, 20 February 2012 18:31 Go to next message
Eclipse UserFriend
Hello,

I am using 2.3.2 version of eclipselink. I´ve got NPE for merging object with remote sessions. Here is a stacktrace:

java.lang.NullPointerException
at org.eclipse.persistence.internal.queries.ContainerPolicy.createWrappedObjectFromExistingWrappedObject(ContainerPolicy.java:697)
at org.eclipse.persistence.mappings.CollectionMapping.mergeIntoObject(CollectionMapping.java:1491)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.mergeIntoObject(ObjectBuilder.java:3466)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.mergeIntoObject(ObjectBuilder.java:3430)
at org.eclipse.persistence.internal.sessions.MergeManager.mergeChangesForRefreshingRemoteObject(MergeManager.java:467)
at org.eclipse.persistence.internal.sessions.MergeManager.mergeChanges(MergeManager.java:361)
at org.eclipse.persistence.sessions.remote.RemoteSession.getObjectCorrespondingTo(RemoteSession.java:230)
at org.eclipse.persistence.queries.ReadObjectQuery.extractRemoteResult(ReadObjectQuery.java:606)
at org.eclipse.persistence.queries.DatabaseQuery.remoteExecute(DatabaseQuery.java:1788)
at org.eclipse.persistence.queries.ReadObjectQuery.remoteExecute(ReadObjectQuery.java:890)
at org.eclipse.persistence.queries.DatabaseQuery.remoteExecute(DatabaseQuery.java:1797)
at org.eclipse.persistence.queries.ReadQuery.remoteExecute(ReadQuery.java:360)
at org.eclipse.persistence.sessions.remote.RemoteSession.executeQuery(RemoteSession.java:129)
at org.eclipse.persistence.internal.sessions.AbstractSession.refreshAndLockObject(AbstractSession.java:3540)
at org.eclipse.persistence.internal.sessions.AbstractSession.refreshObject(AbstractSession.java:3551)
.....

NPE is thrown in the following line:


return referenceDescriptor.getObjectBuilder().wrapObject(mergeManager.getTargetVersionOfSourceObject(unwrapIteratorResult(wrappedObject), referenceDescriptor, targetSession), mergeManager.getSession());

Reference descriptor is attribute of the foreign reference mapping. This attribute is properly initialized on the server side but has NULL value on the client side because is declared as TRANSIENT.

Does anybody have any suggestions?


Re: NPE in remote session [message #804385 is a reply to message #803104] Wed, 22 February 2012 10:13 Go to previous messageGo to next message
Eclipse UserFriend
It is most likely a bug in RemoteSession. Please log a bug with all of the detailed information to recreate the error.

Does it only occur with refresh?

What purpose are you using RemoteSession for? It is not commonly used in EclipseLink.

Re: NPE in remote session [message #804454 is a reply to message #803104] Wed, 22 February 2012 11:40 Go to previous messageGo to next message
Eclipse UserFriend
Hi again,

We started using a toplink 13 years ago. Our application is complex and big RMI based three layer application. At that time we have started using remote sessions on our client side. We had to create a lot of patches around toplink, to not use lazy loading and many others nice features. Our idea is to replace old toplink with eclipselink. Apart from remote sessions, application is working pretty fine with eclipselink. Now I am going to apply same patch to eclipselink as we did for toplink and go further with testing. For every problem that I am going to find out, I will create a new post.

I have created simple test project to reproduce same NPE exception as well. Here is a code:

public class MyProject extends Project {
public void init() {
setName("MyProject");
applyLogin();
addDescriptor(buildUserDescriptor());
addDescriptor(buildAddressDescriptor());
}
private ClassDescriptor buildAddressDescriptor() {
RelationalDescriptor addressDescriptor = new RelationalDescriptor();
addressDescriptor.setTableName("ADDRESS");
addressDescriptor.addPrimaryKeyFieldName("ADDRESS.ID");
addressDescriptor.setSequenceNumberName("ADDRESS_SEQ");
addressDescriptor.setSequenceNumberFieldName("ID");
addressDescriptor.setAlias("Address");
addressDescriptor.setJavaClass(Address.class);
DirectToFieldMapping streetMapping = new DirectToFieldMapping();
streetMapping.setAttributeName("street");
streetMapping.setFieldName("ADDRESS.STREET");
addressDescriptor.addMapping(streetMapping);
DirectToFieldMapping idMapping = new DirectToFieldMapping();
idMapping.setAttributeName("id");
idMapping.setFieldName("ID");
addressDescriptor.addMapping(idMapping);
OneToOneMapping userMapping = new OneToOneMapping();
userMapping.setReferenceClass(User.class);
userMapping.setForeignKeyFieldName("USER_ID");
userMapping.setAttributeName("user");
userMapping.setUsesIndirection(false);
addressDescriptor.addMapping(userMapping);
return addressDescriptor;
}
private ClassDescriptor buildUserDescriptor() {
RelationalDescriptor userDescriptor = new RelationalDescriptor();
userDescriptor.setTableName("USER");
userDescriptor.addPrimaryKeyFieldName("USER.ID");
userDescriptor.setSequenceNumberFieldName("ID");
userDescriptor.setSequenceNumberName("USER_SEQ");
userDescriptor.setAlias("User");
userDescriptor.setJavaClass(User.class);
DirectToFieldMapping nameMapping = new DirectToFieldMapping();
nameMapping.setAttributeName("name");
nameMapping.setFieldName("USER.NAME");
userDescriptor.addMapping(nameMapping);
DirectToFieldMapping idMapping = new DirectToFieldMapping();
idMapping.setAttributeName("id");
idMapping.setFieldName("ID");
userDescriptor.addMapping(idMapping);
OneToManyMapping addressesMapping = new OneToManyMapping();
addressesMapping.setAttributeName("addresses");
addressesMapping.setReferenceClass(Address.class);
addressesMapping.setTargetForeignKeyFieldName("USER_ID");
addressesMapping.setUsesIndirection(false);
userDescriptor.addMapping(addressesMapping);
return userDescriptor;
}
public void applyLogin() {
DatabaseLogin login = new DatabaseLogin();
login.usePlatform(new MySQLPlatform());
login.setDriverClassName("com.mysql.jdbc.Driver");
login.setConnectionString("jdbc:mysql://localhost:3306/MyDB");
login.setUserName("user");
login.setPassword("password");
setDatasourceLogin(login);
}
}

public class MyClient {
private static RMIConnection rmiConnection = null;
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("my/client/rmi-client-context.xml");
RMISessionManager rmiSessionManager = (RMISessionManager) ctx.getBean("rmiSessionManager");
try {
rmiConnection = new RMIConnection(rmiSessionManager.getRMIRemoteSessionController());
} catch (RemoteException e) {
e.printStackTrace();
}
testRemoteSessionRefresh();
}
private static void testRemoteSessionRefresh() {
Expression expression = new ExpressionBuilder(User.class).get("name").equal("loder");
Session session = rmiConnection.createRemoteSession();
Vector<User> users = session.readAllObjects(User.class, expression);
User loder = users.get(0);
loder = (User) session.refreshObject(loder);
}
}


Executing client gives NPE with following stracktrace:
Exception in thread "main" java.lang.NullPointerException
at org.eclipse.persistence.internal.queries.ContainerPolicy.createWrappedObjectFromExistingWrappedObject(ContainerPolicy.java:697)
at org.eclipse.persistence.mappings.CollectionMapping.mergeIntoObject(CollectionMapping.java:1491)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.mergeIntoObject(ObjectBuilder.java:3466)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.mergeIntoObject(ObjectBuilder.java:3430)
at org.eclipse.persistence.internal.sessions.MergeManager.mergeChangesForRefreshingRemoteObject(MergeManager.java:466)
at org.eclipse.persistence.internal.sessions.MergeManager.mergeChanges(MergeManager.java:361)
at org.eclipse.persistence.sessions.remote.RemoteSession.getObjectCorrespondingTo(RemoteSession.java:230)
at org.eclipse.persistence.queries.ReadObjectQuery.extractRemoteResult(ReadObjectQuery.java:606)
at org.eclipse.persistence.queries.DatabaseQuery.remoteExecute(DatabaseQuery.java:1788)
at org.eclipse.persistence.queries.ReadObjectQuery.remoteExecute(ReadObjectQuery.java:890)
at org.eclipse.persistence.queries.DatabaseQuery.remoteExecute(DatabaseQuery.java:1797)
at org.eclipse.persistence.queries.ReadQuery.remoteExecute(ReadQuery.java:360)
at org.eclipse.persistence.sessions.remote.RemoteSession.executeQuery(RemoteSession.java:129)
at org.eclipse.persistence.internal.sessions.AbstractSession.refreshAndLockObject(AbstractSession.java:3540)
at org.eclipse.persistence.internal.sessions.AbstractSession.refreshObject(AbstractSession.java:3551)
at my.client.MyClient.testRemoteSessionRefresh(MyClient.java:55)
at my.client.MyClient.main(MyClient.java:46)

Re: NPE in remote session [message #808351 is a reply to message #804454] Mon, 27 February 2012 12:38 Go to previous message
Eclipse UserFriend
Seems like a bug, please log the in Bugzilla. If you have a support contract for TopLink, please also follow it up with TopLink support.
Previous Topic:Auditar entidad
Next Topic:Detached Instance Following (read-only) Query
Goto Forum:
  


Current Time: Sun Jul 06 07:52:03 EDT 2025

Powered by FUDForum. Page generated in 0.03506 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top