You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Subhanjan <su...@gmail.com> on 2012/04/17 09:32:09 UTC

Null Pointer Exception and servicemix-karaf problems

Hi,
   I am very new to Apache-camel. Hence, plz pardon me if I ask very basic
things. I am using this for converting csv files to xml file while creating
the camel flow for file transfer.

My code for RouteBuilder is:

/package foo;

import org.apache.camel.LoggingLevel;

import org.apache.camel.builder.RouteBuilder;

import org.apache.camel.dataformat.xstream.XStreamDataFormat;
import org.apache.camel.spring.Main;

import com.thoughtworks.xstream.XStream;

public class MyRouteBuilder extends RouteBuilder {

		public static void main(String[] args) throws Exception {
		Main.main(args);
	}

		public void configure() {

				XStream xstream = new XStream();

		XStreamDataFormat xStreamDataFormat = new XStreamDataFormat();

		xStreamDataFormat.setXStream(xstream);

		System.out.println("hi");
		from("file://D:/deploy/csv?fileName=Book1.csv&noop=true")
				.unmarshal()
				.csv()
				.log(LoggingLevel.INFO, "unmarshall")
				.process(new CsvToXMLProcessor())
				.log(LoggingLevel.INFO, "after processing")
				.marshal(xStreamDataFormat)
				.log(LoggingLevel.INFO, "after marshalling")
				.to("file:target/csvoutput?fileName=test.xml");

			}
}/
My CsvToXMLProcessor class is:

/package foo;

import java.util.Iterator;
import java.util.List;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;

public class CsvToXMLProcessor implements Processor {

	@Override
	public void process(Exchange exchange) throws Exception {
				
		List<List&lt;String>> list = (List<List&lt;String>>)
exchange.getIn().getBody(List.class);
		
                          for (Iterator<List&lt;String>> it =
list.iterator(); it.hasNext();) { 
                // Split the content of the message into field 
        	List<String>  message = it.next(); 
                System.out.println(message);
                } 		
	}
         }  /       		

	
My question is - 1) whenever I try to run it from main() by 'run as' option,
it is creating output folder "csvoutput" & inside the desired xml - Fine!!!

But, when I try to run 2nd time, it should overwrite the target file. But
instead it is showing Null Pointer Exception like this:

/Exception in thread "main"
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected
exception parsing XML document from file
[D:\workspace\FirstProject\target\classes\META-INF\spring\camel-context.xml];
nested exception is java.lang.NullPointerException
	at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
	at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
	at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
	at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
	at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
	at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
	at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
	at
org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:126)
	at
org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:92)
	at
org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
	at
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)
	at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)
	at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
	at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
	at
org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:185)
	at org.apache.camel.spring.Main.doStart(Main.java:139)
	at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
	at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
	at org.apache.camel.impl.MainSupport.run(MainSupport.java:136)
	at org.apache.camel.impl.MainSupport.run(MainSupport.java:322)
	at org.apache.camel.spring.Main.main(Main.java:72)
	at foo.MyRouteBuilder.main(MyRouteBuilder.java:39) --->* this is pointing
to Main.main(args) in the code*Caused by: java.lang.NullPointerException
	at
com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.checkOverrideProperties(Unknown
Source)
	at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.<init>(Unknown
Source)
	at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getOrCreate(Unknown
Source)
	at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getOrCreate(Unknown
Source)
	at
com.sun.xml.internal.bind.v2.runtime.property.ArrayReferenceNodeProperty.<init>(Unknown
Source)

& so on.........../

Any idea what is my mistake here???


Also, I forgot to mention another porblem

2) when I try to deploy this Fuse Project from servicemix-karaf command
prompt by giving prompt as "features:install FirstProject" (FirstProject is
the features-bundle name)

it is reading the files & showing the message as I wrote in Processor class,
but it is not producing any output file.
it is like this:
/karaf@root> features:install FirstProject
karaf@root> hi
[1, John, 25]
[2, Subha, 23]
[3, John, 25]
[4, xyz, 23]/

Then the cursor is blinking. 

Hence, I want to know anyone can help this? How to solve this 2 problems?

Please make me out of this misery.. I am stuck for this since 2 days!!!




--
View this message in context: http://camel.465427.n5.nabble.com/Null-Pointer-Exception-and-servicemix-karaf-problems-tp5645869p5645869.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Null Pointer Exception and servicemix-karaf problems

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You could also try the new release
Fuse ESB 4.4.1-fuse-03-06, March 08, 2012



On Tue, Apr 17, 2012 at 12:59 PM, Subhanjan <su...@gmail.com> wrote:
> I am using *jdk 1.6.0_23
>
> camel 2.7.3-fuse-00-53
>
> servicemix 4.4.1-fuse-02-05*
>
>
> I have just restarted servicemix after refreshing the log
> & when I again run the program from main mathod by 'run as' (which I should
> not.. I have to use Servicemix for running this) the NPE problem seems to
> have gone for some time & for sometime it is appearing again
>
> So I am leaving it & I am editing the NPE portion
>
> So my main problem is the 2 nd problem Why is it not running through
> servicemix?
>
> I watched the  servicemix log closely
>
> There it is perfectly shown the Log info upto "after marshalling"
>
> That means it is perfectly fine running in servicemix also.. except the
> desired output file is not generating!!!
>
>
> Hence, I want to know - since trying through main method gives perfect
> solution & noticing servicemix log, it is also giving the same,(that means
> from client machine, it is not a problem but from server side, somehow
> output is not generating) I am curious- is there anything I have to do on
> servicemix (example config properties change etc) to produce output xml file
> ??
>
>
> can Anybody give me a light upon this??
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Null-Pointer-Exception-and-servicemix-karaf-problems-tp5645869p5646282.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Null Pointer Exception and servicemix-karaf problems

Posted by Subhanjan <su...@gmail.com>.
I am using *jdk 1.6.0_23

camel 2.7.3-fuse-00-53

servicemix 4.4.1-fuse-02-05*


I have just restarted servicemix after refreshing the log
& when I again run the program from main mathod by 'run as' (which I should
not.. I have to use Servicemix for running this) the NPE problem seems to
have gone for some time & for sometime it is appearing again

So I am leaving it & I am editing the NPE portion

So my main problem is the 2 nd problem Why is it not running through
servicemix?

I watched the  servicemix log closely

There it is perfectly shown the Log info upto "after marshalling"

That means it is perfectly fine running in servicemix also.. except the
desired output file is not generating!!!


Hence, I want to know - since trying through main method gives perfect
solution & noticing servicemix log, it is also giving the same,(that means
from client machine, it is not a problem but from server side, somehow
output is not generating) I am curious- is there anything I have to do on
servicemix (example config properties change etc) to produce output xml file
??


can Anybody give me a light upon this??

--
View this message in context: http://camel.465427.n5.nabble.com/Null-Pointer-Exception-and-servicemix-karaf-problems-tp5645869p5646282.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Null Pointer Exception and servicemix-karaf problems

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

What JDK, Camel and Karaf versions are you using?
The NPE may be an issue on JDK1.7 i think.




On Tue, Apr 17, 2012 at 9:32 AM, Subhanjan <su...@gmail.com> wrote:
> Hi,
>   I am very new to Apache-camel. Hence, plz pardon me if I ask very basic
> things. I am using this for converting csv files to xml file while creating
> the camel flow for file transfer.
>
> My code for RouteBuilder is:
>
> /package foo;
>
> import org.apache.camel.LoggingLevel;
>
> import org.apache.camel.builder.RouteBuilder;
>
> import org.apache.camel.dataformat.xstream.XStreamDataFormat;
> import org.apache.camel.spring.Main;
>
> import com.thoughtworks.xstream.XStream;
>
> public class MyRouteBuilder extends RouteBuilder {
>
>                public static void main(String[] args) throws Exception {
>                Main.main(args);
>        }
>
>                public void configure() {
>
>                                XStream xstream = new XStream();
>
>                XStreamDataFormat xStreamDataFormat = new XStreamDataFormat();
>
>                xStreamDataFormat.setXStream(xstream);
>
>                System.out.println("hi");
>                from("file://D:/deploy/csv?fileName=Book1.csv&noop=true")
>                                .unmarshal()
>                                .csv()
>                                .log(LoggingLevel.INFO, "unmarshall")
>                                .process(new CsvToXMLProcessor())
>                                .log(LoggingLevel.INFO, "after processing")
>                                .marshal(xStreamDataFormat)
>                                .log(LoggingLevel.INFO, "after marshalling")
>                                .to("file:target/csvoutput?fileName=test.xml");
>
>                        }
> }/
> My CsvToXMLProcessor class is:
>
> /package foo;
>
> import java.util.Iterator;
> import java.util.List;
>
> import org.apache.camel.Exchange;
> import org.apache.camel.Processor;
>
> public class CsvToXMLProcessor implements Processor {
>
>        @Override
>        public void process(Exchange exchange) throws Exception {
>
>                List<List&lt;String>> list = (List<List&lt;String>>)
> exchange.getIn().getBody(List.class);
>
>                          for (Iterator<List&lt;String>> it =
> list.iterator(); it.hasNext();) {
>                // Split the content of the message into field
>                List<String>  message = it.next();
>                System.out.println(message);
>                }
>        }
>         }  /
>
>
> My question is - 1) whenever I try to run it from main() by 'run as' option,
> it is creating output folder "csvoutput" & inside the desired xml - Fine!!!
>
> But, when I try to run 2nd time, it should overwrite the target file. But
> instead it is showing Null Pointer Exception like this:
>
> /Exception in thread "main"
> org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected
> exception parsing XML document from file
> [D:\workspace\FirstProject\target\classes\META-INF\spring\camel-context.xml];
> nested exception is java.lang.NullPointerException
>        at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
>        at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
>        at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
>        at
> org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
>        at
> org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
>        at
> org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
>        at
> org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
>        at
> org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:126)
>        at
> org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:92)
>        at
> org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
>        at
> org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)
>        at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)
>        at
> org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
>        at
> org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
>        at
> org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:185)
>        at org.apache.camel.spring.Main.doStart(Main.java:139)
>        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
>        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
>        at org.apache.camel.impl.MainSupport.run(MainSupport.java:136)
>        at org.apache.camel.impl.MainSupport.run(MainSupport.java:322)
>        at org.apache.camel.spring.Main.main(Main.java:72)
>        at foo.MyRouteBuilder.main(MyRouteBuilder.java:39) --->* this is pointing
> to Main.main(args) in the code*Caused by: java.lang.NullPointerException
>        at
> com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.checkOverrideProperties(Unknown
> Source)
>        at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.<init>(Unknown
> Source)
>        at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getOrCreate(Unknown
> Source)
>        at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getOrCreate(Unknown
> Source)
>        at
> com.sun.xml.internal.bind.v2.runtime.property.ArrayReferenceNodeProperty.<init>(Unknown
> Source)
>
> & so on.........../
>
> Any idea what is my mistake here???
>
>
> Also, I forgot to mention another porblem
>
> 2) when I try to deploy this Fuse Project from servicemix-karaf command
> prompt by giving prompt as "features:install FirstProject" (FirstProject is
> the features-bundle name)
>
> it is reading the files & showing the message as I wrote in Processor class,
> but it is not producing any output file.
> it is like this:
> /karaf@root> features:install FirstProject
> karaf@root> hi
> [1, John, 25]
> [2, Subha, 23]
> [3, John, 25]
> [4, xyz, 23]/
>
> Then the cursor is blinking.
>
> Hence, I want to know anyone can help this? How to solve this 2 problems?
>
> Please make me out of this misery.. I am stuck for this since 2 days!!!
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Null-Pointer-Exception-and-servicemix-karaf-problems-tp5645869p5645869.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/