Fresh maven generated playn 1.9 can't load background PNG in eclipse

38 views
Skip to first unread message

jame...@gmail.com

unread,
Oct 25, 2015, 1:21:06 AM10/25/15
to PlayN
I've been trying to setup Playn 1.9, and I've came across this issue: A freshly generated playn is not showing the bg.png, instead a black background with the words ERROR is shown. The console shows the following:
Could not load image: images/bg.png [error=javax.imageio.IIOException: Can't read input file!] 
I've regenerated the project a few times, cleaned cache for maven and tried changing the file name. Even though these methods didn't work, I did come across changing the "assets().getImage("images/bg.png");" into "assets().getRemoteImage("<Remote Image Url>");" which did work. Is it something I forgot to add to the classpath?

Andres Martinez Quijano

unread,
Oct 26, 2015, 8:16:11 AM10/26/15
to pl...@googlegroups.com
This exact same thing happened to me last week, funny thing is I
solved it, but I don't know how.

What I did:
imported the project in Eclipse in Linux, ran it and it didn't show the image
afterwards I imported it in Eclipse on a mac (import existing maven
project), ran it and it worked (how? don't know)
made some changes to the project, commited to git
went back to Linux, git pull, refresh and it worked here

my guess is that I was missing some mvn clean / mvn package or
somthing that placed the image in the target folder, but it's just a
guess
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "PlayN" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to playn+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Yiyao Yu

unread,
Oct 28, 2015, 4:00:00 PM10/28/15
to PlayN
Well, I haven't tried moving it to a mac yet. (Since I only got windows and linux) But what I've learned is that this issue is not version specific. Just tried with 2.0-rc2 and it still exists. Also tried to import the project into Netbeans but other issues popped up. Gonna try moving it into linux tonight.

Andres Martinez Quijano

unread,
Oct 28, 2015, 4:26:06 PM10/28/15
to pl...@googlegroups.com
did you try running $ mvn test -Pjava on the project?

Yiyao Yu

unread,
Oct 29, 2015, 12:14:04 AM10/29/15
to PlayN
Still the same bug, wonder if I could try to get a full stacktrace.

Michael Bayne

unread,
Oct 29, 2015, 11:13:08 AM10/29/15
to pl...@googlegroups.com

On Sat, Oct 24, 2015 at 10:21 PM, <jame...@gmail.com> wrote:
I've been trying to setup Playn 1.9, and I've came across this issue: A freshly generated playn is not showing the bg.png, instead a black background with the words ERROR is shown. The console shows the following:

Can you describe the exact steps you took on the command line to cause this problem? I've done the following on both Mac and Linux and it works fine:

% mvn archetype:generate -DarchetypeGroupId=com.googlecode.playn -DarchetypeArtifactId=playn-archetype -DarchetypeVersion=1.9 -DgroupId=com.test -DartifactId=example -Dversion=1.0-SNAPSHOT -DJavaGameClassName=Example -Dpackage=example

(then type 'y' when it asks to confirm)

% cd example
% mvn test -Pjava

Then I see a window with the background image.

Also, out of curiosity, why are you setting up a new project with PlayN 1.9 instead of PlayN 2.0-rc3?


Michael Bayne

unread,
Oct 29, 2015, 11:15:47 AM10/29/15
to pl...@googlegroups.com
On Thu, Oct 29, 2015 at 8:13 AM, Michael Bayne <m...@samskivert.com> wrote:
Also, out of curiosity, why are you setting up a new project with PlayN 1.9 instead of PlayN 2.0-rc3?

FWIW, generating the project with the 2.0-rc3 archetype also worked fine:

mvn archetype:generate -DarchetypeGroupId=io.playn -DarchetypeArtifactId=playn-archetype -DarchetypeVersion=2.0-rc3 -DgroupId=com.test -DartifactId=example -Dversion=1.0-SNAPSHOT -DJavaGameClassName=Example -Dpackage=example

I'll see if I can try all this on a Windows machine. Maybe it's a Windows problem.

Andres Martinez Quijano

unread,
Oct 29, 2015, 11:17:12 AM10/29/15
to pl...@googlegroups.com
In my particular case it failed on Linux but from Eclipse, then I ran
it from command line with mvn and it worked, and then kept working on
Eclipse ever since. I'm guessing Eclipse was missing the assets file
in a target folder or something like it

Yiyao Yu

unread,
Oct 29, 2015, 3:32:04 PM10/29/15
to PlayN
Just a quick update on the details.
After tweaking with the playn-core.jar, I finally got it to spit out a stacktrace. Seems to be something with the buffered image http://pastebin.com/ZesZmztu
I wasn't using 2.0 because it doesn't show the error when failing to load the image. I'll try rc3 later

Yiyao Yu

unread,
Oct 29, 2015, 4:07:52 PM10/29/15
to PlayN
Funny, after almost two weeks of desperate trying, example project actually worked...
No idea why creating a project called example would work, I'm pretty sure I've tried to change the name to something else before. Might be something cached that was refreshed when I replaced the original playn-core.jar
I'll see if I could find out what the problem was, thanks guys for the help

Yiyao Yu

unread,
Oct 29, 2015, 5:26:46 PM10/29/15
to PlayN
Final Update:

Found the issue, there were spaces inside the folder the project was generated. I did some tests and found the assets api unusable with directories with spaces. Issue solved.

Michael Bayne

unread,
Oct 29, 2015, 9:17:49 PM10/29/15
to pl...@googlegroups.com
Ah, I'll try that out and see if there's anything I can do to prevent that from causing problems. If not I can at least issue a warning.

-- m...@samskivert.com
Reply all
Reply to author
Forward
0 new messages