On 2011-2-24, at 下午11:23, prossman wrote:
Hi,
I'm trying to use a camel-flatpack endpoint inside a Fuse SMX
container
(apache-servicemix-4.3.0-fuse-03-00). When triggered, the route
fails with a
NullPointerException:
15:58:43,328 | ERROR | - vm://flatpack |
DefaultErrorHandler |
rg.apache.camel.processor.Logger 248 | 72 - org.apache.camel.camel-
core -
2.4.0.fuse-02-00 | Failed delivery for exchangeId:
6b384114-ab78-4740-b0c2-b96a3254404f. Exhausted after delivery
attempt: 1
caught: java.lang.NullPointerException
java.lang.NullPointerException
at
net
.sf.flatpack.util.ParserUtils.loadConvertProperties(ParserUtils.java:
1003)[200:org.apache.servicemix.bundles.flatpack:3.1.1.3]
at
net
.sf
.flatpack
.AbstractDelimiterParser
.doDelimitedFile(AbstractDelimiterParser.java:130)
[200:org.apache.servicemix.bundles.flatpack:3.1.1.3]
at
net
.sf
.flatpack
.AbstractDelimiterParser.doParse(AbstractDelimiterParser.java:78)
[200:org.apache.servicemix.bundles.flatpack:3.1.1.3]
at
net.sf.flatpack.AbstractParser.parse(AbstractParser.java:113)
[200:org.apache.servicemix.bundles.flatpack:3.1.1.3]
at
org
.apache
.camel
.component.flatpack.FlatpackProducer.process(FlatpackProducer.java:
37)[201:org.apache.camel.camel-flatpack:2.4.0.fuse-02-00]
at
org.apache.camel.impl.converter.AsyncProcessorTypeConverter
$
ProcessorToAsyncProcessorBridge
.process(AsyncProcessorTypeConverter.java:50)
[72:org.apache.camel.camel-core:2.4.0.fuse-02-00]
...
<<
Cross-checking against the source files, it seems that the error
occurs when
Flatpack is trying to load a property file from the class path:
public static Properties loadConvertProperties() throws
IOException {
final Properties pzConvertProps = new Properties();
final URL url =
ParserUtils
.class.getClassLoader().getResource("fpconvert.properties");
pzConvertProps.load(url.openStream());
return pzConvertProps;
}
<<
A remote debug confirmed that url is null, which leads to the NPE when
loading the props.
The properties file is contained in the flatpack 3.1.1 JAR file. I
also
created a file of the same name and content in my bundle. Still, the
error
remains.
I'm relatively new to OSGi, but my suspicion is that the call to..
ParserUtils
.class.getClassLoader().getResource("fpconvert.properties");
<<
... doesn't behave as in other environments, and that the error
comes from
OSGi class loading.
Can any of you guys confirm this observation?
Is there a way to work around this issue?
Hi,
You are correct, the problem comes from that the fpconvert.properties
isn't available for flatpack bundle(this is a third party jar used by
camel-flatpack) in OSGi container.
The solution I can come up with is that create a fragment bundle
including the properties file, and attach it to flatpack bundle as
host, all resource in fragment bundle is available to the host bundle.
Fragment/host bundle is a concept in OSGi, you may need google to get
details how it works.
Freeman
Thanks,
Ciao, Philipp
--
View this message in context:
http://servicemix.396122.n5.nabble.com/camel-flatpack-in-Fuse-SMX-fails-in-ParserUtils-tp3398705p3398705.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
--
Freeman Fang
------------------------
FuseSource: http://fusesource.com
blog: http://freemanfang.blogspot.com
twitter: http://twitter.com/freemanfang
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org