This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JBoss and the fly likes JBoss EAR structure Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Products » JBoss
Reply Bookmark "JBoss EAR structure" Watch "JBoss EAR structure" New topic
Author

JBoss EAR structure

John Ozimits
Greenhorn

Joined: Jul 15, 2008
Posts: 2
Could somebody please tell me how an EAR is supposed to be organized if it were to have:
- A WAR
- An EJB jar
- A couple of classes jars
- A SAR (that should run before the EAR is started)


I've looked through the JBoss documentation but they don't explain how to embed things in an EAR well beyond "here's how you make a sar" and "here's how you make a war and an ear..."
How should the application.xml look like? How many jboss-app.xml files are needed? Where would the jboss-service.xml file go under?

Thanks in advance for your assistance.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 8142
    
  52

John,

Welcome to JavaRanch

How many jboss-app.xml files are needed?


One per EAR.

Where would the jboss-service.xml file go under?


Under the META-INF folder of the SAR.

Here's how i package my application:
<blockquote>code:
<pre name="code" class="core">
MyApp.ear
|
|
|--- META-INF
||
||--- application.xml
||
||--- jboss-app.xml
|
|
|--- MyApp.war
|
|
|--- MyAppEJB.jar
|
|
|--- lib
||--- MyOtherUtils.jar
|
|
|--- MyApp.sar
||
||--- META-INF
|||
|||--- jboss-service.xml

</pre>
</blockquote>

application.xml:
<blockquote>code:
<pre name="code" class="core">
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">
<application>
<display-name>MyApp</display-name>
<module>
<web>
<web-uri>MyApp.war</web-uri>
<context-root>/MyApp</context-root>
</web>
</module>
<module>
<ejb>MyAppEJB.jar</ejb>
</module>


</application>
</pre>
</blockquote>

jboss-app.xml:
<blockquote>code:
<pre name="code" class="core">
<jboss-app>

<module>
<service>MyApp.sar</service>
</module>

</jboss-app>
</pre>
</blockquote>


[My Blog] [JavaRanch Journal]
John Ozimits
Greenhorn

Joined: Jul 15, 2008
Posts: 2
Hi Jaikiran. Thank you very much for the prompt reply. I appreciate your help.

To be honest with you, that is what I thought the setup of the EAR should look like, but wasn't sure which is why I asked. I made my EAR look just like what you suggested. It fails to start with an exception that it can't find the sar module.

<blockquote>code:
<pre name="code" class="core">
09:59:11,123 ERROR [MainDeployer] Could not initialise deployment: file:/C:/jboss-4.2.2.GA/server/default/deploy/MyEar.ear
org.jboss.deployment.DeploymentException: Failed to find module file: MySar.sar
at org.jboss.deployment.EARDeployer.init(EARDeployer.java:295)
at org.jboss.deployment.MainDeployer.init(MainDeployer.java:872)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:809)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy9.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
at $Proxy0.start(Unknown Source)
at org.jboss.system.ServiceController.start(ServiceController.java:417)
at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy4.start(Unknown Source)
at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy5.deploy(Unknown Source)
at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
at org.jboss.Main.boot(Main.java:200)
at org.jboss.Main$1.run(Main.java:508)
at java.lang.Thread.run(Thread.java:619)
09:59:11,346 ERROR [URLDeploymentScanner] Incomplete Deployment listing:

--- Incompletely deployed packages ---
org.jboss.deployment.DeploymentInfo@d555dc67 { url=file:/C:/jboss-4.2.2.GA/server/default/deploy/MyEar.ear }
deployer: org.jboss.deployment.EARDeployer@11415c8
status: null
state: FAILED
watch: file:/C:/jboss-4.2.2.GA/server/default/deploy/MyEar.ear
altDD: null
lastDeployed: 1216216751122
lastModified: 1216216751011
mbeans:
</pre>
</blockquote>

Now, I played around with it for a bit and it seems like I can't get it to see the sar for some reason. I'm not doing anything special with anything I don't think.
I'm sure it's probably something stupid, but I just can't seem to find it.

Thanks again.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 8142
    
  52

Post the output of the following command (run it on the ear which is present in the deploy folder):

<blockquote>code:
<pre name="code" class="core">jar -tf MyEar.ear</pre>
</blockquote>
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: JBoss EAR structure
 
Similar Threads
JBoss Archive Files
How the Sar and War share a class file in ear?
How to deploy a sar or war to root in jboss?
Java Code not updating
Monitoring jboss