Showing posts with label EJB. Show all posts
Showing posts with label EJB. Show all posts

Monday, October 29, 2007

今天在deploy一個ejb, 裡面因為用到spring所以把他的manifest.mf改了改, 想說可以把dependent的jar塞進去這個ejb的jar. 原本想說沒啥問題, 但今天弄了一整天, 才發現這句關鍵的句子害我感到都浪費了
Use the manifest file to specify that a JAR file can reference another JAR file.
Standalone EJBs cannot use the Manifest Class-Path. It is only supported for
components that are deployed within an EAR file
. The clients should reference
the client.jar in the classpath entry of the manifest file.

真讓我感到傷心, 原來是因為這樣, 不過超神奇的還是weblogic如果直接選原本的檔案, 卻又活的好好的, 讓我感到很迷惘阿.
雖然可以找到的解法很多, 像是直接把classpath塞到weblogic的classpath裡面, 但是想說不要動server的設定比較好, 結果就讓我耗了一天了!! 可惡~~

Friday, October 26, 2007

當Spring碰上EJB

最近都在學一堆JAVA的framework, 對很多人來說, 這都不是新東西. 不過依舊多少會碰到一些問題. 所以就順手把一些常用的筆記寫下來了.

記得第一個碰到的是怎麼利用spring去config EJB. 方法有很多種, 在此簡單寫一下我的做法.

在Spring當中, 它提供三種abstract class, 形同EJB的bean class.








abstract class for bean in Spring
In Spring EJB
AbstractStatelessSessionBean Stateless Session Bean
AbstractStatefulSessionBean Stateful Session Bean
AbstractMessageDrivenBean Message Driven Bean

以上皆源自於AbstractEnterpriseBean

需要的步驟如下:

1. BeanFactoryLocator: 他是個interface, 必須有Function: BeanFactoryReference userBeanFactory (String factoryKey) throws BeansException;

2. ServiceInterface以及他的implementation

3. EJBObject的Interface要extends ServiceInterfaceEJBObject

4. EJBHome: 要extends EJBHome
,要記得function create()要return 3的type

5. Bean: 根據需求, extends上表當中的class, 最重要的事情是要有onEjbCreate() throws CreateException這個function.

6. Finally, 要在deployment descriptor當中(也就是ejb-jar.xml檔案)當中加入中的<env-entry-name>, <env-entry-type>,<env-entry-value>.


<env-entry>
<env-entry-name>ejb/BeanFactoryPath</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>spring-config.xml</env-entry-value>
</env-entry>