dev@glassfish.java.net

About hybrid application which demonstrates an EJB as an OSGi service

From: Tang Yong <tangyong_at_cn.fujitsu.com>
Date: Fri, 07 Sep 2012 16:06:44 +0900

Hi sahoo,

  Today, I looked your previous blog[1] again, and tried second hybrid
application which demonstrates an EJB as an OSGi service on my build
snapshot based on crrent gf trunk. But I met some problems.
[1]http://weblogs.java.net/blog/ss141213/archive/2009/06/accessing_an_ej.html

  Firstly, I modified parent pom[2] of the hybrid sample in order to use
the recent jar.
[2]pl. see the attachment(pom.xml)

  Secondly, I start to deploy hybridapp2-service.jar using the following
three ways,

(1) using "asadmin deploy" command

>asadmin deploy E:\gfv4\hybridapp2-service.jar

The result failed, and the following error happened on cmd shell.

remote failure: Error occurred during deployment: Exception while
preparing the app : Unable to load the EJB module. DeploymentContext
does not contain any EJB. Check the archive to ensure correct packaging
for ...
If you use EJB component annotations to define the EJB, and an ejb or
web deployment descriptor is also used, please make sure that the
deployment descriptor references a Java EE 5 or higher version schema,
and that the metadata-complete attribute is not set to true, so the
component annotations can be processed as expected. Please see
server.log for more details. Command deploy failed.

BTW: while using "asadmin deploy E:\gfv4\hybridapp2-service.war" , the
result is the same as (1).

(2) using "asadmin deploy --type=osgi" command

>asadmin deploy --type=osgi E:\gfv4\hybridapp2-service.jar

The result displayed on cmd shell is successful, but I found that while
deploying, start method of sahoo.hybridapp.example2.service.Activator
was firstly executed, and UserAuthServiceEJB.selfRef was null, so on the
server.log, the following info[3] was printed. Then, postConstruct()
method of UserAuthServiceEJB class was executed, but, after executing
[4], selfRef was still null.

[3] "Not able to register the EJB as service, as it didn't deploy"
[4] selfRef = sessionContext.getBusinessObject(UserAuthService.class);

(3) directly cp hybridapp2-service.jar into domain1\autodeploy\bundles

The result is the same as (2).

So, if having time, could you please confirm the sample and whether I
made some mistake or not? Or other reasons?

Thanks!
--Tang