如何告诉 Seam 注入本地 EJB 接口(SLSB)而不是远程 EJB 接口(SLSB)?

发布于 2024-08-30 02:34:09 字数 3969 浏览 5 评论 0 原文

我正在使用 Seam 和 JBoss AS。 在我的应用程序中,我有一个 SLSB,它也使用 @Name 注释声明为接缝组件。我正在尝试使用 @In 注释在另一个接缝组件中注入并使用此 SLSB。

我的问题是,有时Seam注入本地接口(然后代码运行正常),有时Seam注入远程接口(然后代码执行时出现错误)。我已尝试执行此链接上指定的所有操作: http://docs.jboss.org/seam/2.2.0.GA/reference/en-US/html/configuration.html#config.integration.ejb.container< /a>

SeamInterceptor 已配置,
我已在 Components.xml 文件中指定了 jndi 模式 ( ),
我还尝试对每个 SLSB 使用 @JndiName("earName/ejbName/local") 注释,
我尝试在 seam.properties 文件中设置此属性( org.jboss.seam.core.init.jndiPattern=earName/#{ejbName}/local )。
我还尝试将下面的文本放入 web.xml 文件中

<上下文参数>
    <参数名称>org.jboss.seam.core.init.jndiPattern
    <参数值>earName/#{ejbName}/local
  

即使完成上述所有操作后,接缝有时仍然会注入远程接口。我在这里错过了什么吗?谁能告诉我如何解决这个问题并告诉seam始终注入本地接口?

我的 Components.xml 文件如下所示:


<组件 xmlns="http://jboss.com/products/seam/components"
        xmlns:core="http://jboss.com/products/seam/core"
        xmlns:persistence="http://jboss.com/products/seam/persistence"
        xmlns:drools="http://jboss.com/products/seam/drools"
        xmlns:bpm="http://jboss.com/products/seam/bpm"
        xmlns:security="http://jboss.com/products/seam/security"
        xmlns:mail="http://jboss.com/products/seam/mail"
        xmlns:web="http://jboss.com/products/seam/web"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:架构位置=
            “http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd
             http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd
             http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.1.xsd
             http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.1.xsd
             http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd
             http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.1.xsd
             http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.1.xsd
             http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd">
  
  <核心:经理并发请求超时=“500”
             对话超时=“120000”
             对话 id 参数=“cid”
             parent-conversation-id-parameter=“pid”/>
  
  <持久性:托管持久性上下文名称=“entityManager”自动创建=“true”
                  persistence-unit-jndi-name="@puJndiName@"/>;
  
    
      <值>/security.drl
    
  
  ;
  
  <事件类型=“org.jboss.seam.security.notLoggedIn”>
     <操作执行=“#{redirect.captureCurrentView}”/>
  
  <事件类型=“org.jboss.seam.security.loginSuccessful”>
     <操作执行=“#{redirect.returnToCapturedView}”/>
  
  <组件名称=“org.jboss.seam.core.init”>
     <属性名称=“jndiPattern”>myEarName/#{ejbName}/local
  

我的 EJB 组件如下所示:


@Stateless
@Name("myEJBComponent")
@AutoCreate
public class MyEJBComponentImpl implements MyEJBComponentRemote, MyEJBComponentLocal {

    public void doSomething() {

    }

}


I am using Seam with JBoss AS.
In my application I have a SLSB which is also declared as a seam component using the @Name annotation. I am trying to inject and use this SLSB in another seam component using the @In annotation.

My problem is that sometimes Seam injects the local interface (then the code runs fine) and sometimes seam injects the remote interface (then there is an error in execution of the code). I have tried doing all the things specified on this link: http://docs.jboss.org/seam/2.2.0.GA/reference/en-US/html/configuration.html#config.integration.ejb.container

The SeamInterceptor is configured,
I have specified the jndi pattern in components.xml file ( < core:init debug="true" jndi-pattern="earName/#{ejbName}/local"/> ),
I have also tried using the @JndiName("earName/ejbName/local") annotation for every SLSB,
I have tried setting this property ( org.jboss.seam.core.init.jndiPattern=earName/#{ejbName}/local ) in the seam.properties file.
I have also tried putting the text below in web.xml file

<context-param>
    <param-name>org.jboss.seam.core.init.jndiPattern</param-name>
    <param-value>earName/#{ejbName}/local</param-value>
</context-param>  

Even after doing all the above mentioned things, the seam still injects the remote interface sometimes. Am I missing something here? Can anyone tell me how to resolve this issue and tell seam to always inject the local interface?

My components.xml file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<components xmlns="http://jboss.com/products/seam/components"
        xmlns:core="http://jboss.com/products/seam/core"
        xmlns:persistence="http://jboss.com/products/seam/persistence"
        xmlns:drools="http://jboss.com/products/seam/drools"
        xmlns:bpm="http://jboss.com/products/seam/bpm"
        xmlns:security="http://jboss.com/products/seam/security"
        xmlns:mail="http://jboss.com/products/seam/mail"
        xmlns:web="http://jboss.com/products/seam/web"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation=
            "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd
             http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd
             http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.1.xsd
             http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.1.xsd
             http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd
             http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.1.xsd
             http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.1.xsd
             http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd">
  <core:init debug="true" jndi-pattern="myEarName/#{ejbName}/local"/>
  <core:manager concurrent-request-timeout="500"
             conversation-timeout="120000"
             conversation-id-parameter="cid"
             parent-conversation-id-parameter="pid"/>
  <web:hot-deploy-filter url-pattern="*.seam"/>
  <persistence:managed-persistence-context name="entityManager" auto-create="true"
                  persistence-unit-jndi-name="@puJndiName@"/>
  <drools:rule-base name="securityRules">
    <drools:rule-files>
      <value>/security.drl</value>
    </drools:rule-files>
  </drools:rule-base>
  <security:rule-based-permission-resolver security-rules="#{securityRules}"/>
  <security:identity authenticate-method="#{authenticator.authenticate}" remember-me="true"/>
  <event type="org.jboss.seam.security.notLoggedIn">
     <action execute="#{redirect.captureCurrentView}"/>
  </event>
  <event type="org.jboss.seam.security.loginSuccessful">
     <action execute="#{redirect.returnToCapturedView}"/>
  </event>
  <component name="org.jboss.seam.core.init">
     <property name="jndiPattern">myEarName/#{ejbName}/local</property>
  </component>
</components>

And my EJB component looks like:


@Stateless
@Name("myEJBComponent")
@AutoCreate
public class MyEJBComponentImpl implements MyEJBComponentRemote, MyEJBComponentLocal {

    public void doSomething() {

    }

}


如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

水中月 2024-09-06 02:34:09

我想下面的

 public interface MyStateless {

     void doSomething();         

 }

 /**
   * Be aware you CAN NOT USE @Local and @Remote at the same time
   */

 @Local
 public interface MyStatelessLocal extends MyStateless {}

 @Remote
 public interface MyStatelessRemote extends MyStateless {}

你的无状态应该看起来像

 /**
   * Global JNDI address will be earName/MyStatelessImpl/local and earName/MyStatelessImpl/remote
   */
 @Stateless
 @Name("myStateless")
 public class MyStatelessImpl implements MyStatelessLocal, MyStatelessRemote {

     public void doSomething() {

     }

 }

在你的Seam组件中

 @Name("otherSeamComponent")
 public class OtherSeamComponent {

     /**
       * Seam will lookup a Seam Component by field name - myStateless
       *
       * Notice i am using the local interface
       */
     private @In MyStatelessLocal myStateless;

 }

I suppose the following one

 public interface MyStateless {

     void doSomething();         

 }

 /**
   * Be aware you CAN NOT USE @Local and @Remote at the same time
   */

 @Local
 public interface MyStatelessLocal extends MyStateless {}

 @Remote
 public interface MyStatelessRemote extends MyStateless {}

Your Stateless should looks like

 /**
   * Global JNDI address will be earName/MyStatelessImpl/local and earName/MyStatelessImpl/remote
   */
 @Stateless
 @Name("myStateless")
 public class MyStatelessImpl implements MyStatelessLocal, MyStatelessRemote {

     public void doSomething() {

     }

 }

Inside your Seam component

 @Name("otherSeamComponent")
 public class OtherSeamComponent {

     /**
       * Seam will lookup a Seam Component by field name - myStateless
       *
       * Notice i am using the local interface
       */
     private @In MyStatelessLocal myStateless;

 }
假面具 2024-09-06 02:34:09

@Arthur Ronald FD Garcia:我的错,我忽略了您上面发布的答案的一小部分。

在我的应用程序中,我有 MyStatelessLocal 和 MyStatelessRemote 接口,但没有 MyStateless 父接口。我在本地和远程接口中都添加了抽象方法,并且它们不为空。

当我创建 MyStateless 父接口,将抽象方法从本地和远程接口移动到父接口(以便本地和远程接口为空)时,错误得到解决,现在我的应用程序工作正常!

非常感谢您的帮助!

——哈沙德·维亚瓦哈雷。

@Arthur Ronald F D Garcia : My bad, I ignored a small part of the answer you posted above.

In my application I had MyStatelessLocal and MyStatelessRemote interfaces, but did not have the MyStateless parent interface. I had added the abstract methods in both, local and remote interfaces, and they were not empty.

When I created a MyStateless parent interface, moved the abstract methods from the local and remote interface to the parent interface (so that the local and remote interfaces are empty), the error got resolved, and now my application is working fine!

Thank you very much for your help!

--Harshad Vyawahare.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文