I am having trouble figuring out why an EJB session bean is not working. The actual error message is an EJBException: NameNotFoundException, but that is not a very illuminating message.
I have traced it down to a exactly what line causes the problem, but have not figure out why. So, I wanted to create a session bean to keep track of the input values from a form.
A slimmed down version of the code is:
public class rrpInputField {
public boolean isRequired;
public int maxLength;
public String inputValue;
public String displayValue;
public String formatMask;
public rrpInputField() {
isRequired = false;
maxLength = 64;
inputValue = "";
displayValue = "";
formatMask = "";
}
}
I then created a interface dohicky...
@Local
public interface Test1 {
public void setAction(String action);
public String getAction();
public void setName(String name);
public String getName();
}
Then I created the test bean itself...
@Stateful
public class Test1Bean implements Test1 {
private String action;
private rrpInputField name;
@PostConstruct
public void initialize() {
action = "initalValue";
//name.currentValue = "TestValue";
@Override
public void setAction(String action){ this.action = action; }
@Override
public void getAction() { return this.action; }
@Override
public void setName(String name) { this.name.currentValue = name; }
@Override
public String getName() { return this.name.currentValue; }
}
In my test servlet I have
@EJB
private Test1 t1;
If I un-comment the one line in the bean initialize method in the bean definition I get the failure. So I know it has something to do with that. //name.currentValue = "TestValue";
If I leave it commented out, as soon as I code t1.getName("New Value") in the servlet I'll get the same error.
If I leave it commented it out, then the bean works as anticipated - I can initialize, and use setAction and getAction just fine.
I am fairly sure the rrpInput class is correct, because I can code in the servlet:
rrpInputField f1 = new rrpInputField();
f1.currentValue = "TestValue";
I figure it must have something to do with my input field class, but I have had no luck figuring out what.