gautamdudeja90 / beanio

Automatically exported from code.google.com/p/beanio
Apache License 2.0
0 stars 1 forks source link

NullPointerException at org.beanio.internal.util.Settings.loadProperties #42

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am getting the below exception when I try to deploy my application on Apache 
Karaf. Can you please help me with this issue.

BeanIO version: 2.0.1
Using BeanIO with Apache Camel

Caused by: java.lang.NullPointerException
    at org.beanio.internal.util.Settings.loadProperties(Settings.java:233)
    at org.beanio.internal.util.Settings.getInstance(Settings.java:162)
    at org.beanio.StreamFactory.newInstance(StreamFactory.java:323)
    at org.beanio.StreamFactory.newInstance(StreamFactory.java:295)
    at org.apache.camel.dataformat.beanio.BeanIODataFormat.doStart(BeanIODataFormat.java:79)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.processor.UnmarshalProcessor.doStart(UnmarshalProcessor.java:100)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
    at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.start(AsyncProcessorConverterHelper.java:92)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
    at org.apache.camel.processor.interceptor.TraceInterceptor.doStart(TraceInterceptor.java:358)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
    at org.apache.camel.processor.RedeliveryErrorHandler.doStart(RedeliveryErrorHandler.java:1049)
    at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:41)
    at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:28)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
    at org.apache.camel.processor.interceptor.DefaultChannel.doStart(DefaultChannel.java:152)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:85)
    at org.apache.camel.processor.MulticastProcessor.doStart(MulticastProcessor.java:941)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
    at org.apache.camel.processor.UnitOfWorkProcessor.doStart(UnitOfWorkProcessor.java:88)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.impl.RouteService.startChildService(RouteService.java:322)
    at org.apache.camel.impl.RouteService.warmUp(RouteService.java:151)
    at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:1941)
    at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:1869)
    at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1662)
    at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1550)
    at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1427)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1395)
    at org.apache.camel.blueprint.BlueprintCamelContext.maybeStart(BlueprintCamelContext.java:86)
    at org.apache.camel.blueprint.BlueprintCamelContext.init(BlueprintCamelContext.java:78)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_04]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_04]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_04]
    at java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_04]
    at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:225)[9:org.apache.aries.blueprint:0.3.2]
    at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:838)[9:org.apache.aries.blueprint:0.3.2]
    at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:638)[9:org.apache.aries.blueprint:0.3.2] 

Original issue reported on code.google.com by aravindi...@gmail.com on 20 Sep 2012 at 6:34

GoogleCodeExporter commented 9 years ago
Hello,

This is probably a class loader issue related to OSGi, which I have limited 
knowledge of.  But I do have one theory, please try the attached snapshot JAR 
and let me know if that fixes the issue.

Thanks,
Kevin

Original comment by kevin.s...@gmail.com on 22 Sep 2012 at 1:44

Attachments:

GoogleCodeExporter commented 9 years ago
I'm getting the same exception in an OSGi environment. I'm not using Camel; I'm 
just running some simple tests from Eclipse.

I'm importing the package org.beanio and using the public static StreamFactory 
newInstance(ClassLoader classLoader) factory method.

The root cause seems to be that BeanIO is using the client-bundle-supplied 
classloader to try to load its own resources - in this case, 
org/beanio/internal/config/beanio.properties. This fails unless the client 
bundle also imports org.beanio.internal.config.

The quick and dirty solution is to make sure all exported BeanIO packages are 
imported by the client bundle. That doesn't look like it will be an option for 
the original poster, though.

Eric

Original comment by emckenzi...@gmail.com on 22 Sep 2012 at 6:54

GoogleCodeExporter commented 9 years ago
Hi Eric,

Did you try the snapshot JAR I attached?  I changed the class loader for 
loading the default BeanIO settings file in there to use the same class loader 
that loads the Settings class (instead of the user supplied one).  I'm hoping 
that resolves it...  What OSGi environment do you use in Eclipse?  I should 
probably get one setup :)

Thanks,
Kevin

Original comment by kevin.s...@gmail.com on 23 Sep 2012 at 2:26

GoogleCodeExporter commented 9 years ago
Hi Kevin,

I tried installing the attached jar, while installing as a bundle on Karaf 
Container I am getting the following Exception. Can you please look into it.

java.lang.NumberFormatException: For input string: "2-SNAPSHOT"

With the old version I am able to install the bundle without any issues, but 
seeing the NullPointerException when I try to install my application on Karaf 
Container.

Thanks a lot for the support.

Thanks,
Aravind

Original comment by aravindi...@gmail.com on 24 Sep 2012 at 6:44

GoogleCodeExporter commented 9 years ago
Hi Aravind,

Sorry about that, I didn't release the OSGi bundle-version had to be 
".SNAPSHOT" instead of "-SNAPSHOT".  Try the attached JAR instead.

Thanks,
Kevin

Original comment by kevin.s...@gmail.com on 25 Sep 2012 at 1:52

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Kevin -

I just tried the jar from your latest post; here's the error I get:

org.beanio.BeanIOException: Failed to load stream factory implementation class 
'org.beanio.internal.DefaultStreamFactory'
    at org.beanio.StreamFactory.newInstance(StreamFactory.java:335)
    at tests.SampleExternalTest.test(SampleExternalTest.java:10)
    ...
Caused by: java.lang.ClassNotFoundException: 
org.beanio.internal.DefaultStreamFactory
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.beanio.StreamFactory.newInstance(StreamFactory.java:329)
    ...

You'll find that this is again a matter of using the client-bundle classloader.

Regarding Eclipse, I'm just using the Eclipse (3.7.2) Plug-in Development 
Environment (PDE) that comes bundled with *some* of the Eclipse download 
packages (I'm using the JEE package). I've attached a minimal test project that 
I used to produce the error above; you'll need to run it as a JUnit Plug-in 
Test to run it in the OSGi container.

Thank you,
Eric

Original comment by emckenzi...@gmail.com on 25 Sep 2012 at 7:36

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Kevin,

I just tried the latest jar and got the same error as Eric.

Thanks,
Aravind

Original comment by aravindi...@gmail.com on 25 Sep 2012 at 4:16

GoogleCodeExporter commented 9 years ago
Hi guys,

Thanks for your patience.  And the sample project was really helpful (thanks 
Eric!).

Try the attached snapshot JAR.  I think I've addressed the remaining class 
loading issues in it....

Kevin

Original comment by kevin.s...@gmail.com on 26 Sep 2012 at 3:14

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Kevin -

Just tried the latest JAR...so far, so good!

> Thanks for your patience.
Thank you for being so responsive! I'm glad the sample project was useful.

One more thought on the OSGi front: if your *.internal.* packages are really 
intended to be private, a best practice would be to exclude them from the 
Export-Package section of your MANIFEST.MF.

Thanks again!

Eric

Original comment by emckenzi...@gmail.com on 26 Sep 2012 at 8:04

GoogleCodeExporter commented 9 years ago
Hi Kevin,

I just tried the latest jar and its all working fine. Thank you for all the 
effort you put in to make this work.

As always you are so prompt and responsive. Thanks !!

Thanks,
Aravind

Original comment by aravindi...@gmail.com on 26 Sep 2012 at 6:24

GoogleCodeExporter commented 9 years ago

Original comment by kevin.s...@gmail.com on 29 Sep 2012 at 8:49