NullPointerException when I'm trying to read a resource - gluon

I have a Gluon Mobile JavafX project.
I'm trying to read a resource from my apk and I'm receiving an error only in Android.
private void leerConfiguracion() { logger.log(Level.INFO, "ConfiguradorGeneralService:leerConfiguracion: BEGIN ... ");
try
{
File fileLugares = new File(ConfiguradorGeneralService.class.getResource("/com/registrodevisitas/json/configuracion.json").getFile());
logger.log(Level.INFO, "ConfiguradorGeneralService:leerConfiguracion: Leyendo configuraciĆ³n: " + fileLugares.getAbsolutePath());
// create a FileClient to the specified File
FileClient fileClient = FileClient.create(fileLugares);
// create a JSON converter that converts the nodes from a JSON array into language objects
InputStreamIterableInputConverter<ConfiguradorGeneral> converter = new JsonIterableInputConverter<>(ConfiguradorGeneral.class);
// retrieve a list from a ListDataReader created from the FileClient
configuracion = DataProvider.retrieveList(fileClient.createListDataReader(converter));
}
catch(Exception e)
{
logger.log(Level.SEVERE, e.getMessage(), e);
}
logger.log(Level.INFO, "ConfiguradorGeneralService:leerConfiguracion: END ");
}
The error on Android is:
I/figuradorGeneralService(11481): ConfiguradorGeneralService:leerConfiguracion: BEGIN ...
E/figuradorGeneralService(11481): null
E/figuradorGeneralService(11481): java.lang.NullPointerException
E/figuradorGeneralService(11481): at com.registrodevisitas.services.ConfiguradorGeneralService.leerConfiguracion(ConfiguradorGeneralService.java:50)
E/figuradorGeneralService(11481): at com.registrodevisitas.services.ConfiguradorGeneralService.<init>(ConfiguradorGeneralService.java:34)
E/figuradorGeneralService(11481): at java.lang.Class.newInstanceImpl(Native Method)
E/figuradorGeneralService(11481): at java.lang.Class.newInstance(Class.java:1208)
E/figuradorGeneralService(11481): at com.airhacks.afterburner.injection.Injector.lambda$getDefaultInstanceSupplier$8(Injector.java:233)
E/figuradorGeneralService(11481): at com.airhacks.afterburner.injection.Injector.access$lambda$3(Injector.java)
E/figuradorGeneralService(11481): at com.airhacks.afterburner.injection.Injector$$Lambda$4.apply(Unknown Source)
E/figuradorGeneralService(11481): at com.airhacks.afterburner.injection.Injector.instantiateModelOrService(Injector.java:116)
E/figuradorGeneralService(11481): at com.airhacks.afterburner.injection.Injector.injectMembers(Injector.java:151)
E/figuradorGeneralService(11481): at com.airhacks.afterburner.injection.Injector.injectMembers(Injector.java:136)
E/figuradorGeneralService(11481): at com.airhacks.afterburner.injection.Injector.injectAndInitialize(Injector.java:129)
E/figuradorGeneralService(11481): at com.airhacks.afterburner.injection.Injector.registerExistingAndInject(Injector.java:107)
E/figuradorGeneralService(11481): at com.airhacks.afterburner.injection.Injector.instantiatePresenter(Injector.java:60)
E/figuradorGeneralService(11481): at com.airhacks.afterburner.views.FXMLView.lambda$loadSynchronously$2(FXMLView.java:89)
E/figuradorGeneralService(11481): at com.airhacks.afterburner.views.FXMLView.access$lambda$1(FXMLView.java)
E/figuradorGeneralService(11481): at com.airhacks.afterburner.views.FXMLView$$Lambda$2.call(Unknown Source)
E/figuradorGeneralService(11481): at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:929)
E/figuradorGeneralService(11481): at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:971)
E/figuradorGeneralService(11481): at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:220)
E/figuradorGeneralService(11481): at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:744)
E/figuradorGeneralService(11481): at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
E/figuradorGeneralService(11481): at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
E/figuradorGeneralService(11481): at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
E/figuradorGeneralService(11481): at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
E/figuradorGeneralService(11481): at com.airhacks.afterburner.views.FXMLView.loadSynchronously(FXMLView.java:91)
E/figuradorGeneralService(11481): at com.airhacks.afterburner.views.FXMLView.initializeFXMLLoader(FXMLView.java:100)
E/figuradorGeneralService(11481): at com.airhacks.afterburner.views.FXMLView.getView(FXMLView.java:112)
E/figuradorGeneralService(11481): at com.registrodevisitas.RegistroDeVisitas.lambda$init$0(RegistroDeVisitas.java:55)
E/figuradorGeneralService(11481): at com.registrodevisitas.RegistroDeVisitas.access$lambda$0(RegistroDeVisitas.java)
E/figuradorGeneralService(11481): at com.registrodevisitas.RegistroDeVisitas$$Lambda$1.get(Unknown Source)
E/figuradorGeneralService(11481): at com.gluonhq.impl.charm.a.d.a.a(SourceFile:32)
E/figuradorGeneralService(11481): at com.gluonhq.charm.glisten.application.MobileApplication.a(SourceFile:620)
E/figuradorGeneralService(11481): at com.gluonhq.charm.glisten.application.MobileApplication.switchView(SourceFile:391)
E/figuradorGeneralService(11481): at com.gluonhq.charm.glisten.application.MobileApplication.switchView(SourceFile:368)
E/figuradorGeneralService(11481): at com.gluonhq.charm.glisten.application.MobileApplication.start(SourceFile:218)
E/figuradorGeneralService(11481): at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$144(LauncherImpl.java:863)
E/figuradorGeneralService(11481): at com.sun.javafx.application.LauncherImpl.access$lambda$8(LauncherImpl.java)
E/figuradorGeneralService(11481): at com.sun.javafx.application.LauncherImpl$$Lambda$9.run(Unknown Source)
E/figuradorGeneralService(11481): at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$157(PlatformImpl.java:326)
E/figuradorGeneralService(11481): at com.sun.javafx.application.PlatformImpl.access$lambda$6(PlatformImpl.java)
E/figuradorGeneralService(11481): at com.sun.javafx.application.PlatformImpl$$Lambda$7.run(Unknown Source)
E/figuradorGeneralService(11481): at com.sun.javafx.application.PlatformImpl.lambda$null$155(PlatformImpl.java:295)
E/figuradorGeneralService(11481): at com.sun.javafx.application.PlatformImpl.access$lambda$18(PlatformImpl.java)
E/figuradorGeneralService(11481): at com.sun.javafx.application.PlatformImpl$$Lambda$19.run(Unknown Source)
E/figuradorGeneralService(11481): at java.security.AccessController.doPrivileged(AccessController.java:52)
E/figuradorGeneralService(11481): at com.sun.javafx.application.PlatformImpl.lambda$runLater$156(PlatformImpl.java:294)
E/figuradorGeneralService(11481): at com.sun.javafx.application.PlatformImpl.access$lambda$5(PlatformImpl.java)
E/figuradorGeneralService(11481): at com.sun.javafx.application.PlatformImpl$$Lambda$6.run(Unknown Source)
E/figuradorGeneralService(11481): at com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:92)
E/figuradorGeneralService(11481): at com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:51)
E/figuradorGeneralService(11481): at java.lang.Thread.run(Thread.java:8
I/figuradorGeneralService(11481): ConfiguradorGeneralService:leerConfiguracion: END
This file is on RESOURCE/COM....
This method is working perfectly on windows.
Any help would be nice. Thank you.

On Android (and iOS), you can't directly access classpath resources as a File, like you can on desktop. Instead, you need to access resources by using the InputStream. This works on all the supported platforms (android, iOS and desktop).
Try to access your resource with the following code:
BasicInputDataSource source = new BasicInputDataSource(ConfiguradorGeneralService.class.getResourceAsStream("/com/registrodevisitas/json/configuracion.json"));
InputStreamIterableInputConverter<ConfiguradorGeneral> converter = new JsonIterableInputConverter<>(ConfiguradorGeneral.class);
configuracion = DataProvider.retrieveList(new InputStreamListDataReader<>(source, converter));

Related

Xamarin App crashes on Run time or even once starting the first time

Upon checking the App Vitals from G Play Console I found multiple crash issue reported there. 3 crash reports I have motioned below with crash stack trace, could any one please help us out to understand the main reason of app crashing.
First Stack Trace:-
android.runtime.JavaProxyThrowable
android.runtime.JavaProxyThrowable: at Xamarin.Forms.Platform.Android.AppCompat.Platform.Xamarin.Forms.Platform.Android.IPlatformLayout.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x0002b] in <04c545f414d24a37af95d995791bb9a9>:0
at Xamarin.Forms.Platform.Android.PlatformRenderer.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00024] in <04c545f414d24a37af95d995791bb9a9>:0
at Android.Views.ViewGroup.n_OnLayout_ZIIII (System.IntPtr jnienv, System.IntPtr native__this, System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00008] in <afe87cbe480b4f36a0d2b653e61f173f>:0
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.43(intptr,intptr,bool,int,int,int,int)
at crc643f46942d9dd1fff9.PlatformRenderer.n_onLayout (Native Method)
at crc643f46942d9dd1fff9.PlatformRenderer.onLayout (PlatformRenderer.java:55)
at android.view.View.layout (View.java:23482)
at android.view.ViewGroup.layout (ViewGroup.java:6575)
at android.widget.RelativeLayout.onLayout (RelativeLayout.java:1103)
at android.view.View.layout (View.java:23482)
at android.view.ViewGroup.layout (ViewGroup.java:6575)
at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
at android.widget.FrameLayout.onLayout (FrameLayout.java:270)
at android.view.View.layout (View.java:23482)
at android.view.ViewGroup.layout (ViewGroup.java:6575)
at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
at android.widget.FrameLayout.onLayout (FrameLayout.java:270)
at android.view.View.layout (View.java:23482)
at android.view.ViewGroup.layout (ViewGroup.java:6575)
at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
at android.widget.FrameLayout.onLayout (FrameLayout.java:270)
at android.view.View.layout (View.java:23482)
at android.view.ViewGroup.layout (ViewGroup.java:6575)
at android.widget.LinearLayout.setChildFrame (LinearLayout.java:1841)
at android.widget.LinearLayout.layoutVertical (LinearLayout.java:1673)
at android.widget.LinearLayout.onLayout (LinearLayout.java:1582)
at android.view.View.layout (View.java:23482)
at android.view.ViewGroup.layout (ViewGroup.java:6575)
at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
at android.widget.FrameLayout.onLayout (FrameLayout.java:270)
at com.android.internal.policy.DecorView.onLayout (DecorView.java:873)
at android.view.View.layout (View.java:23482)
at android.view.ViewGroup.layout (ViewGroup.java:6575)
at android.view.ViewRootImpl.performLayout (ViewRootImpl.java:4075)
at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:3470)
at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:2398)
at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:9407)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1214)
at android.view.Choreographer.doCallbacks (Choreographer.java:968)
at android.view.Choreographer.doFrame (Choreographer.java:868)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1199)
at android.os.Handler.handleCallback (Handler.java:938)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loopOnce (Looper.java:233)
at android.os.Looper.loop (Looper.java:344)
at android.app.ActivityThread.main (ActivityThread.java:8200)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:589)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1071)
Second Crash Stack Trace :-
android.runtime.JavaProxyThrowable: at LastMile.Droid.ForgroundServices.LocationTrackingService.OnStartCommand (Android.Content.Intent intent, Android.App.StartCommandFlags flags, System.Int32 startId) [0x00000] in <6b6c92ba8a0f4ed4a6248c52b6e5063a>:0
at Android.App.Service.n_OnStartCommand_Landroid_content_Intent_II (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_intent, System.Int32 native_flags, System.Int32 startId) [0x0000f] in <afe87cbe480b4f36a0d2b653e61f173f>:0
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.5(intptr,intptr,intptr,int,int)
at crc64f1353ff377cb4a5c.LocationTrackingService.n_onStartCommand (Native Method)
at crc64f1353ff377cb4a5c.LocationTrackingService.onStartCommand (LocationTrackingService.java:40)
at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:4836)
at android.app.ActivityThread.access$2100 (ActivityThread.java:258)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2249)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loopOnce (Looper.java:233)
at android.os.Looper.loop (Looper.java:344)
at android.app.ActivityThread.main (ActivityThread.java:8200)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:589)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1071)
Third Crash Stack Trace :-
java.lang.IllegalStateException:
at androidx.fragment.app.Fragment$4.onFindViewById (Fragment.java:2901)
at androidx.fragment.app.FragmentStateManager.createView (FragmentStateManager.java:504)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState (FragmentStateManager.java:282)
at androidx.fragment.app.FragmentStore.moveToExpectedState (FragmentStore.java:112)
at androidx.fragment.app.FragmentManager.moveToState (FragmentManager.java:1647)
at androidx.fragment.app.FragmentManager.dispatchStateChange (FragmentManager.java:3126)
at androidx.fragment.app.FragmentManager.dispatchActivityCreated (FragmentManager.java:3070)
at androidx.fragment.app.Fragment.performActivityCreated (Fragment.java:3002)
at androidx.fragment.app.FragmentStateManager.activityCreated (FragmentStateManager.java:580)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState (FragmentStateManager.java:285)
at androidx.fragment.app.FragmentStore.moveToExpectedState (FragmentStore.java:112)
at androidx.fragment.app.FragmentManager.moveToState (FragmentManager.java:1647)
at androidx.fragment.app.FragmentManager.dispatchStateChange (FragmentManager.java:3126)
at androidx.fragment.app.FragmentManager.dispatchActivityCreated (FragmentManager.java:3070)
at androidx.fragment.app.FragmentController.dispatchActivityCreated (FragmentController.java:251)
at androidx.fragment.app.FragmentActivity.onStart (FragmentActivity.java:501)
at androidx.appcompat.app.AppCompatActivity.onStart (AppCompatActivity.java:210)
at crc643f46942d9dd1fff9.FormsAppCompatActivity.n_onStart (Native Method)
at crc643f46942d9dd1fff9.FormsAppCompatActivity.onStart (FormsAppCompatActivity.java:128)
at android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1469)
at android.app.Activity.performStart (Activity.java:8155)
at android.app.ActivityThread.handleStartActivity (ActivityThread.java:3834)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence (TransactionExecutor.java:221)
at android.app.servertransaction.TransactionExecutor.cycleToPath (TransactionExecutor.java:201)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:173)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2373)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loopOnce (Looper.java:233)
at android.os.Looper.loop (Looper.java:344)
at android.app.ActivityThread.main (ActivityThread.java:8200)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:589)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1071)

IBM MQ Create Context throws com.ibm.mq.jmqi.JmqiException "Channel not defined remotely" (RC 2540)

While trying to create the context, this code throws the exception below:
package com.mycompany.mq.client;
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Logger;
import javax.jms.JMSConsumer;
import javax.jms.JMSContext;
import javax.jms.JMSProducer;
import javax.jms.Queue;
import javax.jms.TextMessage;
import org.junit.Assert;
import org.junit.Test;
import com.ibm.msg.client.jms.JmsConnectionFactory;
import com.ibm.msg.client.jms.JmsFactoryFactory;
import com.ibm.msg.client.wmq.WMQConstants;
import com.prowidesoftware.swift.io.RJEReader;
import com.prowidesoftware.swift.model.SwiftMessage;
public class FileScanner {
private static final Logger logger = Logger.getLogger("RJEFileParser");
#Test
public void testPublish() throws Exception {
int count=0;
long m1,m2;
// Create a connection factory
JmsFactoryFactory ff = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER);
JmsConnectionFactory cf = ff.createConnectionFactory();
// Set the properties
String s;
s=Config.get("HOST"); // 10.32.1.69
cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, s);
s=Config.get("PORT"); // 1414
cf.setIntProperty(WMQConstants.WMQ_PORT, Integer.parseInt(s));
s=Config.get("CHANNEL"); // MQCLI.CLNTCONN
cf.setStringProperty(WMQConstants.WMQ_CHANNEL, s);
cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
s=Config.get("QMGR"); // RJE_PerfTest
cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, s);
cf.setStringProperty(WMQConstants.WMQ_APPLICATIONNAME, "mq-cli");
cf.setBooleanProperty(WMQConstants.USER_AUTHENTICATION_MQCSP, true);
s=Config.get("APP_USER"); // app
cf.setStringProperty(WMQConstants.USERID, s);
s=Config.get("APP_PASSWORD"); // password
cf.setStringProperty(WMQConstants.PASSWORD, s);
// Create JMS objects
try {
JMSContext context = cf.createContext(); // Throws exception
...
} catch (FileNotFoundException e) {
e.printStackTrace();
Assert.fail(e.getMessage());
} catch (IOException e) {
e.printStackTrace();
Assert.fail(e.getMessage());
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
}
The exception thrown:
com.ibm.msg.client.jms.DetailedJMSRuntimeException: JMSWMQ0018: Failed
to connect to queue manager 'RJE_PerfTest' with connection mode
'Client' and host name '10.32.1.69(1414)'. Check the queue manager is
started and if running in client mode, check there is a listener
running. Please see the linked exception for more information. at
com.ibm.msg.client.jms.DetailedJMSException.getUnchecked(DetailedJMSException.java:267)
at
com.ibm.msg.client.jms.internal.JmsErrorUtils.convertJMSException(JmsErrorUtils.java:173)
at
com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createContext(JmsConnectionFactoryImpl.java:478)
at
com.mycompany.mq.client.FileScanner.testPublish(FileScanner.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at
org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at
org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at
org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at
org.junit.runners.ParentRunner.run(ParentRunner.java:363) at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: com.ibm.mq.MQException: JMSCMQ0001: IBM MQ call failed with
compcode '2' ('MQCC_FAILED') reason '2540'
('MQRC_UNKNOWN_CHANNEL_NAME'). at
com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:203)
at
com.ibm.msg.client.wmq.internal.WMQConnection.(WMQConnection.java:424)
at
com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createV7ProviderConnection(WMQConnectionFactory.java:8475)
at
com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createProviderConnection(WMQConnectionFactory.java:7815)
at
com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl._createConnection(JmsConnectionFactoryImpl.java:303)
at
com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createContext(JmsConnectionFactoryImpl.java:444)
... 24 more Caused by: com.ibm.mq.jmqi.JmqiException:
CC=2;RC=2540;AMQ9204: Connection to host '10.32.1.69(1414)' rejected.
[1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2540;AMQ9520: Channel not
defined remotely.
[3=MQCLI.CLNTCONN]],3=10.32.1.69(1414),5=RemoteConnection.analyseErrorSegment]
at
com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:2314)
at
com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1285)
at
com.ibm.mq.ese.jmqi.InterceptedJmqiImpl.jmqiConnect(InterceptedJmqiImpl.java:377)
at com.ibm.mq.ese.jmqi.ESEJMQI.jmqiConnect(ESEJMQI.java:562) at
com.ibm.msg.client.wmq.internal.WMQConnection.(WMQConnection.java:357)
... 28 more Caused by: com.ibm.mq.jmqi.JmqiException:
CC=2;RC=2540;AMQ9520: Channel not defined remotely. [3=MQCLI.CLNTCONN]
at
com.ibm.mq.jmqi.remote.impl.RemoteConnection.analyseErrorSegment(RemoteConnection.java:4464)
at
com.ibm.mq.jmqi.remote.impl.RemoteConnection.receiveTSH(RemoteConnection.java:3199)
at
com.ibm.mq.jmqi.remote.impl.RemoteConnection.initSess(RemoteConnection.java:1274)
at
com.ibm.mq.jmqi.remote.impl.RemoteConnection.connect(RemoteConnection.java:895)
at
com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSessionFromNewConnection(RemoteConnectionSpecification.java:416)
at
com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSession(RemoteConnectionSpecification.java:312)
at
com.ibm.mq.jmqi.remote.impl.RemoteConnectionPool.getSession(RemoteConnectionPool.java:146)
at
com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1761)
... 32 more
DIS CHANNEL ('MQCLI.CLNTCONN')
3 : DIS CHANNEL ('MQCLI.CLNTCONN')
AMQ8414: Display Channel details.
CHANNEL(MQCLI.CLNTCONN) CHLTYPE(CLNTCONN)
AFFINITY(PREFERRED) ALTDATE(2020-03-06)
ALTTIME(11.34.36) CERTLABL( )
CLNTWGHT(0) COMPHDR(NONE)
COMPMSG(NONE) CONNAME(10.32.1.69)
DEFRECON(NO) DESCR( )
HBINT(300) KAINT(AUTO)
LOCLADDR( ) MAXMSGL(4194304)
MODENAME( ) PASSWORD( )
QMNAME(RJE_PerfTest) RCVDATA( )
RCVEXIT( ) SCYDATA( )
SCYEXIT( ) SENDDATA( )
SENDEXIT( ) SHARECNV(10)
SSLCIPH( ) SSLPEER( )
TPNAME( ) TRPTYPE(TCP)
USERID( )
With the Queue Manager configured as
DIS QMGR
2 : DIS QMGR
AMQ8408: Display Queue Manager details.
QMNAME(RJE_PerfTest) ACCTCONO(DISABLED)
ACCTINT(1800) ACCTMQI(OFF)
ACCTQ(OFF) ACTIVREC(MSG)
ACTVCONO(DISABLED) ACTVTRC(OFF)
ALTDATE(2020-03-04) ALTTIME(15.48.24)
AUTHOREV(DISABLED) CCSID(437)
CERTLABL(ibmwebspheremqrje_perftest) CERTVPOL(ANY)
CHAD(DISABLED) CHADEV(DISABLED)
CHADEXIT( ) CHLEV(DISABLED)
CHLAUTH(ENABLED) CLWLDATA( )
CLWLEXIT( ) CLWLLEN(100)
CLWLMRUC(999999999) CLWLUSEQ(LOCAL)
CMDEV(DISABLED) CMDLEVEL(800)
COMMANDQ(SYSTEM.ADMIN.COMMAND.QUEUE) CONFIGEV(DISABLED)
CONNAUTH(SYSTEM.DEFAULT.AUTHINFO.IDPWOS)
CRDATE(2020-02-20) CRTIME(16.25.00)
CUSTOM( ) DEADQ( )
DEFCLXQ(SCTQ) DEFXMITQ( )
DESCR( ) DISTL(YES)
INHIBTEV(DISABLED) IPADDRV(IPV4)
LOCALEV(DISABLED) LOGGEREV(DISABLED)
MARKINT(5000) MAXHANDS(256)
MAXMSGL(104857600) MAXPROPL(NOLIMIT)
MAXPRTY(9) MAXUMSGS(10000)
MONACLS(QMGR) MONCHL(OFF)
MONQ(OFF) PARENT( )
PERFMEV(DISABLED) PLATFORM(WINDOWSNT)
PSMODE(ENABLED) PSCLUS(ENABLED)
PSNPMSG(DISCARD) PSNPRES(NORMAL)
PSRTYCNT(5) PSSYNCPT(IFPER)
QMID(RJE_PerfTest_2020-02-20_16.25.00)
REMOTEEV(DISABLED) REPOS( )
REPOSNL( ) REVDNS(ENABLED)
ROUTEREC(MSG) SCHINIT(QMGR)
SCMDSERV(QMGR) SPLCAP(DISABLED)
SSLCRLNL( ) SSLCRYP( )
SSLEV(DISABLED) SSLFIPS(NO)
SSLKEYR(C:\ProgramData\IBM\MQ\qmgrs\RJE_PerfTest\ssl\key)
SSLRKEYC(0) STATACLS(QMGR)
STATCHL(OFF) STATINT(1800)
STATMQI(OFF) STATQ(OFF)
STRSTPEV(ENABLED) SUITEB(NONE)
SYNCPT TREELIFE(1800)
TRIGINT(999999999) VERSION(08000005)
XRCAP(NO)
The connectivity works fine.
How to troubleshoot this problem?
Thanks in advance.
This error comes out of a basic confusion between the channel types.
The client connection channel configured in the server is for something else, as pointed out in this forum: https://www.tek-tips.com/viewthread.cfm?qid=248122
"When you say you created a 'Client Connection' on the Queue Manager,
do you mean you created a channel with type CLNTCONN? This needs to be
type SVRCONN to allow client connections. CLNTCONN channels are never
use dby QMgrs - they are only there to create Channel Tables for
clients."
The client connection requires a server connection channel, created as explained here>
https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q031730_.htm
DEFINE CHANNEL(SWFMQ.CHANNEL) CHLTYPE(SVRCONN) TRPTYPE(TCP)
7 : DEFINE CHANNEL(SWFMQ.CHANNEL) CHLTYPE(SVRCONN) TRPTYPE(TCP)
AMQ8014: WebSphere MQ channel created.
Now my channel looks:
DIS CHANNEL ('SWFMQ.CHANNEL')
8 : DIS CHANNEL ('SWFMQ.CHANNEL')
AMQ8414: Display Channel details.
CHANNEL(SWFMQ.CHANNEL) CHLTYPE(SVRCONN)
ALTDATE(2020-03-06) ALTTIME(13.09.41)
CERTLABL( ) COMPHDR(NONE)
COMPMSG(NONE) DESCR( )
DISCINT(0) HBINT(300)
KAINT(AUTO) MAXINST(999999999)
MAXINSTC(999999999) MAXMSGL(4194304)
MCAUSER( ) MONCHL(QMGR)
RCVDATA( ) RCVEXIT( )
SCYDATA( ) SCYEXIT( )
SENDDATA( ) SENDEXIT( )
SHARECNV(10) SSLCAUTH(REQUIRED)
SSLCIPH( ) SSLPEER( )
TRPTYPE(TCP)

Why is mstor throwing a NotSerializableException on inbox.close()

I'm using the basic mstor logic with version 1.0.0 of of the maven mstor library, but it's throwing an Exception on the inbox.close() method. Note: I am not doing any writing to the disk so this Exception is odd. I made, as an attempt, my class which calls this code to "implement Serializable", but that did not help.
This code is running from a SpringBoot REST Service.
If I don't do an inbox.close(), then on Windows the mbox file is still open (not released by this library) after the method below completes.
Here's the basic code:
Properties properties = new Properties();
properties.setProperty("mail.store.protocol", "mstor");
properties.setProperty("mstor.mbox.metadataStrategy", "none");
properties.setProperty("mstor.mbox.cacheBuffers", "disabled");
properties.setProperty("mstor.mbox.bufferStrategy", "mapped");
properties.setProperty("mstor.metadata", "disabled");
properties.setProperty("mstor.mozillaCompatibility", "enabled");
Session session = Session.getInstance(properties);
try {
store = session.getStore(new URLName("mstor:" + pathToMboxFile));
store.connect();
inbox = (MStorFolder) store.getDefaultFolder();
inbox.open(Folder.READ_ONLY);
Message[] messages = inbox.getMessages();
int bodyPartCount = 0;
// ***********************
// process all mbox data.
// *************************
for (int pos = 0; pos < messages.length; pos++)
{
// processing.
}
catch (NoSuchProviderException e)
{
log.debug("MboxController NoSuchProviderException Exception: " + e.getMessage());
}
catch (javax.mail.MessagingException e)
{
errors.append(e);
log.debug("MboxController MessagingException Exception: " + e.getMessage());
}
finally
{
// close the mbox store
try
{
inbox.close(false);
store.close();
}
catch (MessagingException e)
{
log.debug("MboxController Closing Store Exception: " + e.getMessage());
}
}
Now, although the code does work and returns the mbox text and closes the file, when the inbox.close(false) runs, I get this error stack (or something close to it) each time in the Tomcat log:
2019-03-31 08:06:09 - Disk Write of 191 failed:
"java.io.NotSerializableException: net.fortuna.mstor.data.MessageInputStream
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:441)
at net.sf.ehcache.Element.writeObject(Element.java:791)
at sun.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1140)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
at net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream.serialize(MemoryEfficientByteArrayOutputStream.java:97)
at net.sf.ehcache.store.disk.DiskStorageFactory.serializeElement(DiskStorageFactory.java:413)
at net.sf.ehcache.store.disk.DiskStorageFactory.write(DiskStorageFactory.java:392)
at net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call(DiskStorageFactory.java:493)
at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1151)
at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1135)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

Plotting Image Histogram Using Androidplot

I m a beginner programmer, I am developing an android application which process an image and generate its histogram. I am using AndroidPlot to draw different color channels of an image in the histogram, but I'm having some errors and exceptions.
This is my code :
public class ImgHistogram extends Activity {
ImageView ImageView;
LinearLayout ll;
ImageView imgView;
private Bitmap source ;
private XYPlot xyPlot;
public XYSeries rSerie;
int[] intensities={
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,
101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,
201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
} ;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.histo);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
imgView = (ImageView) findViewById(R.id.img);
Bundle bundle = this.getIntent().getExtras();
source=(Bitmap) bundle.getParcelable("img");
imgView.setImageBitmap(source);
// initialize our XYPlot reference:
xyPlot = (XYPlot) findViewById(R.id.xyplot);
Bitmap image = Bitmap.createBitmap(source.getWidth(),source.getHeight(), Bitmap.Config.ARGB_8888);
ArrayList<Integer> rVals = new ArrayList<Integer>();
for (int x = 0; x < image.getWidth(); x++) {
for (int y = 0; y < image.getHeight(); y++) {
int color = image.getPixel(x, y);
rVals.add((color >> 16) & 0xff); //red channel
}}
rSerie = new SimpleXYSeries(
rVals, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "red channel");
// Create a formatter to format Line and Point of income series
LineAndPointFormatter format = new LineAndPointFormatter(
Color.rgb(0, 0, 255), // line color
Color.rgb(200, 200, 200), // point color
Color.rgb(10, 20, 20), // fill color (none)
null );
// add series to the xyplot:
xyPlot.addSeries(rSerie, format);
// Formatting the Domain Values ( X-Axis )
xyPlot.setDomainValueFormat(new Format() {
private static final long serialVersionUID = 1L;
#Override
public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) {
return new StringBuffer( intensities[ ( (Number)obj).intValue() ] );
}
#Override
public Object parseObject(String source, ParsePosition pos) {
return null;
}
});
xyPlot.setDomainLabel("");
xyPlot.setRangeLabel("");
// Increment X-Axis by 1 value
xyPlot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 1);
xyPlot.getGraphWidget().setRangeLabelWidth(50);
// Reduce the number of range labels
xyPlot.setTicksPerRangeLabel(2);
// Reduce the number of domain labels
xyPlot.setTicksPerDomainLabel(2);
// Remove all the developer guides from the chart
// xyPlot.disableAllMarkup();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
and this is the stack trace:
05-23 23:52:21.731: E/AndroidRuntime(30404): FATAL EXCEPTION: main
05-23 23:52:21.731: E/AndroidRuntime(30404): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dreamaker.magipixel/com.dreamaker.magipixel.processing.ImgHistogram}: java.lang.NullPointerException
05-23 23:52:21.731: E/AndroidRuntime(30404): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
05-23 23:52:21.731: E/AndroidRuntime(30404): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
05-23 23:52:21.731: E/AndroidRuntime(30404): at android.app.ActivityThread.access$700(ActivityThread.java:159)
05-23 23:52:21.731: E/AndroidRuntime(30404): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
05-23 23:52:21.731: E/AndroidRuntime(30404): at android.os.Handler.dispatchMessage(Handler.java:99)
05-23 23:52:21.731: E/AndroidRuntime(30404): at android.os.Looper.loop(Looper.java:137)
05-23 23:52:21.731: E/AndroidRuntime(30404): at android.app.ActivityThread.main(ActivityThread.java:5419)
05-23 23:52:21.731: E/AndroidRuntime(30404): at java.lang.reflect.Method.invokeNative(Native Method)
05-23 23:52:21.731: E/AndroidRuntime(30404): at java.lang.reflect.Method.invoke(Method.java:525)
05-23 23:52:21.731: E/AndroidRuntime(30404): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
05-23 23:52:21.731: E/AndroidRuntime(30404): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
05-23 23:52:21.731: E/AndroidRuntime(30404): at dalvik.system.NativeStart.main(Native Method)
05-23 23:52:21.731: E/AndroidRuntime(30404): Caused by: java.lang.NullPointerException
05-23 23:52:21.731: E/AndroidRuntime(30404): at com.dreamaker.magipixel.processing.ImgHistogram.onCreate(ImgHistogram.java:110)
05-23 23:52:21.731: E/AndroidRuntime(30404): at android.app.Activity.performCreate(Activity.java:5372)
05-23 23:52:21.731: E/AndroidRuntime(30404): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
05-23 23:52:21.731: E/AndroidRuntime(30404): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
05-23 23:52:21.731: E/AndroidRuntime(30404): ... 11 more
I hope that someone could help me!
Given the fact that in the line in question (ImgHistogram.java:110) you have only 1 object which could possibly cause the exception - xyPlot:
xyPlot.addSeries(rSerie, format);
This suggests that findViewByID returns null =< xyPlot is null. There is a question about this: findViewByID returns null the accepted answer should solve your problem:
Wait until onFinishInflate()

Can I put the renderscript memory allocation inside a loop to process a series of variable size arrays?

I am trying to modify the parallel reduction algorithm. I am using a logic to divide an given array length into powers of 2. For example if i put in the number 26, I make array 1 of 16 elements, the next array of 8 elements and the last array of 2 elements. Although 26 in itself is not a power of 2 but by this method i have more number of sub arrays created from the main array where each of them can be subjected to parallel reduction. but to be able to do this in rendercript i use a loop to each time rewrite the renderscript memory allocation while it has only one context but it is throwing me errors. can you help me in this part? point me to my blind spot? the following is my code!
private void createScript() {
log ("i'm in createscript");
int pp=0;
int qq=1;
int ii=0;
**mRS = RenderScript.create(this);**
for (int gstride=0; gstride < address.length/2; gstride++){
log("im in stride noof gstride:"+gstride);
// this is the address array location
int strtadd=address[ii];
int sze = 0;
sze=address[qq]-address[pp]+1;
tempin =new int [sze];
System.arraycopy(input, strtadd, tempin, 0, tempin.length);
strtadd=address[ii+2];
log("Generated size of array: " + tempin.length);
//renderscript declarations
`enter code here`**mInAllocation=Allocation.createSized(mRS,Element.I32(mRS),tempin.length);
`enter code here`mOutAllocation=Allocation.createSized(mRS,Element.I32(mRS),address.length/2); `
mInAllocation.copyFrom(tempin);
mScript = new ScriptC_reduce2(mRS, getResources(), R.raw.reduce2);
//int row_width = input.length;
mScript.bind_gInarray(mInAllocation);
mScript.set_gIn(mInAllocation);
mScript.set_gOut(mOutAllocation);
mScript.set_gScript(mScript);
//time measurement
long lStartTime = new Date().getTime();
for (int stride = tempin.length / 2; stride > 0; stride /= 2) {
mScript.set_stride(stride);
mScript.invoke_filter();
}**
long lEndTime = new Date().getTime();
long difference = lEndTime - lStartTime;
nettime[gstride]=difference;
pp=pp+1;
qq=qq+1;
mInAllocation.copyTo(tempin);
output[gstride] = tempin[0];
}
int sum=0;
int sum2=0;
int i = 0; .
while(i < output.length) {
sum += output[i];
sum2 +=nettime[i];
i++;
}
t1.setText(String.format("output:%s\n\nExecution time:%s",
+sum, +sum2 +"ms")); //input:%s\n\n ArrayToString(input),
}
I get the following error as copied from the error log: I don't think its out of memory ` `error.
V/RenderScript( 2890): rsContextCreate dev=0x2a14ea68
V/ScriptC ( 2890): Create script for resource = reduce2
D/StopWatch( 2890): StopWatch bcc: RSCompilerDriver::loadScriptCache time (us): 1988
D/StopWatch( 2890): StopWatch bcc: RSCompilerDriver::build time (us): 2485
D/AndroidRuntime( 2890): Shutting down VM
W/dalvikvm( 2890): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
E/AndroidRuntime( 2890): FATAL EXCEPTION: main
E/AndroidRuntime( 2890): java.lang.RuntimeException: Unable to start activity `enter code `enter code here`ComponentInfo{com.example.paralleladd2/com.example.paralleladd2.Paralleladd2}:java.lang .NullPointerException
E/AndroidRuntime( 2890): at `enter code here`android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
E/AndroidRuntime( 2890): at `enter code here`android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
E/AndroidRuntime( 2890): at android.app.ActivityThread.access$600(ActivityThread.java:141)
E/AndroidRuntime( 2890): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
E/AndroidRuntime( 2890): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 2890): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 2890): at android.app.ActivityThread.main(ActivityThread.java:5041)
E/AndroidRuntime( 2890): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2890): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 2890): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime( 2890): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime( 2890): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 2890): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 2890): at com.example.paralleladd2.Paralleladd2.createScript(Paralleladd2.java:157)
E/AndroidRuntime( 2890): at com.example.paralleladd2.Paralleladd2.onCreate(Paralleladd2.java:48)
E/AndroidRuntime( 2890): at android.app.Activity.performCreate(Activity.java:5104)
E/AndroidRuntime( 2890): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
E/AndroidRuntime( 2890): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
Allocation creation should be fine inside the loop. I think your problem is coming from having the script creation inside the loop. I would create one reduce script outside your allocation creation loop and re-use it in the loop.
Script creation is very resource intensive and could be running the system out of resources.

Resources