The best place to *find* answers to programming/development questions, imo, however it's the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but again, a great reference for *finding* answers.

My Music (Nickleus)

20131107

[SOLVED] JSF SessionScoped: com.sun.faces.mgbean.ManagedBeanCreationException: Cant instantiate class

when trying to view a jsf page, i got the following error in the browser:
http 500 error:
com.sun.faces.mgbean.ManagedBeanCreationException: Cant instantiate class: com.test.userUsersDataBean



and this was in the console:
11:23:07,407 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/].[facesServlet]] (http-localhost/127.0.0.1:8080-3) JBWEB000236: Servlet.service() for servlet facesServlet threw exception: java.lang.NullPointerException
    at com.test.userUsersDataBean.setUserAndMemberOnBackingBean(UsersDataBean.java:97) [:]
    at com.test.userUsersDataBean.<init>(UsersDataBean.java:109) [:]
...



here's the code for UsersDataBean.java, line 97:
user = userMenuBean.getUser();

userMenuBean was apparently null. eventually i found out that the problem was this, in UserMenuBean.java:
@javax.enterprise.context.SessionScoped


when i changed it to this, it worked:
@javax.faces.bean.SessionScoped;


UPDATE

i just got a similar Cant instantiate class error when i migrated some validator classes from faces-config.xml to using annotations. the solution was just to rebuild/recompile the project, then "Clean" the server (servers > right click on my jboss server instance > clean), then restart the server.

No comments:

Post a Comment