我使用Seam和JBoss AS。 在我的應用程序中,我有一個SLSB,它也使用@Name註釋聲明爲seam組件。我正在嘗試使用@In註釋在另一個seam組件中注入和使用此SLSB。如何告訴Seam注入本地EJB接口(SLSB)而不是遠程EJB接口(SLSB)?
我的問題是,有時Seam注入本地接口(然後代碼運行正常),有時會接縫注入遠程接口(然後執行代碼時出現錯誤)。我曾嘗試做這一切鏈接指定的東西:http://docs.jboss.org/seam/2.2.0.GA/reference/en-US/html/configuration.html#config.integration.ejb.container
將SeamInterceptor配置,
我指定在components.xml文件中的JNDI模式(<核心:初始化調試=「真正的」 JNDI模式=」我已經嘗試使用@JndiName(「earName/ejbName/local」)註釋爲每個SLSB,
我已經嘗試設置此屬性(org.jboss。 seam.properties文件中的seam.core.init.jndiPattern = earName /#{ejbName}/local)。
我也試圖把下面的文字在web.xml文件
<context-param> <param-name>org.jboss.seam.core.init.jndiPattern</param-name> <param-value>earName/#{ejbName}/local</param-value> </context-param>
即使做上述所有事情後,縫還是注入的遠程接口的時候。我在這裏錯過了什麼嗎?任何人都可以告訴我如何解決這個問題,並告訴seam始終注入本地接口?
我components.xml文件看起來像:
<?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="@[email protected]"/> <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>
我的EJB組件的樣子:
@Stateless
@Name("myEJBComponent")
@AutoCreate
public class MyEJBComponentImpl implements MyEJBComponentRemote, MyEJBComponentLocal {
public void doSomething() {
}
}
我檢查了jboss日誌,我在日誌文件中觀察到這一行:DEBUG [org.jboss.seam.Component](main)org。jboss.seam.core.init.jndiPattern = myEarName /#{ejbName}/local, jndiPattern正在正確設置。 – 2010-04-28 07:11:43
V看起來不錯!嘗試以下方法:**移除遠程界面**,並查看您的應用程序是否正常運行。如果沒有,請顯示您的stackTrace。如果可能,請不要使用AutoCreate註釋。 – 2010-04-28 13:59:49
@Arthur Ronald F D Garcia:好的,我刪除了AutoCreate註釋,並用@In(create = true)替換它。我刪除了所有的遠程接口,並運行應用程序6次(因爲即使使用遠程接口,應用程序有時也能正常工作),它在6次運行都很順利。我覺得用這個遠程接口去掉seam並不會感到困惑,使用哪個接口,本地還是遠程。 – 2010-04-29 06:28:44