NPE with afterCreate

Hi,

I’m getting the following NPE.









BackendlessException{ code: 'Server.Processing', message: 'java.lang.RuntimeException: java.lang.NullPointerException' }

	at com.backendless.Invoker$SyncResponder.errorHandler(Invoker.java:132)

	at com.backendless.core.responder.AdaptingResponder.handledAsFault(AdaptingResponder.java:120)

	at com.backendless.core.responder.AdaptingResponder.responseHandler(AdaptingResponder.java:75)

	at weborb.client.ioEngine.HttpIOEngine.processAMFResponse(HttpIOEngine.java:261)

	at weborb.client.ioEngine.HttpIOEngine.send(HttpIOEngine.java:206)

	at weborb.client.ioEngine.HttpIOEngine.invoke(HttpIOEngine.java:144)

	at weborb.client.WeborbClient.invoke(WeborbClient.java:138)

	at com.backendless.Invoker.invokeSync(Invoker.java:100)

	at com.backendless.Persistence.save(Persistence.java:96)

	at com.backendless.DataStoreFactory$1.save(DataStoreFactory.java:40)

	at com.backendless.digitalcopel.models.Subscriptions.save(Subscriptions.java:144)

	at com.backendless.digitalcopel.events.persistence_service.ClassroomMemberActivationRequestsTableEventHandler.afterCreate(ClassroomMemberActivationRequestsTableEventHandler.java:52)

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

	at java.lang.reflect.Method.invoke(Method.java:606)

	at com.backendless.coderunner.runtime.InvocationTask.runImpl(InvocationTask.java:95)

	at com.backendless.coderunner.runtime.concurrent.ExtendedRunnable.run(ExtendedRunnable.java:20)

	at java.lang.Thread.run(Thread.java:745)

And the code is:









	@Override

	public void afterCreate(

			RunnerContext context,

			ClassroomMemberActivationRequests classroommemberactivationrequests,

			ExecutionResult<ClassroomMemberActivationRequests> result)

			throws Exception {

		logger = Logger.getLogger(ClassroomMemberActivationRequests.class);

		

		Subscriptions s = new Subscriptions();

		try {

			Devices d = Backendless.Persistence.of(Devices.class).findFirst();

			d.save();

			s.setClassroom("TEST");

			s.setDevice(d);

			s.save();

		} catch (Exception ex) {

ex.printStackTrace();

		} 

}

This code is in the afterCreate event handler for the ClassroomMemberActivationRequestsTableEventHandler. It’s a simplified version of the code where I get the same NPE with my actual business logic. I’m using CodeRunner v1.13. The app ID is the usual one, dev version.

By the way, the exception does not happen if I do not run setDevices on the the new Subscription object.

And to clarify the exception, it happens on the line: s.save();

Hi Simon!
Can I export data from your app to investigate this problem on my local server?

Regards,
Kate.

Sure, thanks!

Hi, Simon,

Are you using the latest CodeRunner? (v1.13)

Yes I am. I mentioned that at the bottom of the post.

Hi Simon!
Please download latest Code Runner SDK from site. We made several updates in project.
Regards,
Kate.

That worked, thanks.