Getting a Stack must not be null when call an Home Object from MDB
rogerwbmd May 28, 2008 4:27 PMI need to call a Home object created by seam-gen (New - Seam Entity) from a MDB. First I tried to inject the home object but the MDB didn't work at all (no exception.) Then I tried to get the Home object by SystemMailHome systemMailHome = (SystemMailHome) Component.getInstance(SystemMailHome.class, true); But I get an exception on the line above: java.lang.IllegalArgumentException: Stack must not be null
Does anyone see this before? Does it have anything to do with the scope of my Home object and my MDB? Thanks!!
My MDB:
package com.xxx.OpsAIPOC.mdb;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.mail.*;
import javax.mail.internet.*;
import java.io.*;import org.jboss.annotation.ejb.ResourceAdapter;
import org.jboss.resource.adapter.mail.inflow.MailListener;
import org.jboss.logging.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.*;import com.webmd.OpsAIPOC.session.SystemMailHome;
import com.webmd.OpsAIPOC.entity.SystemMail;
/**
* A JavaMail based MDB for EJB3 use
*/
@MessageDriven(activationConfig={
@ActivationConfigProperty(propertyName="mailServer", propertyValue="..."),
@ActivationConfigProperty(propertyName="mailFolder", propertyValue="..."),
@ActivationConfigProperty(propertyName="storeProtocol", propertyValue="..."),
@ActivationConfigProperty(propertyName="pollingInterval", propertyValue="..."),
@ActivationConfigProperty(propertyName="userName", propertyValue="..."),
@ActivationConfigProperty(propertyName="password", propertyValue="...")
})
@ResourceAdapter("mail-ra.rar")
@Name("OpsAIMailListener")
public class OpsAIMailListener implements MailListener
{
private static Logger log = Logger.getLogger(OpsAIMailListener.class);
//Injection, but it doesn't work
//@In(create=true) SystemMailHome systemMailHome;
public void onMessage(Message msg)
{
try{
log.info("onMessage, Subject="+msg.getSubject());
printMessage(msg);
}catch(Exception me){
me.printStackTrace();
}
}
public void printMessage(Message message)
{
try{
....
....
SystemMailHome systemMailHome = (SystemMailHome) Component.getInstance(SystemMailHome.class, true);
SystemMail sm = new SystemMail(); sm.setEmailSubject(subject); systemMailHome .setInstance(sm);
systemMailHome .persist();
}catch (Exception ex){
ex.printStackTrace();
}
}
}
My Home Object:
package com.xxx.OpsAIPOC.session;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.RequestParameter;
import org.jboss.seam.framework.EntityHome;
import com.xxx.OpsAIPOC.entity.SystemMail;
@Name("systemMailHome")
public class SystemMailHome extends EntityHome<SystemMail>
{
private static final long serialVersionUID = 1881413500711441951L;
@RequestParameter
Long systemMailId;
@Override
public Object getId()
{
if (systemMailId==null)
{
return super.getId();
}
else
{
return systemMailId;
}
}
@Override @Begin
public void create() {
super.create();
}
}
Exception I got:
12:18:45,980 ERROR [STDERR] java.lang.IllegalArgumentException: Stack must not be null 12:18:45,980 ERROR [STDERR] at org.jboss.seam.core.ConversationEntry.<init>(ConversationEntry.java:40) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.core.ConversationEntries.createConversationEntry(ConversationEntries.java:50) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.core.Manager.createConversationEntry(Manager.java:685) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.core.Manager.beginConversation(Manager.java:707) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.interceptors.ConversationInterceptor.beginConversation(ConversationInterceptor.java:194) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.interceptors.ConversationInterceptor.beginConversationIfNecessary(ConversationInterceptor.java:131) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.interceptors.ConversationInterceptor.aroundInvoke(ConversationInterceptor.java:55) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.interceptors.TransactionInterceptor$1.work(TransactionInterceptor.java:32) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.util.Work.workInTransaction(Work.java:37) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.interceptors.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:27) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87) 12:18:45,980 ERROR [STDERR] at com.xxx.OpsAIPOC.session.SystemMailHome_$$_javassist_6.create(SystemMailHome_$$_javassist_6.java) 12:18:45,980 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 12:18:45,980 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 12:18:45,980 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 12:18:45,980 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:20) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:123) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.Component.callComponentMethod(Component.java:1834) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.Component.callCreateMethod(Component.java:1757) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.Component.newInstance(Component.java:1746) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.Component.getInstance(Component.java:1643) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.Component.getInstance(Component.java:1610) 12:18:45,980 ERROR [STDERR] at org.jboss.seam.Component.getInstance(Component.java:1589) 12:18:45,980 ERROR [STDERR] at com.xxx.OpsAIPOC.mdb.OpsAIMailListener.printMessage(OpsAIMailListener.java:106) 12:18:45,980 ERROR [STDERR] at com.xxx.OpsAIPOC.mdb.OpsAIMailListener.onMessage(OpsAIMailListener.java:53) ...