Resource not found.

classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Resource not found.

Pixelapp
Hello Jogampers:

I have a game that runs well on Windows and Mac but in Ubuntu it tells me: Nullpointer and then crashes. Which means it cannot file the image files.

This is my code snippet:

        String folder = "pixelapp/wavelogy/images/";

        fileName[count] = folder + "boat.jpg";

        pTex[count] = TextureIO.newTexture(
                                cl.getResource(fileName[count]), false, null);





END OF CODE SNIPPET.

Also, it crashes right at the end of this code presented here.

Why do I get this error? Any ideas?
Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

gouessej
Administrator
Hi

It's not an hard crash, just a NullPointerException. Where are your images? In the alpha version of TUER, as my images are in the same JAR than the rest of the game, all my paths start with "/".
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

Pixelapp
I've tried that before.

I'm also fighting the battle here :P :

http://stackoverflow.com/questions/13946767/java-web-sart-ubuntu-12-1-load-resource-image

I'm going to try TUER tomorrow, if it works, I'll gently ask you to tell me snippets of your code.

Good nights!
Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

gouessej
Administrator
I do that:
vendingMachineCoordinatesBuffer=GameIO.readGameFloatDataFile("/data/vendingMachine.data");

...

in=new DataInputStream(new BufferedInputStream(GameIO.class.getResourceAsStream(path)));
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

Pixelapp
It works on Windows (as I knew/thought) but NOT on Ubuntu.
Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

Pixelapp
In reply to this post by gouessej
Please try running (Linux):

http://wavelogy.pixelapp.co/WavelogyDesktop.jnlp

And let me know how it went?
Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

gouessej
Administrator
It works very well under Mageia Linux 2 with Oracle Java 1.7 but not with OpenJDK 1.7 update 6. The problem probably comes from your source code, don't use null as a file suffix as some texture providers may not support it and just execute a small test in order to find which path allows you to get the proper URL to load your file. N.B: this.getClass().getClassLoader() can be null, read that:
http://docs.oracle.com/javase/6/docs/api/java/lang/Class.html#getClassLoader()
Some implementations may use null to represent the bootstrap class loader
Edit.: Don't rely on the class loader, rather use getResourceAsStream. You may have to use a slightly different path to make it work.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

Pixelapp
Still doesn't work.
Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

gouessej
Administrator
Please be more accurate. I assume that getResource() or getResourceAsStream() returns null because you have to use the correct path. What doesn't work? Which path do you use?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

Pixelapp
something.class.getResource() doesn't work under Ubuntu 12.1.

Also, any path combination: "pixelapp/wavelogy/images" , "/pixelapp/wavelogy/images", "/images" or any other doesn't work either.

In short, anything suggested by me or by you doesn't work under Ubuntu 12.1.
Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

gouessej
Administrator
TUER works flawlessly under GNU Linux (including Ubuntu) so there is probably something wrong in your code.

I have looked at the structure of your JAR. Wavelogy.class.getResourceAsStream("/pixelapp/wavelogy/images") should work. Maybe try to use ClassLoader.getSystemClassLoader().

Edit.: I don't see boat.jpg, only blueboat.jpg
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

gouessej
Administrator
In reply to this post by Pixelapp
You can use Thread.currentThread().getContextClassLoader(). Do you reproduce this bug in an IDE? If you don't specify that the directory containing these images is a resource directory, some IDE (Netbeans?) may ignore it and you will always get null when calling getResource() and getResourceAsStream().
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

Pixelapp
In reply to this post by gouessej
Well, Tuer works. Now I know this is doable! We are on in this for a long ride then.

Also, I get a bug tough. Look at the top left corner. That's a bug that shows up every second when you are walking on Tuer. Every second when it shows up it doesn't disappear even if you stop walking.



I just wrote boat.jpg on this forum to make my code snippet short and readable by the way. boat.jpg doesn't exist anywhere. So don't mind boat.jpg.

Moreover, I'll try every suggestion you have said in the last two posts.
Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

gouessej
Administrator
Ok you tested the old alpha version (relying on JOGL 1.1.1a). It's strange, this "bug" occurs when your graphics card is going to die soon. Good luck with my suggestions.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

Xerxes Rånby
In reply to this post by Pixelapp
If possible take a look and check if this icedtea-web changeset fixes the issue:

http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=909
http://icedtea.classpath.org//hg/icedtea-web?cmd=changeset;node=95fc28e972ad

You need to recompile the latest icedtea-web sourcecode to test:
http://icedtea.classpath.org/wiki/IcedTea-Web

Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

gouessej
Administrator
Xerxes, can you explain why you think this bug is involved in this problem?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

Xerxes Rånby
gouessej wrote
Xerxes, can you explain why you think this bug is involved in this problem?
The JNLPClassLoader inside icedtea-web uses the IcedTea-web ResourceTracker class.
The IcedTea-web bug 909 http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=909 fixes a flaw inside the ResourceTracker addResource method, also used internally by the JNLPClassLoader.
"ResourceTracker#addResource attempts to percent-encode all URLs before loading the resource, causing links to be invalid. "

This may be the root cause why Pixelapps wavelogy JNLP code only fail using IcedTea-web and work using the Oracle closed source JNLP launcher.
Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

Xerxes Rånby
Pixelapp on my ARM ac100 laptop the jnlp loads using the latest icedtea-web 1.4pre release compiled from the latest sources. But i hit a javax.media.opengl.GLException: Not a GL2 implementation, this is expected...
Try use the GL2ES2 profile to stay compatible with OpenGL ES ARM GNU/Linux systems!

xranby@ac100-armhf:~$ /usr/local/bin/javaws WavelogyDesktop.jnlp
NvRmPrivGetChipIdStub: Could not read Tegra chip id/rev
Expected on kernels without Tegra3 support, using Tegra2
Loading GLESv2lib libGLESv2.so.2
Library for API 1 exposes function not wrapped: glPointSizePointerOES
Exception in thread "Timer-0" javax.media.opengl.GLException: Not a GL2 implementation
        at jogamp.opengl.es2.GLES2Impl.getGL2(GLES2Impl.java:4905)
        at pixelapp.wavelogy.Wavelogy.init(Wavelogy.java:6152)


If you still get into trouble loading resources using the latest icedtea-web file a bugreport on the icedtea-web bugzilla.
http://icedtea.classpath.org/bugzilla 
Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

gouessej
Administrator
In reply to this post by Xerxes Rånby
You're right Xerxes but as TUER works, it means that this bug doesn't affect very simple URLs, it can be used as a workaround.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Resource not found.

Pixelapp
Ok, so for productivity's sake. I'll wait for the next iced-tea to be released. Afterwards, I'll launch my program, if it doesn't work I'll file a bug.

So, for now, everyone take a brake.

And thanks for all the help.
12