I have an IllegalArgumentException and have no Idea how to fix it.
Exception in thread "Display" java.lang.ExceptionInInitializerError
at com.cube.zambezi.graphics.Sprite.<clinit>(Sprite.java:16)
at com.cube.zambezi.level.tile.Tile.<clinit>(Tile.java:15)
at com.cube.zambezi.level.Level.getTile(Level.java:95)
at com.cube.zambezi.level.Level.render(Level.java:71)
at com.cube.zambezi.Game.render(Game.java:172)
at com.cube.zambezi.Game.run(Game.java:142)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: input == null!
at javax.imageio.ImageIO.read(Unknown Source)
at com.cube.zambezi.graphics.SpriteSheet.load(SpriteSheet.java:34)
at com.cube.zambezi.graphics.SpriteSheet.<init>(SpriteSheet.java:29)
at com.cube.zambezi.graphics.SpriteSheet.<clinit>(SpriteSheet.java:19)
... 7 more
If you need more information, tell me.
You are trying to read an image, but your input is null.
Make sure you have a valid input, either from a stream, a file or a URL, and the problem is solved.
If you don't know in advance, a simple if (input != null) around the ImageIO.read will fix it.
Related
I'm trying to run a Groovy script in a soapUI Test case.
The script does nothing but take the response, extract a value and use it in the next request. The extracting works when I run my script standalone. But, as soon as I try to run my test case I get following error:
ERROR:
java.lang.ClassCastException: java.lang.String cannot be cast to org.apache.log4j.Logger
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:125)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:211)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:47)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:138)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:46)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:128)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Even when I remove all code from my script I get the error. If I remove the whole script the test case runs without a problem. Anyone has an idea?
The syntax of your assert statement isn't correct. If you're testing for null, something like the following will work:
assert !context.response: "Response Empty or Null"
It's also looks like you're using the assertion to control your script logic, but this is not a good practice. An if-then-else clause would make your intent clearer.
I cannot make a simple Speech-To-Text app work (I'm new to Java). I have been working on this code for several days and refuses to launch due to these errors:
08-13 12:35:08.784 26041-26041/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.blindnavi.navirecog2, PID: 26041
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.blindnavi.navirecog2/com.blindnavi.navirecog2.NaviVoice}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Window$Callback android.view.Window.getCallback()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2819)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Window$Callback android.view.Window.getCallback()' on a null object reference
at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:117)
at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:149)
at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:29)
at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:54)
at android.support.v7.app.AppCompatDelegateImplV23.<init>(AppCompatDelegateImplV23.java:31)
at android.support.v7.app.AppCompatDelegateImplN.<init>(AppCompatDelegateImplN.java:31)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:198)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:183)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:519)
at android.support.v7.app.AppCompatActivity.findViewById(AppCompatActivity.java:190)
at com.blindnavi.navirecog2.NaviVoice.<init>(NaviVoice.java:17)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1086)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2809)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
I do not know what most of these errors mean so i cannot fix the program myself. Please leave your suggestions below!
Your help is appreciated!
As discussed in another stackoverflow question Attempt to invoke virtual method 'android.view.Window$Callback android.view.Window.getCallback()' on a null object reference
An Activity is not fully initialized and ready to look up views until after setContentView(...) is called in onCreate().
So only declare the fields uninitialized and then assign the values in onCreate:
I have a custom textfield, PersistentPromptTextField that extends TextField and would like to be able to add it my .fxml file. When I do and I run it, I get a list of errors such as this:
Caused by: java.lang.InstantiationException: gui.PersistentPromptTextField
at java.lang.Class.newInstance(Unknown Source)
at sun.reflect.misc.ReflectUtil.newInstance(Unknown Source)
... 75 more
Caused by: java.lang.NoSuchMethodException: gui.PersistentPromptTextField.<init>()
at java.lang.Class.getConstructor0(Unknown Source)
... 77 more
In my .fxml file I have included <?import gui.PersistentPromptTextField?> as well, but obviously I am missing something.
The error raised due to the FXMLLoader is (by default) tried to instantiate the given class using its a no-arg constructor. If you didn't define, try it.
Instantiating using a constructor having some arguments, you need to use #NamedArgs annotation. See this comprehensive answer for more details.
I have a piece of code that prints the current java file for logging purposes.
final StackTraceElement stackTraceElement = new Throwable().fillInStackTrace().getStackTrace()[2];
final String parentClassName = stackTraceElement.getFileName().replaceAll(".java", "");
final int lineNumber = stackTraceElement.getLineNumber();
I wrote something in groovy that uses the above code to print logs, it works, most of the time, however after couple of runs I'm starting to get NPE
java.lang.NullPointerException
at com.bla.general.util.log.LogUtils.generateLogMessage(LogUtils.java:140)
at com.bla.general.util.log.LogUtils.info(LogUtils.java:67)
at sun.reflect.GeneratedMethodAccessor831.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:43)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:88)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.bla.AppVersionServiceImpl.getAppVersion(AppVersionServiceImpl.groovy:47)
When the following line is the originator:
LogUtils.info("Trying to get details for device hash ${deviceHash}");
I'm using tomcat and java 1.7 as my stack. After restarting Tomcat things get back to normal.
It's my first endeavor to the dynamic world of JVM. I'll appreciate if you can enlighten me
What is the meaning of groovy.lang$run.call(Unknown Source) and on what circumstances it will throw, this is the error what i'm getting in my groovy program
at groovy.lang$run.call(Unknown Source)
at groovy.lang.run(groovy.lang.Two_Script:6)
...................................................
...................................................
at groovy.lang.run(groovy.lang.Two_Script:6)
at groovy.lang$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:121)
at one_script.run(level_one_script.groovy:5)
why it has not thrown at the compile time only # runtime it has thrown any Idea ?
attached the sample groovy these are very simple recursive calls;
level_one_script.groovy
new Two_Script(binding).run()
Two_Script.groovy
new Three_Script().run()
Three_Script.groovy
println "Anish"
the exception was thrown while evaluating Three_Script.groovy , it give me recurive call on Two_Script.groovy
Exception occurred while executing the script [level_one_script.groovy] - [java.lang.StackOverflowError].
try
{
compiledScript.eval(bindings)
//compiledScript is the type of CompiledScript
}
Surprising part is if i remove the call new Three_Script().run() from "Two_Script.groovy"
it shows me correct result
Surprising
If the Groovy scripts are all defined in a package, the error is not thrown.
If the scripts are moved to the default package (no package), the error is thrown.
What is the actual exception thrown (first few lines)
Looks like there's problem in your file level_one_script.groovy at line 5