Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » Nullpointer in JarCreator when running Unittests
Nullpointer in JarCreator when running Unittests [message #1494169] Mon, 01 December 2014 08:31 Go to next message
Andreas Schilling is currently offline Andreas SchillingFriend
Messages: 25
Registered: April 2010
Junior Member
Hi everyone!

We migrated our Spring DM application to gemini blueprint. The migration itself was pretty smooth and everything's fine, however we have a hard time getting our unit tests to run again.
We're getting this NPE upon test context initialization:
Caused by: java.lang.NullPointerException
	at org.eclipse.gemini.blueprint.test.internal.util.jar.JarCreator.determineRootPath(JarCreator.java:73)
	at org.eclipse.gemini.blueprint.test.internal.util.jar.JarCreator.<init>(JarCreator.java:59)
	at org.eclipse.gemini.blueprint.test.AbstractOnTheFlyBundleCreatorTests$1.run(AbstractOnTheFlyBundleCreatorTests.java:100)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.gemini.blueprint.test.AbstractOnTheFlyBundleCreatorTests.initializeJarCreator(AbstractOnTheFlyBundleCreatorTests.java:97)
	at org.eclipse.gemini.blueprint.test.AbstractOnTheFlyBundleCreatorTests.<init>(AbstractOnTheFlyBundleCreatorTests.java:88)
	at org.eclipse.gemini.blueprint.test.AbstractConfigurableBundleCreatorTests.<init>(AbstractConfigurableBundleCreatorTests.java:91)


The line where this happens is the following:
return Thread.currentThread().getContextClassLoader().getResource(".").toString();


The getResource() call returns null. What we noticed is, that the code is executed multiple times, from multiple classloaders. The one that fails is the BundleDelegatingClassLoader for the on-the-fly created test bundle.
Any help is appreciated, maybe we're just missing some small detail here wich is obvious to someone else Smile

kind regards,

Andreas
Re: Nullpointer in JarCreator when running Unittests [message #1512065 is a reply to message #1494169] Mon, 15 December 2014 12:19 Go to previous messageGo to next message
Andreas Schilling is currently offline Andreas SchillingFriend
Messages: 25
Registered: April 2010
Junior Member
Hmm, anyone?
We also noticed, that in earlier versions (that is, Spring DM times...) the code for determineRootPath() looked pretty different. Does anyone have an idea why it changed to the current version?
Re: Nullpointer in JarCreator when running Unittests [message #1512224 is a reply to message #1512065] Mon, 15 December 2014 15:13 Go to previous message
Andreas Schilling is currently offline Andreas SchillingFriend
Messages: 25
Registered: April 2010
Junior Member
OK, finally found the problem so let's share it:
We basically used the Spring DM integration test features (AbstractConfigurableBundleCreatorTests) wrong all the time and it just didn't show before migrating to Gemini Blueprint.
What we had was, that in the Spring configuration for the tests the test classes themselves were added as beans so that dependency injection can happen on them. We somehow totally missed back in the days, that injection works automagically when the name of the property matches the name of the bean definition.
So, the error occurred when during test execution the test class became instantiated again.
Removing the bean definition of the test classes from the Spring configuration was all that was needed (and some naming fixing so that the automatic injection worked).

Reading the test chapters in "Spring Dynamic Modules in Action" again brought us on the right path. RTFM definitely helps Smile
Previous Topic:Gemini Blueprint Extender ShutdownSorter issues
Next Topic:Problems using Gemini JPA in a Eclipse RCP application using features
Goto Forum:
  


Current Time: Tue Oct 08 13:27:16 GMT 2024

Powered by FUDForum. Page generated in 0.04123 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top