i am using jsf2.0 as MVC framework and Spring just for Dependency Injection. i made it work but there is little problem when Spring Creating bean. Means on My JSFBean (ManagedBean) i have to use @Component Annotation of Spring otherwise i am not able to make it work. and because of that when my ManagedBean have some code in Constructor Spring is throwing Exception. It is working Perfect without Constructor CODE. Please comment if you need anything else.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myBean' defined in file [C:\Documents and Settings\KshiS\My Documents\NetBeansProjects\Sp_Js_1\build\web\WEB-INF\classes\com\ksh\excel\MyBean.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.ksh.excel.MyBean]: Constructor threw exception; nested exception is java.lang.NullPointerException
My JSF Bean code is
package com.ksh.excel;
import java.util.ArrayList;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.springframework.beans.factory.annotation.Autowired;
/**
*
* @author KshiS
*/
@ManagedBean
@ViewScoped
public class MyBean {
@Autowired
private Userdao userdao;
ArrayList<String> arrayList = new ArrayList<String>();
public MyBean()
{
Object object = FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("Userid");
if(object != null)
{
arrayList.add("Session Value");
}
else
{
arrayList.add("Temp Value");
}
}
public void print()
{
System.out.println(userdao.print());
}
}
How to Resolve it. ? OR Is there any possibility to Make it work without @Component Annotation on ManagedBean. ?
One More Important Question that I dont want use Spring As DI rather then i want use J2EE6 Dependency Injection. But also there is One problem That i have to use pure j2EE server like glassFish or JBOSS. Is it possible to use it in Tomcat. ? i know tomcat is not pure j2ee Server But i just want to use DI.