I have a application which contains the following
some server side logic which are bundled as a jboss module
The EJB layer which is bundle into the EAR
The RESTful layer which is bundled as a war which is in the EAR
Both the EJB and RESTful modules depends on the server side logic modules which are jboss modules. This server side logic has dependencies to other modules such as guava, hibernate, and some home grown modules as well.
Now i want to use Arquillian to write some tests to both EJB and REST layers. But to do that i cannot find any reference how i can include the jboss modules i have in the ShrinkWrap.
I tried searching for documentation but i couldn't find any reference. I only found ShrinkWrap Descriptor library for jboss modules, but not how to ShrinkWrap a complete jboss module with the required jar files.
It would be great if someone point me to a documentation or sample which shows how to ShrinkWrap a complete jboss module.
Related
I have a 1.4 EAR deployed on WAS 8.5+.
I've created a JAX-RS RESTful service WAR bundled inside the EAR. Ive got a ton of deployment scripts related to this EAR, so I'd prefer not to deploy the war separately.
When reading docs, it's all about JEE6+ compliance
Has anyone actually done this in the real world?
I have an application which I am deploying on GlassFish. It has an EJB-tier with (JPA) Entites and EJBs to get access and write to the database and it has 3 (independent) web apps. Everything is built with Maven.
ServerApplication
|
+-ServerApplication-ear
+-ServerApplication-ejb
|
+-GrumpyCat (war)
+-HummingBird (war)
+-Koala (war)
All three war projects depend on the ejb project. When compiling/building the ear, it copies the war files to the ear project and then I can deploy the ear file on GlassFish.
This works fine, all 4 modules (the ejb, and the 3 war) get deployed without problems and I can access the 3 war projects like:
myServer.com/GrumpyCat
myServer.com/HummingBird
myServer.com/Koala
My problem is, that I can't deploy a single war project on its own. For example when I change something in the koala project, I would like to be able to build only the koala.war and deploy it on the server, without having to upload and deploy the complete ear file.
But when deploying, GlassFish tells me either :
there is already a project deployed on Koala (true, it was deployed together with the ear)
or (when I change the build-version) it doesn't "know" the ejbs and I get a number of ClassNotFound Exceptions.
Is there a way to deploy the modules of the application one by one?
Your second approach is the way to go if you really want to deploy them individually. However, you are seeing a ClassNotFound exception because the WARs are individual projects and as such don't have access to the EAR's class path.
To make that work, you have to add the public API of your application to your WAR's classpath. The public API consists of at least the EJB's remote interfaces of the EJBS that you would like to access from the WAR and any DTOs used in your API.
The easiest way is to create a separate package (such as com.example.api) and let a build tools such as ant or Maven bundle that api package together with your EJBs and your WARs, or you create a myapp-api.jar and include it in the respective class-paths.
Then you can remove the WARs from the EAR and deploy them as separate projects.
I have a number of web applications under JBOSS EAP 6.2 which use jBPM 6.
jBPM jars take about 20MB in each WEB-INF/lib so I decided to move them into a separate JBoss module. After that I have issues with classloading because jBPM module's classloader tries to load classes by name defined in web applications and fails to do that (ClassNotFound errors).
So my question is there a way to use jBPM 6 as a JBoss module OR is there a way to load jBPM module's classes using web applications classloaders?
Thank you!
There are modules containing core jars available out-of-the-box:
http://repository.jboss.org/nexus/content/groups/public/org/kie/kie-eap-distributions-bpms-layer/
The slim workbench war using these modules is available here:
http://repository.jboss.org/nexus/content/groups/public/org/kie/kie-eap-distributions-bpms-webapp/
Note that the latest snapshots are targeted to eap 6.3.0.
I have web application which has a servlet and an ejb. The ejb is annotated #Local. In my servlet I used #Inject to inject the ejb. It woekd fine.
Then I created an ear with an ejb module and a web module. I deployed the ear and I got exceptions. Then I learned that I cannot use #Inject. So I used #Resource(lookup = "jndiname") and then it worked.
Then I created an independent web application and used the #Resource annotation to inject the ejb in the ear into a servlet. The war failed to load. So I thought to place the ejb jar inside the lib directory of the app server so that all applications in the app server can use them. I am using jboss eap 6.0. I placed the jar under jbosshome/modules/com/ejb/beginner/main/. It did not work. I got exceptions. Then I placed the ejb jar in jbosshome/modules/com/ejb/beginner/api/main/. Still no luck.
I want to learn how to create #Local beans so that applications in the app server can use. Is it possible?
I figured it out. If I want to use modules from another ear in other deployments I have to declare the dependencies in the MANIFEST.MF file like this
Dependencies: deployments.appname.ear.appname.jar
The following links help me figure it out
https://community.jboss.org/message/604576
https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7
i'm setting up a new multi module project structure. for now there is an ejb and an ear module and i want to add a web module for a RESTful web service. what is the best approach?
the application looks like this (modules and their content):
app (pom): the parent pom
core (ejb): ejb, hibernate, DAOs, entities, business logic
ear (ear): the module that creates a deployable container
now i would like to add a restful webservice module.
looking at the jboss-as-7 quickstart applications from http://www.jboss.org/jbossas/downloads there is always a war module which just bootstraps the rest service while the beans with jax-rs annotations are part of the ejb project (in my case core:
app
ejb (containing services + beans with jax-rs annotations)
ear
war (just containing a web.xml)
my issue with this approach is that the ejb module contains the services and the rest resources. wouldn't it be better to keep them separate? or is this the way to go?
otherwise: which approach would be better?
app
core
ear
rest (war which contains the rest resource beans and the web.xml)
or
app
core
ear
rest
rest-resources (separate container for the rest resource beans)
rest-war (war which only contains the web.xml)
From a JEE6/JAX-RS point of view the only thing you need a WAR file for is to actually have something to hand off to the application server to deploy. It can literally contain no resources (except for the ones required to make it a valid archive) and your application will still work as long as your classes are made available somewhere on the classpath. So, its really up to you to bundle up these classes as you see fit.
The one thing you will need is a class that extends javax.ws.rs.core.Application. This class is used as a marker/bootstrap to indicate to the application server that there are REST resources available in the web archive that need to be loaded. In most shops I've seen this class placed in the WAR project itself.
If you are really looking for organizational tips, I would recommend you start off by grouping all the REST resource classes together in their own project. Add as dependencies, any projects that are required for the resource classes to work (for example your core and ear projects). Add all three (rest, ear, core) as dependencies for your war project.
Then refine the model as needed, as you work your way through implementation.
There is a really awesome JBoss Maven Archetype for this sort of project.
1) Go to eclipse with maven integration installed
2) New -> Project -> Maven Project
3) Click Next
4) In Filter type in ee6
5) Out of the options that appear, use Group ID: "org.jboss.spec.archetypes", and Artifact ID: "jboss-javaee6-webapp-archetype"
6) Out will come a beautifully structured web application project with EAR connecting to a EJB project and a WAR project.