The best place to ask programming/development questions, imo. UPDATE: stackoverflow is 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 a great reference for finding answers.

My Music (Nickleus)

20120329

WELD-000075 Normal scoped managed bean implementation class has a public field: public@ViewScoped @Named class



i was having the hardest time trying to figure out why i was getting these errors when i started my jboss 7, richfaces 4, seam 3, jsf 2 app:

Caused by: org.jboss.weld.exceptions.DefinitionException: WELD-000075 Normal scoped managed bean implementation class has a public field:  public@ViewScoped @Named class com.myApp.richfacesweb.test.Test
at org.jboss.weld.bean.ManagedBean.checkBeanImplementation(ManagedBean.java:438)
at org.jboss.weld.bean.AbstractClassBean.initialize(AbstractClassBean.java:197)
at org.jboss.weld.bean.ManagedBean.initialize(ManagedBean.java:322)
at org.jboss.weld.bootstrap.AbstractBeanDeployer.deploy(AbstractBeanDeployer.java:115)
at org.jboss.weld.bootstrap.BeanDeployment.deployBeans(BeanDeployment.java:204)
at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:344)
at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:82)
at org.jboss.as.weld.services.WeldService.start(WeldService.java:76)
15:25:34,408 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"myApp.ear\".WeldService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"myApp.ear\".WeldService: org.jboss.weld.exceptions.DefinitionException: WELD-000075 Normal scoped managed bean implementation class has a public field:  public@ViewScoped @Named class com.myApp.richfacesweb.test.Test"}}}}

then i figured that the problem was that i declared a variable public instead of private!

my bean looked like this:
package com.myApp.richfacesweb.test;
import java.io.Serializable;
import javax.faces.bean.ViewScoped;
import javax.inject.Named;
@ViewScoped
@Named(value="myTestBean")
public class Test implements Serializable {
public String submit(String param) {
   System.out.println("Submit using value " + param);
   System.out.println("myobject " + myobject);
   return null;
}
public String myobject;
public String getMyobject() {
return myobject;
}
public void setMyobject(String _myobject) {
myobject = _myobject;
System.out.println("myobject " + myobject);
}
}
 the error was this line:
public String myobject;
it should have been this:
private String myobject;

facepalm! 

it was Jan Groth's comment which led me to the solution (thanks Jan):
The motivation of WELD-000075 is technical. Access to a public field cannot be proxied. So a bean is required to be either pseudo scoped (@dependent, @singleton) or to guarantee access through public methods (which shouldn't be hard to achieve).

2 comments:

  1. {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.web.deployment.default-host./TestRich" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./TestRich: JBAS018040: Failed to start context"}}}}
    Any Solution for this Problem................

    ReplyDelete
  2. I had the same problem and the same post gave me a clue :-D

    ReplyDelete