Error during opening file: java.lang.ArrayIndexOutOfBoundsException: arraycopy: destination index -4 out of bounds for byte[256] - sshj

During opening the file in this way:
RemoteFile remoteFile = sftpClient.open(path)
I've faced with following error with stacktrace:
java.lang.ArrayIndexOutOfBoundsException: arraycopy: destination index -4 out of bounds for byte[256]
at net.schmizz.sshj.common.Buffer.putRawBytes(Buffer.java:271)
at net.schmizz.sshj.connection.channel.ChannelOutputStream$DataBuffer.write(ChannelOutputStream.java:64)
at net.schmizz.sshj.connection.channel.ChannelOutputStream.write(ChannelOutputStream.java:141)
at net.schmizz.sshj.connection.channel.ChannelOutputStream.write(ChannelOutputStream.java:131)
at net.schmizz.sshj.sftp.SFTPEngine.transmit(SFTPEngine.java:292)
at net.schmizz.sshj.sftp.SFTPEngine.request(SFTPEngine.java:130)
at net.schmizz.sshj.sftp.SFTPEngine.doRequest(SFTPEngine.java:136)
at net.schmizz.sshj.sftp.SFTPEngine.open(SFTPEngine.java:141)
at net.schmizz.sshj.sftp.SFTPClient.open(SFTPClient.java:68)
at net.schmizz.sshj.sftp.SFTPClient.open(SFTPClient.java:73)
at net.schmizz.sshj.sftp.SFTPClient.open(SFTPClient.java:78)
at com.echovox.paidle.common.util.SftpUtil.getFileDataListFromZip(SftpUtil.java:86)
at com.echovox.paidle.common.util.SftpUtil.lambda$getFileDataWithRetry$1(SftpUtil.java:139)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
I found 3 implementation of open method:
public RemoteFile open(String filename)
public RemoteFile open(String filename, Set<OpenMode> mode)
public RemoteFile open(String filename, Set<OpenMode> mode, FileAttributes attrs)
Is it possible to use somehow Set<OpenMode> mode and/or FileAttributes attrs to avoid this issue?

Related

Create Jax2b marshaller Formatted_Output property doesnt work

Im trying to create a Marshaller with Jax2b with a formatted output property:
protected static Marshaller createMarshaller() throws AMLParseException {
final Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setClassesToBeBound(CAEXFile.class);
final Map<String, Object> props = new HashMap<>();
props.put(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, true); //:TODO
//marshaller.setJaxbContextProperties(props);
return marshaller;
}
If i set the JaxbContextProperties it says "Property "jaxb.formatted.output" is not supported" :
Caused by: javax.xml.bind.JAXBException: Eigenschaft "jaxb.formatted.output" wird nicht unterstützt.
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:118) ~[jaxb-runtime-2.3.2.jar:2.3.2]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:251) ~[jakarta.xml.bind-api-2.3.2.jar:2.3.2]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:240) ~[jakarta.xml.bind-api-2.3.2.jar:2.3.2]
at javax.xml.bind.ContextFinder.find(ContextFinder.java:363) ~[jakarta.xml.bind-api-2.3.2.jar:2.3.2]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:691) ~[jakarta.xml.bind-api-2.3.2.jar:2.3.2]
at org.springframework.oxm.jaxb.Jaxb2Marshaller.createJaxbContextFromClasses(Jaxb2Marshaller.java:551) ~[spring-oxm-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.oxm.jaxb.Jaxb2Marshaller.getJaxbContext(Jaxb2Marshaller.java:503) ~[spring-oxm-5.2.4.RELEASE.jar:5.2.4.RELEASE]
If i dont set the Property it works.
Any clue how to solve this ?
You can use
marshaller.setMarshallerProperties(Collections.singletonMap(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE ));

while I test my app, I get the follow error in the Android-Studio-Consol:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.firstproject, PID: 6019
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.firstproject/com.example.firstproject.MainActivity}: android.view.InflateException: Binary XML file line #25: Error inflating class android.webkit.WebView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: android.view.InflateException: Binary XML file line #25: Error inflating class android.webkit.WebView
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.example.firstproject.MainActivity.onCreate(MainActivity.java:19)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
at android.app.ActivityThread.access$800(ActivityThread.java:151) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5254) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55) 
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555) 
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161) 
at com.example.firstproject.MainActivity.onCreate(MainActivity.java:19) 
at android.app.Activity.performCreate(Activity.java:5990) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
at android.app.ActivityThread.access$800(ActivityThread.java:151) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5254) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x2040003
at android.content.res.Resources.getText(Resources.java:299)
at android.content.res.Resources.getString(Resources.java:385)
at com.android.org.chromium.content.browser.ContentViewCore.setContainerView(ContentViewCore.java:684)
at com.android.org.chromium.content.browser.ContentViewCore.initialize(ContentViewCore.java:608)
at com.android.org.chromium.android_webview.AwContents.createAndInitializeContentViewCore(AwContents.java:631)
at com.android.org.chromium.android_webview.AwContents.setNewAwContents(AwContents.java:780)
at com.android.org.chromium.android_webview.AwContents.(AwContents.java:619)
at com.android.org.chromium.android_webview.AwContents.(AwContents.java:556)
at com.android.webview.chromium.WebViewChromium.initForReal(WebViewChromium.java:311)
at com.android.webview.chromium.WebViewChromium.access$100(WebViewChromium.java:96)
at com.android.webview.chromium.WebViewChromium$1.run(WebViewChromium.java:263)
at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.drainQueue(WebViewChromium.java:123)
at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue$1.run(WebViewChromium.java:110)
at com.android.org.chromium.base.ThreadUtils.runOnUiThread(ThreadUtils.java:144)
at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.addTask(WebViewChromium.java:107)
at com.android.webview.chromium.WebViewChromium.init(WebViewChromium.java:260)
at android
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final WebView webView = (WebView) findViewById(R.id.web_view) ;
final EditText editText = (EditText) findViewById(R.id.etext) ;
webView.setWebViewClient (new WebViewClient() );
Button button = (Button)findViewById(R.id.btn_go) ;
button.setOnClickListener (new View.OnClickListener() {
#Override
public void onClick (View v){
webView.loadUrl(editText.getText().toString() ) ;
}
});
}
}
Here's XML code :
Here's Emulator :

Issue populating map in Groovy

I've got an interesting issue in groovy, I am trying to populate a map and for some reason it doesn't work, here is the program (just made a bare-bones version to see the problem easier):
public class dd2 {
Map<String, String> subscriptions = ["Listing":"a Listing","Issue":"an Issue"]
Map<String, Object> subscriptionAttributes = new HashMap<String, Object>()
public static void main(String[] args) throws Exception {
def dd = new dd2()
dd.getSubscriptionAttributes()
}
def getSubscriptionAttributes(){
subscriptions.each {
def attributes = ""
println "getting ${it.key}"
subscriptionAttributes.put(it.key, attributes)
}
}
}
if I remove:
subscriptionAttributes.put(it.key, attributes)
it iterates through the whole map of subscriptions. If I try to add to the subscriptionAttributes map it will only get Listing until eventually I get stack overflow.
What am I doing wrong?
It's due to def getSubscriptionAttributes() method name - when getter method is defined Groovy uses it wherever you use a property name. So in your case you are getting:
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844
Exception in thread "main" java.lang.StackOverflowError
at sun.net.www.protocol.file.Handler.parseURL(Handler.java:67)
at java.net.URL.<init>(URL.java:622)
at java.net.URL.<init>(URL.java:490)
at sun.misc.URLClassPath$FileLoader.getResource(URLClassPath.java:1259)
at sun.misc.URLClassPath.getResource(URLClassPath.java:239)
at java.net.URLClassLoader$1.run(URLClassLoader.java:365)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at groovy.lang.Closure.call(Closure.java:416)
at groovy.lang.Closure.call(Closure.java:430)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.callClosureForMapEntry(DefaultGroovyMethods.java:5278)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2117)
at org.codehaus.groovy.runtime.dgm$164.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at dd2.getSubscriptionAttributes(dd2.groovy:13)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1850)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:3758)
at dd2.getProperty(dd2.groovy)
at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:174)
at groovy.lang.Closure.getPropertyTryThese(Closure.java:312)
at groovy.lang.Closure.getPropertyOwnerFirst(Closure.java:306)
at groovy.lang.Closure.getProperty(Closure.java:295)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:50)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307)
at dd2$_getSubscriptionAttributes_closure1.doCall(dd2.groovy:16)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
at groovy.lang.Closure.call(Closure.java:414)
at groovy.lang.Closure.call(Closure.java:430)
because when you say:
subscriptionAttributes.put(it.key, attributes)
Groovy actually tries doing:
getSubscriptionAttributes().put(it.key, attributes)
and you get into infinite loop.
Change your method name so it does not conflict with internal map variable and you're good.

thread-weaver with hibernate unit testing

I am trying to write a multithread unit test for my hibernate test.
I chose thread-weaver and got a little play with it.
I used the HSQL Database engine for my hibernate testing which is an in memory database.
It was working perfect until i wanted to write some multi thread unit tests.
Since i am new to thread weaver, i could make some newbie mistakes.
I knew the thread weaver is loading my class with its customized loader.
But in the #ThreadedBefore i try to set the sessionFactory for HSQL one. However, i got a bunch of error logs like
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [sun.misc.Launcher$AppClassLoader#ece88d2].
log4j:ERROR Could not instantiate appender named "console".
log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [com.google.testing.instrumentation.InstrumentedClassLoader#2a57a184] whereas object of type
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.google.testing.threadtester.MethodCaller.invoke(MethodCaller.java:71)
at com.google.testing.threadtester.BaseThreadedTestRunner.runTests(BaseThreadedTestRunner.java:179)
at com.google.testing.threadtester.BaseThreadedTestRunner.runTests(BaseThreadedTestRunner.java:143)
at com.amazon.amazonclicksdali.test.simpleTest.run(simpleTest.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at com.intellij.junit4.JUnit4TestRunnerUtil$IgnoreIgnoredTestJUnit4ClassRunner.runChild(JUnit4TestRunnerUtil.java:306)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at com.google.testing.threadtester.MethodCaller.invoke(MethodCaller.java:68)
... 30 more
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.google.testing.threadtester.MethodCaller.invoke(MethodCaller.java:71)
at com.google.testing.threadtester.ThreadedTestWrapper.runTests(ThreadedTestWrapper.java:71)
... 35 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at com.google.testing.threadtester.MethodCaller.invoke(MethodCaller.java:68)
... 36 more
Caused by: java.lang.NullPointerException
at com.google.testing.instrumentation.InstrumentedClassLoader.loadClassData(InstrumentedClassLoader.java:152)
at com.google.testing.instrumentation.InstrumentedClassLoader.findClass(InstrumentedClassLoader.java:137)
at com.google.testing.instrumentation.InstrumentedClassLoader.loadClass(InstrumentedClassLoader.java:113)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:278)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:170)
at org.hibernate.cfg.Configuration.applyHibernateValidatorLegacyConstraintsOnDDL(Configuration.java:1663)
at org.hibernate.cfg.Configuration.applyConstraintsToDDL(Configuration.java:1653)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1445)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1375)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:717)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:188)
at com.amazon.amazonclicksdali.test.scheduler.repository.TestSessionHelper.getSessionFactory(TestSessionHelper.java:20)
at com.amazon.amazonclicksdali.test.simpleTest.setup(simpleTest.java:45)
... 41 more
A simple test is like this
public class simpleTest {
Script<RDBInternalReportRepository> main;
Script<RDBInternalReportRepository> second;
final RDBInternalReportRepository target = new RDBInternalReportRepository();
SessionFactory sessionFactory;
RDBInternalReport internalReport1;
#Test
public void run() {
new ThreadedTestRunner().runTests(getClass(), RDBInternalReportRepository.class);
}
#ThreadedBefore
public void setup() throws Exception {
TestSessionHelper testSessionHelper = new TestSessionHelper();
sessionFactory = testSessionHelper.getSessionFactory();
target.setSessionFactory(sessionFactory);
internalReport1 = new RDBInternalReport();
internalReport1.setReferenceId("aaa");
internalReport1.setReportName("testReportName");
internalReport1.setSubmittedDate(new DateTime(2015, 1, 1, 0, 0));
internalReport1.setMarketplaceId(1);
internalReport1.setHashKey("hashValues");
internalReport1.setDedupingString("uid");
internalReport1.setState(ReportState.SUBMITTED);
internalReport1.setErrorCount(0);
target.createOrUpdateInternalReport(internalReport1);
}
#ThreadedTest
public void testSession() throws Exception {
main = new Script<RDBInternalReportRepository>(target);
second = new Script<RDBInternalReportRepository>(target);
main.addTask(new ScriptedTask<RDBInternalReportRepository>() {
#Override
public void execute() throws Exception {
IInternalReport report1 = target.getInternalReport("aaa");
releaseTo(second);
}
});
second.addTask(new ScriptedTask<RDBInternalReportRepository>() {
#Override
public void execute() throws Exception {
releaseTo(main);
}
});
new Scripter<RDBInternalReportRepository>(main, second).execute();
}
}
It fails to even load the sessionFactory which is a simple HSQL database.
It looks as though the NullPointerException is caused by getSystemResourceAsStream() returning null. See line 136 here: https://github.com/google/thread-weaver/blob/5c316abcfdfa1832df981f90cfa5c5811003012e/main/com/google/testing/instrumentation/InstrumentedClassLoader.java
I found the following question which sounds like a pretty good explanation as to what's going on: getSystemResourceAsStream() returns null
It sounds as though a fix might be to add the following to 'InstrumentedCLassLoader.findClass()'
InputStream input = getSystemResourceAsStream(resourceName);
if (input == null) {
return Thread.currentThread().getContextClassLoader().findClass(className);
}
Can you try building threadweaver from source with this fix? Alternatively, I would need to run your entire test and verify.

App unfortunately closing

I am receiving "App has unfortunately stopped" error. I am using parse so I am assuming the issue lies somewhere within that.
This is the java file that I causes the error when loading
public class NewTipActivity extends Activity {
private Tip tip;
#Override
protected void onCreate(Bundle savedInstanceState) {
tip = new Tip();
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
//New Tip Fragment
setContentView(R.layout.activity_new_tip);
FragmentManager manager = getFragmentManager();
Fragment fragment = manager.findFragmentById(R.id.fragmentContainer);
if (fragment == null) {
fragment = new NewTipFragment();
manager.beginTransaction().add(R.id.fragmentContainer, fragment)
.commit();
}
}
public Tip getCurrentTip() {
return tip;
}
}
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.holyapp.danshinn.wingman_etiquette/com.holyapp.danshinn.wingman_etiquette.NewTipActivity}:
java.lang.IllegalArgumentException: cannot setReadAccess for a user
with null id
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: cannot setReadAccess for a user with null id
at com.parse.ParseACL.setReadAccess(ParseACL.java:308)
at com.parse.ParseACL.getDefaultACL(ParseACL.java:61)
at com.parse.ParseObject.setDefaultValues(ParseObject.java:3385)
at com.parse.ParseObject.(ParseObject.java:181)
at com.parse.ParseObject.(ParseObject.java:127)
at com.holyapp.danshinn.wingman_etiquette.Tip.(Tip.java:17)
at com.holyapp.danshinn.wingman_etiquette.NewTipActivity.onCreate(NewTipActivity.java:20)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

Resources