In the previous Part1 , I have introduced how to integrate Apache Aries Application(EBA) into Glassfish. And in the Part1, I used a simple sample to demonstrate such an integration. However, in a real world, an user’s application can be very complex and typically be made up of EJB, JPA,Servlet,CDI,JAX-RS…. So, you can ask me whether I can use these skills in an EBA and deploying the EBA into Glassfish successfully?
The answer is Yes!
Firstly, an EBA can be made up of EJB Bundles, an WAB, other OSGi Bundles.
Secondly, by using hybrid OSGi-JavaEE(EJB Bundles and WAB) , an user can use powers from both JavaEE and OSGi.
Thirdly, we can deploy such an EBA with JEE capability into Glassfish successfully.
Next, let us see an concrete example. As a prerequisite, please building a glassfish with Aries Application Bundles based on Part1.
Then, we can build such a EBA with JEE based on Fighterfish UAS Sample .
[Wrapping UAS Sample into EBA]
1. Create a directory called “ebawithjee”
2. Creating a pom.xml file and adding the following important contents,...
<name>Glassfish Ear Bundle With JEE</name>
Here, we select the following bundles from UAS Sample,
Providing an interface called “UserAuthService”
Creating EntityManagerFactory and persisting/finding user’s registration data.
3) sample.uas. ejbservice
Defining a stateless session bean with local view, and the ejb implements UserAuthService interface.
This is a WAB using Servlet 3.x and uses Glassfish OSGi/CDI skill to obtain UserAuthService. Eg, seeing the following,
private UserAuthService uas;
Among the above bundles, 1) and 2) are common OSGi bundles, 3) are EJB Bundle, 4) is a WAB.
3. executing “mvn clean install”
This will generate an EBA file(seeing the attachment) with the above UAS Sample Bundles.
[Deploying EBA into Glassfish]
1. executing “asadmin start-database”
2. setting the following in glassfish/config/osgi.properties
Defaultly, the value is false. Because we will use JPA in sample.uas.entities bundle, so we must set the value is true. Otherwise, you will see http://java.net/jira/browse/GLASSFISH-20345
3. executing “asadmin start-domain”
4. deploying the EBA with JEE into Glassfish
putting the EBA into glassfish/domains/domain1/autodeploy/bundles directory.
5. executing “asadmin osgi lb”
Seeing whether deploying is successful, of course, we also should see whether any exception happened server.log.
[Running The EBA]
From your favorite browser, accessing http://localhost:8080/uas/index.jsp
And click “register”and “login”to see whether you are “Welcome”, ：）
Good luck to you!