This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NullPointerException when loading properties from XML in a managed bean?  RSS feed

 
Chris Kujawa
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good morning all. I ran into a problem yesterday afternoon and after a bunch of research and trying a couple of different things I'm stumped...and hope that someone may be able to provide some insight on what's going on. First, I'm using JSF ri 1.1, J2EE 1.4 and Java 5 in a Weblogic app server to build/run my web app. I need to access some config data for and sftp client helper I wrote and found that I was accessing this repeatedly, so decided to move the config info into an application scoped managed bean. I got all that set up, but for some reason I'm getting NullPointerExceptions when I try to access my properties file. The code I'm currently using in my bean constructor looks like:



The exception is thrown at props.loadFromXML. I realise this is verbose btw...I changed from



just to see if I could get any more information on what is happening, but I still get the same exception message/stack trace (the message is simply 'null'):

<java.lang.NullPointerException>
<at com.fairpoint.util.SftpConfigBean.<init>(SftpConfigBean.java:47)>
<at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)>
<at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)>
<at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)>
<at java.lang.reflect.Constructor.newInstance(Constructor.java:494)>
<at java.lang.Class.newInstance0(Class.java:350)>
<at java.lang.Class.newInstance(Class.java:303)>
<at java.beans.Beans.instantiate(Beans.java:204)>
<at java.beans.Beans.instantiate(Beans.java:48)>
<at com.sun.faces.config.ManagedBeanFactory.newInstance(ManagedBeanFactory.java:203)>
<at com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:256)>
<at com.sun.faces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:78)>
<at results.index.getFileNames(index.java:164)>
<at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)>
<at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)>
<at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)>


Any thoughts/advice would be greatly appreciated!
[ June 03, 2008: Message edited by: Chris Kujawa ]
 
Darryl Nortje
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howzit Chris...

Let's say i put these 2 lines in any class and run it. What would happen?

Properties props = null;
props.loadFromXML( someInputStream );
 
Chris Kujawa
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ooff....javascript: x()banghead I'm embarrassed. Thanks Darryl...I can't believe I didn't catch that myself...
 
Darryl Nortje
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
;-)

no worries... Good luck with the rest. It happens to me all the time.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!