struts2ejb3-jboss-plugin是个非常好用的struts2插件,使得注入SessionBean非常方便。
使用参考了
http://code.google.com/p/struts2ejb3-jboss-plugin/
在测试过程中遇到了一些问题
关键是@InjectEJB这个annotation的使用问题。
官方上只给了一个例子@InjectEJB(name="UserSessionBean"),在我的代码里我也只是写了我的session Bean的名字。可是报了local not bound的错误。查看下这个annotation的源码,
public @interface InjectEJB {
String name();
String appname() default "";
boolean local() default true;
boolean remote() default false;
}
原来还有三个属性,local默认为true,remote默认为false,我的sessionbean只声明了remote,所以根据sessionbean的情况,我的代码改为@InjectEJB(name="UserSessionBean",remote=true,local=false),调用成功。