In my managedBean, fileUpload : Am calling other beans using @ManagedProperty as shown in code, now later in my class i have something like rtParser.getQuote() but it throws NullPointerException, my question is:
How can I initialize rtParser in this class?
@ManagedProperty(value = "#{rtParser}")
private PositionParserRT rtParser;
public PositionParserRT getRtParser()
{
return rtParser;
}
public void setrtParser(PositionParserRT rtParser)
{
this.rtParser = rtParser;
}
Updated
I am having similar kind of issue here and would highly appreciate any suggestions.
The way as you use
@ManagedPropertyexpects thePositionParserRTto be a@ManagedBeantoo. So put that annotation on the class.But if that class is already not a JSF managed bean in the first place (i.e. it has nothing do to with JSF views/models), then you’re probably looking for the solution in the wrong direction. If it’s a business service, rather make it a
@StatelessEJB and inject it by@EJBinstead.with