'Camel3-Blueprint-Testing fails with error 'Caused by: java.lang.IllegalStateException: zip file closed'

Im trying to implement JUnit-Test with Camel-Blueprints. I used Camel-Blueprint-Testing with Camel2 before without major issues, but with Camel3 it simple dont work and throws strange Errors. I created a simple Sample-Project: https://github.com/CrEaK/camel3-blueprint-testing As you can see the Project is quiet simple. Im using Java8. When I start Class CamelBlueprintTest as Testrun i get the following output: https://gist.github.com/CrEaK/7b323c2d6e76cf06719b3eaa05523e29

The last error with 'Caused by: java.lang.IllegalStateException: zip file closed' is very strange.

Has anyone any idea why this failes so badly?

Thanks!



Solution 1:[1]

You could try moving your blueprint file to standard location for OSGi blueprints which is resources/OSGI-INF/blueprint then using the following getBlueprintDescriptor with CamelBlueprintTestSupport. The issue could be that your blueprints/test.xml is missing path-separator at the begining of the string.

@Override
protected String getBlueprintDescriptor() {
    return "/OSGI-INF/blueprint/test.xml";
}

Looked at your sample Sample-project and noticed that it is missing maven-bundle-plugin and packaging isn't set to bundle which can cause issues. I generally recommend people to use the available archetypes for OSGi/Karaf blueprint projects.

You can also look apache camel github repository for "examples" like this test shows how to setup CamelBlueprintTest.

The exception org.osgi.framework.BundleException: Unable to start bundle with CamelTestSupport usually means that there's something wrong with how blueprint or test has been setup. For me this is usually caused by returning incorrect config pid from useOverridePropertiesWithConfigAdmin or incorrect path with getBlueprintDescriptor. Jars are basically archives so the cryptic Caused by: java.lang.IllegalStateException: zip file closed exception is probably related to failure to find the blueprint.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pasi Österman