English 中文(简体)
EJB 玻璃鱼网应用中的注射
原标题:EJB injection in Glassfish webapp

我用“EJB”通知,在我的ejb.jar档案中用远距离提及EJBs。 结果是不一致的。 在1起案件中,我有一位听众,他们被叫来,而且显然EJB正确地投了票,因为我可以看到它与EJB有联系,并用这种方法。 在另一类(插手2行动)中,当我试图查阅EJB参考文件时,我会得到国家空间局的帮助。 就我可以说的话来说,他们在 Java门住同样的 file门。

作为周围的工作,我增加了建筑商的代码,以便按其全球JNDI名称对EJBs进行监视,并做了罚款。 我只能说明为什么有一个@EJB运作,而不是另一个。

最佳回答

你们如何在Stuts 2行动中注入EJBs? 你们是否利用了土发委会? 您是否使用Struts2 CDI plugin?

<>Update: 问题是,集装箱不是制造Stuts物体,因此集装箱没有机会注入任何东西。 您必须使用上述plugin for CDI,以便能够在你的行动中注入。

如果你想给它一个尝试,请获得两个来源:

svn co http://svn.apache.org/repos/asf/struts/struts2/trunk/ struts2

接着,cd into the struts2Directory andpring the following control (该编码将汇编struts-cdi-plugin所需的模块)。

mvn install -pl plugins -am

之后,又获得迪普林来源:

svn co https://svn.apache.org/repos/asf/struts/sandbox/trunk/struts2-cdi-plugin/

汇编:

mvn install

现在,我寄希望于:

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>2.2.0-SNAPSHOT</version>
</dependency>
<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-cdi-plugin</artifactId>
    <version>2.2.0-SNAPSHOT</version>
</dependency>
<dependency>
  <groupId>javassist</groupId>
  <artifactId>javassist</artifactId>
  <version>3.8.0.GA</version>
</dependency>

我参加了一次行动:

public class HelloWorld extends ActionSupport {

    @Inject
    HelloEJB helloEjb;

    @Override
    public String execute() throws Exception {
        setMessage(helloEjb.getMessage());
        return SUCCESS;
    }

    private String message;

    public void setMessage(String message) {
        this.message = message;
    }

    public String getMessage() {
        return message;
    }

}

https://svn.apache.org/repos/asf/struts/sand Box/trunk/struts2-cdi-example/,例如。

问题回答

暂无回答




相关问题
Recommended way to develop using Jetty and Eclipse

I am currently developing a J2EE application and I would like to use Jetty. I would like to have iot integrated with Eclipse, so I could debug the appliaction. I ve tried out couple of plugins (...

Call function periodically in Java

we need run one function periodically in Java web application . How to call function of some class periodically ? Is there any way that call function when some event occured like high load in server ...

Why make an EJB rather than a Web Service?

I would have thought that there is a lot of information out there on this, but I haven t found anything that really answers my question. What are the advantages of making an EJB rather than a web ...

Where should I put this configuration setting?

I m designing a fairly small web application which will run on a Sun application server (v9.1). It only has a few pages, no database of its own, and will retrieve/update data via web services. There s ...

JNDI Names -- Is Prefix "jdbc/" needed?

What s up with JNDI names? I m trying to get a javax.sql.DataSource using the new annotations feature of Java 5. It s not working for me, so I want to ask... I have a in my web.xml, inside of it is ...

hibernate interceptors : afterTransactionCompletion

I wrote a Hibernate interceptor : public class MyInterceptor extends EmptyInterceptor { private boolean isCanal=false; public boolean onSave(Object entity, Serializable arg1, Object[] arg2, String[]...

热门标签