03-29-2012 12:52 PM
I'm getting a null pointer for the stack value in the PushBESState method. See below
Background:
I'm attempting to implement a stack which will be available during a long running SEAM conversation. I want to be able to backtrack through the lifecycle states of a document and I'm using the stack to store the previous N states as Strings. The document moves through the lifecycle states and reveals, in the edit view, properties for editing based on the lifecycle state.
I've built a simple push and pop automation operations which load and are called correctly. The backing bean was generated using the IDE as a SEAM service bean. I changed the Scope in that bean from event to CONVERSATION.
The Stack itself is a standard Java stack extended to change the name only.
I get an null pointer error on the stack reference when I try a PUSH a string onto this custom stack. I am injecting a reference to the stack into the push and pop automation operation classes . It seems the SEAM backing bean is not being initialized.
Here is the backing bean code and the push and pop classes: The two log messages are never printed in the backing bean, the Push log message getting the previous state from the Document Model prints.
@Name("bESStateStack") @Scope(ScopeType.CONVERSATION) public class BESStateStackBean implements Serializable {
private static final long serialVersionUID = 1L;
protected BESStateStack<String> bESStateStack;
private static final Log log = LogFactory.getLog(BESStateStackBean.class);
@Unwrap
public BESStateStack<String> getService() throws Exception {
log.warn("Getting Service BESStateStackBean");
if (bESStateStack == null) {
log.warn ("Creating BESStateStackBean");
bESStateStack = Framework.getService(BESStateStack.class);
}
return bESStateStack;
}
public BESStateStack<String> getbESStateStack() {
return bESStateStack;
}
public void setbESStateStack(BESStateStack<String> bESStateStack) {
this.bESStateStack = bESStateStack;
}
}
@Operation(id=PopBESState.ID, category=Constants.CAT_EXECUTION_STACK, label="PopBESState", description="") public class PopBESState {
public static final String ID = "PopBESState";
@In (value="#{bESStateStack}")
BESStateStack<String> stack;
private static final Log log = LogFactory.getLog(PopBESState.class);
@OperationMethod
public DocumentModel run(DocumentModel input) {
try {
String x = (String)stack.pop();
log.warn("Stack pop state = "+ x);
input.setProperty("bespreviousstate", "previousstate", x);
} catch (ClientException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return input;
}
}
@Operation(id=PushBESState.ID, category=Constants.CAT_EXECUTION_STACK, label="PushBESState", description="") public class PushBESState {
@In (value="#{bESStateStack}",create=true)
BESStateStack<String> stack;
public static final String ID = "PushBESState";
private static final Log log = LogFactory.getLog(PushBESState.class);
@OperationMethod
public DocumentModel run(DocumentModel input) {
try {
String x = (String)input.getProperty("bespreviousstate", "previousstate");
log.warn("state = "+ x);
stack.push(x);
} catch (ClientException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return input;
}
}
09-12-2012 09:24 AM
Did you have the seam.properties empty file in src/main/resources ?
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.