I'm having problems with Rebirth...

I’m currently using the Rebirth library, and I’m getting the following error message.

Exception in thread “main” java.lang.NullPointerException
at nordgren.silas.happyisles.HappyIsles.init(HappyIsles.java:35)
at nordgren.silas.happyisles.HappyIsles.main(HappyIsles.java:51)

The code is as follows:


public static ResourceHandle<AudioUtilities> audioUtilitiesHandle;
	public static ResourceHandle<VideoUtilities> videoUtilitiesHandle;
	public static ResourcePool resources = Resources.createPool(USER_DIRECTORY
			+ FILE_SEPARATOR + "content", DecoderGroup.CORE, true, false,
			new AudioDecoder(), new VideoDecoder());


resources.parse("resources.xml");

		audioUtilitiesHandle = resources.forceCreate(
				AudioUtilities.class, "main");
		videoUtilitiesHandle = resources.forceCreate(
				VideoUtilities.class, "main");

		audioUtilities = audioUtilitiesHandle.get(); //I get a nullpointer exception here, I believe it is because audioUtilitiesHandle is null.
		videoUtilities = videoUtilitiesHandle.get();

Thank you for your time assisting this initiate to Rebirth.

ReBirth, get over here…the library is named after you ;D

It’s wierd because I’ve never got errors with Rebirth before, and I’ve done the same thing on other projects with no problems. Here are the XML files in case there’s anything wrong with them.

Resources.xml


<resources>
	<include path="resources/AudioUtilities.xml" />
	<include path="resources/VideoUtilities.xml" />
</resources>

resources/AudioUtilities.xml


<resources>
	<map name="AudioUtilities" class="nordgren.silas.happyisles.utilities.AudioUtilities" />
	<AudioUtilities name="main"
	/>
</resources>

resources/VideoUtilities.xml


<resources>
	<map name="VideoUtilities" class="nordgren.silas.happyisles.utilities.VideoUtilities" />
	<VideoUtilities name="main"
	bitsPerPixel="32"
	monitorFrequency="60"
	windowHeight="600"
	windowTitle="Happy Isles"
	windowWidth="800"
	/>
</resources>

I thought someone is going to pick fight with me, oh well hides scope

I don’t know if it’s problem to let AudioUtilities’s property to empty, but do you call resources.update()? First exception appeared before VideoUtilities, so maybe it’ll suffer same problem.

Thank you! The error was gone when I commented out the AudioUtilities loading part. Currently it’s just a placeholder for the variables I’m going to place there soon enough.

Resource names need to be globally unique, and you have two resources with different types both called “main”. I should probably put some code in to barf on loading if you try and reuse a name.

I generally put an extension of the type at the end of resource names (eg. “main.audioUtils” and “main.videoUtils”).

Rebirth the lib was here first. :stuck_out_tongue:

This topic is kinda funny because I’ve heard so little feedback about Rebirth (the library) that I’d kinda assumed no-one was using it other than me.

I didn’t really realize it at the time I made this topic, but the title isn’t really optimal when you have a member with the name ReBirth. Anyway, thanks for the help. Also, loving the library.

Btw could you post your AudioDecoder and VideoDecoder classes? I suspect you could do things in a cleaner way. (Also I’m just nosy how people like to use the api).

I just use the plastic solution of specifying the name of the texture or sound I want to load and then let Slick do the rest.

I guess many members were deceived.

Yeah I know ;D I already read how to use it but never really use it. Maybe because I have small amount of resources so I just type them one by one.

hahahahaha, I don’t know why, but it never clicked for me that ReBirth didnt write reberth.

Which is surprising considering I was hear when orangy tang posted it the first time.

I guess my mind is just failing on me :stuck_out_tongue: