1: наше приложение работает на сервере приложений Weblogic, версия 10.3.0
2: в нашей системе нам необходимо развернуть EJB, соответствующий спецификации EJB 3.0.
пример кода для нашей среды UAT, как показано ниже:
/*The remote interface*/
package com.serverside.ejb.session;
import javax.ejb.Remote;
@Remote
public interface ASimpleSessionBeanRemote {
public void printThis(String print);
}
/*The bean class*/
package com.serverside.ejb.session;
import javax.ejb.Remote;
import javax.ejb.Stateless;
/**
* Session Bean implementation class ASimpleSessionBean
*/
@Stateless(name="ASimpleSessionBean", **mappedName = "ASimpleSessionEJB"**)
@Remote(ASimpleSessionBeanRemote.class)
public class ASimpleSessionBean implements ASimpleSessionBeanRemote {
/**
* Default constructor.
*/
public ASimpleSessionBean() {
// TODO Auto-generated constructor stub
}
@Override
public void printThis(String print) {
// TODO Auto-generated method stub
System.out.println("ASimpleSessionBean : "+print);
}
}
3: Приведенные выше файлы при упаковке в jar успешно развертываются на сервере.
4: Согласно спецификации EJB 3.0,дескрипторы развертывания не являются обязательными. Итак, в jar не входят ejb-jar.xml и weblogic-ejb-jar.xml
5: см. ниже ссылку на аннотации EJB3.0 в соответствии с приложением WeblogicСерверная документация:
Annotation : @Stateless
Package: javax.ejb.Stateless
Attribute : mappedName
Description :
Specifies the product-specific name to which the stateless session bean should be mapped.
You can also use this attribute to specify the JNDI name of this stateless session bean. WebLogic Server uses the value of the mappedName attribute when creating the bean’s global JNDI name. In particular, the JNDI name will be:
mappedName#name_of_businessInterface
where name_of_businessInterface is the fully qualified name of the business interface of this session bean.
For example, if you specify mappedName="bank" and the fully qualified name of the business interface is com.CheckingAccount, then the JNDI of the business interface is bank#com.CheckingAccount.
6: в соответствии с приведенной выше спецификацией образец EJB, развернутый на нашем сервере приложений, имеет имя привязки (как отражено в дереве jndi) следующим образом:
ASimpleSessionEJB # com.serverside.ejb.session.ASimpleSessionBeanRemote
JNDI-поиск с использованием этого имени завершается успешно:
InitialContext.doLookup("ASimpleSessionEJB#com.serverside.ejb.session.ASimpleSesionBeanRemote");
7: Теперь нам нужно имя привязки to быть простой строкой, т.е. поиск должен выглядеть примерно так:
InitialContext.doLookup ("ASimpleSessionEJB");
8: для реализации пункта 7 мы попыталисьиспользуя ejb-jar.xml и weblogic-ejb-jar.xml следующим образом ( Извините, не могу понять, как прикреплять / отображать файлы XML ):
9: Несмотря на пункт 8, имя привязки остается следующим:
ASimpleSessionEJB#com.serverside.ejb.session.ASimpleSessionBeanRemote
10: Пожалуйста, сообщите нам о решении и реализации для участия в пункте 7.
Спасибо!