I can't understand why I'm getting this error: java.lang.RuntimeException: Resource not found I'm trying to make a simple 2d game using Slick and LWJGL libraries, I followed this guide http://www.youtube.com/playlist?list=PLaNw_AbDFccGkU5gnFYquQ0PNQPmmD-Q7 and I managed to make even some more by myself.
The thing is that I am receiving this error even though the image does exist in the specified location. The game runs completely fine and suddenly quits with the error I already mentioned.
The error:
Wed Nov 27 14:43:46 PST 2013 ERROR:Resource not found:
/home/tomtam/workspace/Game/gfx/world/object/blockgreen.png
java.lang.RuntimeException: Resource not found:
/home/tomtam/workspace/Game/gfx/world/object/blockgreen.png
at org.newdawn.slick.util.ResourceLoader.getResourceAsStream(ResourceLoader.java:69)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:273)
at org.newdawn.slick.Image.<init>(Image.java:270)
at org.newdawn.slick.Image.<init>(Image.java:244)
at org.newdawn.slick.Image.<init>(Image.java:232)
at org.newdawn.slick.Image.<init>(Image.java:198)
at tomtam.game.object.BlockGreen.render(BlockGreen.java:18)
at tomtam.game.main.World.render(World.java:447)
at tomtam.game.state.PlayState.render(PlayState.java:76)
at org.newdawn.slick.state.StateBasedGame.render(StateBasedGame.java:207)
at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:703)
at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:456)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:361)
at tomtam.game.main.Main.main(Main.java:36)
Wed Nov 27 14:43:46 PST 2013 ERROR:Game.render() failure - check the game code.
org.newdawn.slick.SlickException: Game.render() failure - check the game code.
at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:706)
at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:456)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:361)
at tomtam.game.main.Main.main(Main.java:36)
So the error points to this part of the code (image):
public void render(GameContainer gc, Graphics g) throws SlickException
{
super.render(gc, g);
image = new Image("/home/tomtam/workspace/Game/gfx/world/object/blockgreen.png");
}
I am not a skilled programmer, but I guess that this error is because the image is getting rendered nonstop, even if it's location or other information haven't changed. That may produce some lag spikes, right..? So, I tried to change it to:
try
{
image = new Image("/home/tomtam/workspace/Game/gfx/world/object/blockgreen.png");
}
catch (RuntimeException npe)
{
}
I know that it's a bad thing to do it like this, however, this way I am not receiving any errors and everything works fine for some time. After some time some images starts blinking and the more I wait, the less time they are showing up until finally disappearing.
The code is kinda long, but I can post it, just ask. Any help will be appreciated.
Usually a "java.lang.RuntimeException: Resource not found" occurs when your resources (images now) are not in your CLASSPATH and generally it is a classpath issue.
This may also help you.
Related
Hej.
First of all: sorry for maybe asking a very simple question, I am very new to Java.
Here is my problem: I updated the dependenciy of an ancient code from using net.sourceforge.htmlunit version 2.8 to 2.37.0 (this was recommended by the Github security bot).
Now my code is not compiling and throws two errors.
Here is the relevant code:
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.WebClient;
...
WebClient webClient = new WebClient(FIREFOX_3);
webClient.setTimeout(50000);
HtmlPage page = webClient.getPage("http://king.smith.man.ac.uk/mcpred/");
First error:
[ERROR] ./MissedCleavageAnalysisAdaptor.java:[64,53] cannot find symbol
[ERROR] symbol: variable FIREFOX_3
Second error:
[ERROR] ./MissedCleavageAnalysisAdaptor.java:[65,26] cannot find symbol
[ERROR] symbol: method setTimeout(int)
I managed to avoid the first error by simply deleting the "FIREFOX_3". Using "FIREFOX" (= newest version of firefox) or "FIREFOX_78" instead did not work and threw the same error.
With the second error, I cannot see the problem. I tried other integers or first defining an integer int timeout = 50000; and webClient.setTimeout(timeout);. Always the same error occurs. It seems like the method setTimeout was not imported. However, this should be imported together with WebClient, shouldn't it?
Can you please give me a hint how to tackle these errors?
Thanks a lot!
Wow thats a huge jump 2.8 was released Aug 5, 2010 and 2.37 in January 28, 2020.
The current version is 2.46.0 rom January 2, 2021 - maybe it makes sense to directly migrate to this one.
If you have a look at the release notes you will find this line:
WebClient: deprecated setTimeout() and getTimeout(). Use webClient.getOptions() instead.
for the release 2.11. Means - you have to change your code like this:
webClient.getOptions().setTimeout(50000);
The whole release notes are available here https://htmlunit.sourceforge.io/changes-report.html
I recently updated to AnyLogic PLE 8.4.0 and Java SE 12 on my Windows 10 laptop. And now an AnyLogic model that used to work earlier stops with the error "The method getJComponent() is undefined for the type ShapeTextField." I looked it up in AnyLogic/Help and I notice that getJComponent is identified as "Deprecated" and no alternative is identified. It appears to me that some mismatch happened between AnyLogic and Java updates that resulted in this error. I would appreciate any workarounds to get the model working.
Tried replacing getJComponent() with the following:
by getX() - gave error "cannot cast from double to Jtextfield"
by getPresentable() - gave error "cannot cast from Presentable to Jtextfield"
by getClass() - gave error "Description: Cannot cast from Class to JTextField."
by getComponentGraphics() - gave error "Description: The method getComponentGraphics() is undefined for the type ShapeTextField."
by equals - gave error "Description: The method equals(Object) in the type Object is not applicable for the arguments ()."
The code is:
((JTextField)(editbox.getJComponent())).setHorizontalAlignment(JTextField.LEFT);
This is defined in Simulation - Simulation Experiment / Java Actions/ Initial Experiment Setup field
Expected result: No error message. And the model should proceed to run window.
Thanks to the inputs from #Benjamin and #Felipe the following worked:
I replaced the editbox and buttons with corresponding artifacts from
AL8.4 palette. I copied the code from the earlier artifacts to
corresponding fields in the new artifacts. I deleted the artifacts
that were from AL7.
I commented out the line that was meant to align the editbox since
that capability is not available anymore.
With the above two changes I didn't get the error message about undefined method. The editbox and buttons worked and allowed me to enter XML filename and reading it with an XML parser routine. I have now run into issue with JAXB integration with AL8.4 and haven't been able to get past that yet. I will be posting that as a separate question.
When I run my code on the AWS Lambda server I get this showing up
https://gyazo.com/7b26f2af77451117cea8ab38f52fcbde
Its an error obviously, stack trace being
{
"errorMessage":
"com.fasterxml.jackson.datatype.jsr310.deser.JSR310DateTimeDeserializerBase.findFormatOverrides(Lcom/fasterxml/jackson/databind/DeserializationContext;Lcom/fasterxml/jackson/databind/BeanProperty;Ljava/lang/Class;)Lcom/fasterxml/jackson/annotation/JsonFormat$Value;",
"errorType": "java.lang.NoSuchMethodError",
"stackTrace": [
"com.fasterxml.jackson.datatype.jsr310.deser.JSR310DateTimeDeserializerBase.createContextual(JSR310DateTimeDeserializerBase.java:34)",
"com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer.createContextual(InstantDeserializer.java:235)",
"com.fasterxml.jackson.databind.DeserializationContext.handleSecondaryContextualization(DeserializationContext.java:669)",
"com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:430)",
"com.fasterxml.jackson.databind.deser.std.StdDeserializer.findDeserializer(StdDeserializer.java:947)",
"com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:439)",
"com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:296)",
"com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)",
"com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)",
"com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:428)",
"com.fasterxml.jackson.databind.jsontype.impl.TypeDeserializerBase._findDeserializer(TypeDeserializerBase.java:179)",
"com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:108)",
"com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:93)",
"com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserializeWithType(AbstractDeserializer.java:131)",
"com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:518)",
"com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeSetAndReturn(MethodProperty.java:107)",
"com.fasterxml.jackson.databind.deser.BuilderBasedDeserializer.vanillaDeserialize(BuilderBasedDeserializer.java:255)",
"com.fasterxml.jackson.databind.deser.BuilderBasedDeserializer.deserialize(BuilderBasedDeserializer.java:145)",
"com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3736)",
"com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2726)",
"com.amazon.ask.util.JacksonSerializer.deserialize(JacksonSerializer.java:69)",
"com.andrewtech.alexaskills.MagicDiceHandler.handleRequest(MagicDiceHandler.java:33)",
"sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)",
"sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)",
"sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)",
"java.lang.reflect.Method.invoke(Method.java:498)"
]
}
Its weird that my java code errors, but my test returns this...
https://gyazo.com/975bd574e090be351c53cb7d65a89d84
{"version":"1.0","userAgent":"ask-java/2.5.5 Java/1.8.0_181","response":{"outputSpeech":{"type":"SSML","ssml":"<speak>Number is 10</speak>"}}}
I can't seem to find out why the error is happening. Should be an error when Im compiling, but I cant seem to figure out exactly what... My dependencies are maven based if that helps.
My code: https://github.com/Realmm/MagicDiceGitHub/tree/master/MagicDice
Nevermind, turns out the error wasnt actually happening at all... lol. I just didnt press X on the red box when it initially came up before I fixed it, making me think it was coming up each time I submitted a new jar file
I'm building a game in LibGDX and have began adding visual aspects of the game such as the logo. Considering that I've been using the default libgdxXXX.png files as placeholders for my logo, and that I'm replacing them with my logo, I didn't feel it had any more purpose in my program. I decide to delete it; but it decide to not compile and come up with this error:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: assets/libgdx128.png
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:148)
at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.setupDisplay(LwjglGraphics.java:196)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:142)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:124)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: assets/libgdx128.png (Internal)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:222)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:145)
... 3 more
Somehow, when I return the files from the Trash (I use Linux), it works again! I have checked my code and found nothing I wrote referred to those files. When I deleted the files 1 by 1, the error changes from libgdx128.png to libgdx64.png to libgdx32.png to libgdx16.png respectively. I have changed all the references from libgdx128.png to my logo.png in my code; yet when I try to delete the libgdx logo and run my program, it fails to compile! Any ideas?
I found out my problem. I forgot all about this code at DesktopLauncher.java:
for (int size : new int[] { 128, 64, 32, 16 }) {
configuration.addIcon("assets/libgdx" + size + ".png", FileType.Internal);
}
I did not know it was referencing to the files I have deleted. The configuration.addIcon(); was the code setting the program icon - similar to how a favicon works. I will be adding my own icon now that I know what the code does.
Hope this helps anyone else confused about the error.
I have a quite big (>2.5 GB) h2 database file. Driver version is 1.4.182. Everything worked fine but recently the DB stop to work with exception:
Błąd ogólny: "java.lang.NullPointerException"
General error: "java.lang.NullPointerException" [50000-182] HY000/50000 (Help)
org.h2.jdbc.JdbcSQLException: Błąd ogólny: "java.lang.NullPointerException"
General error: "java.lang.NullPointerException" [50000-182]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:168)
at org.h2.message.DbException.convert(DbException.java:295)
at org.h2.engine.Database.openDatabase(Database.java:297)
at org.h2.engine.Database.<init>(Database.java:260)
at org.h2.engine.Engine.openSession(Engine.java:60)
at org.h2.engine.Engine.openSession(Engine.java:167)
at org.h2.engine.Engine.createSessionAndValidate(Engine.java:145)
at org.h2.engine.Engine.createSession(Engine.java:128)
at org.h2.engine.Engine.createSession(Engine.java:26)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:347)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:108)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:92)
at org.h2.Driver.connect(Driver.java:72)
at org.h2.server.web.WebServer.getConnection(WebServer.java:750)
at org.h2.server.web.WebApp.test(WebApp.java:895)
at org.h2.server.web.WebApp.process(WebApp.java:221)
at org.h2.server.web.WebApp.processRequest(WebApp.java:170)
at org.h2.server.web.WebThread.process(WebThread.java:137)
at org.h2.server.web.WebThread.run(WebThread.java:93)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NullPointerException
at org.h2.mvstore.db.ValueDataType.compare(ValueDataType.java:102)
at org.h2.mvstore.MVMap.compare(MVMap.java:741)
at org.h2.mvstore.Page.binarySearch(Page.java:388)
at org.h2.mvstore.MVMap.put(MVMap.java:179)
at org.h2.mvstore.MVMap.put(MVMap.java:133)
at org.h2.mvstore.db.TransactionStore.rollbackTo(TransactionStore.java:491)
at org.h2.mvstore.db.TransactionStore$Transaction.rollback(TransactionStore.java:785)
at org.h2.mvstore.db.MVTableEngine$Store.initTransactions(MVTableEngine.java:223)
at org.h2.engine.Database.open(Database.java:736)
at org.h2.engine.Database.openDatabase(Database.java:266)
... 17 more
The problem occurs in my application and using H2 web frontend.
I have tried solution from similar question but I cannot downgrade H2 to 1.3.x as it cannot read 1.4.x DB files.
My questions are:
How to handle it? Is it to possible to make it work again? I have tried downgrade H2 to 1.4.177 but it didn't help.
Is there any way to at least recover data to other format? I could use other DB (Sqlite, etc.) however I would need a way to get to these data.
EDIT: updated stacktrace
EDIT 2: Result of using Recovery tool:
$ java -cp h2-1.4.182.jar org.h2.tools.Recover
Exception in thread "main" java.lang.IllegalStateException: Unknown tag 50 [1.4.182/6]
at org.h2.mvstore.DataUtils.newIllegalStateException(DataUtils.java:762)
at org.h2.mvstore.type.ObjectDataType.read(ObjectDataType.java:222)
at org.h2.mvstore.db.TransactionStore$ArrayType.read(TransactionStore.java:1792)
at org.h2.mvstore.db.TransactionStore$ArrayType.read(TransactionStore.java:1759)
at org.h2.mvstore.Page.read(Page.java:843)
at org.h2.mvstore.Page.read(Page.java:230)
at org.h2.mvstore.MVStore.readPage(MVStore.java:1813)
at org.h2.mvstore.MVMap.readPage(MVMap.java:769)
at org.h2.mvstore.Page.getChildPage(Page.java:252)
at org.h2.mvstore.MVMap.getFirstLast(MVMap.java:351)
at org.h2.mvstore.MVMap.firstKey(MVMap.java:218)
at org.h2.mvstore.db.TransactionStore.init(TransactionStore.java:169)
at org.h2.mvstore.db.TransactionStore.<init>(TransactionStore.java:117)
at org.h2.mvstore.db.TransactionStore.<init>(TransactionStore.java:81)
at org.h2.tools.Recover.dumpMVStoreFile(Recover.java:593)
at org.h2.tools.Recover.process(Recover.java:331)
at org.h2.tools.Recover.runTool(Recover.java:192)
at org.h2.tools.Recover.main(Recover.java:155)
I also noticed that two another files (.txt and .sql) has been created but they don't seem to contain a data.
I got the same situation last week with JIRA database, it took me few hours to do google regarding to this problem however, there are no answers which can resolve the situation.
I decided to take a look at H2 source code and I can recover the whole database with very simple code. I may not understand whole picture about the situation e.g. root cause, in which condition it happened, etc.
However, the cause is: when you connect to h2 file then H2 engine will look into auditLog and rollback the in-progress transactions, there are some data which have unknown type (id is 17) and H2 fails to rollback due to exception during recognize the type (id 17).
My code is simple, add h2 lib into your build path then just manual connect to file and clear auditLog because I think it is just the log and will not have big impact (someone may correct me).
Hopefully, you can resolve your problem as well.
public static void main(final String[] args) {
// open the store (in-memory if fileName is null)
final MVStore store = MVStore.open("C:\\temp\\h2db.mv.db");
final MVMap<Object, Object> openMap = store.openMap("undoLog");
openMap.clear();
// close the store (this will persist changes)
store.close();
}
Another solution for this problem:
Go to your home folder (~ in linux).
Move all files named [*.mv.db] to a backup with a different name. For example: mv xyz.mv.db xyz.mv.db.backup
Restart your database.
This seems to clear out MVStore meta-data used for H2 undo features, and resolves the NPE from the MV Store compare.
I had a similar problem:
[HY000][50000] Allgemeiner Fehler: "java.lang.NullPointerException"
General error: "java.lang.NullPointerException" [50000-176]
java.lang.NullPointerException
I tried to connect with IntelliJ to H2 file DB. H2 driver version was 1.3.176 but the DB file version had 1.3.161. So downgraded the driver to 1.3.161 in IntelliJ solved the problem completely.