JayShenSharma has a nice blog at middlewaremagic.com where he outlines some nice tutorials about getting Weblogic up and running.
In the tutorial on EJB3 Local Lookup sample he provides all of the code necessary to get things up and running.
Here are a couple of steps to make the tutorial a little easier.
- Create a root folder and three sub-folders. There are some setup steps that need to be run – as detailed below.
- sfsb3 – is where we can place the two java source files, and into whcih the Test.jar file will be compiled.
- mwm39webapp – is where the jsp files will go. Underneath that, the WEB-INF is the location of the web.xml.
- mwm39ear will contain a “META-INF” folder inside of which will be an application.xml file.
This is outlined in the comments of the tutorial, however when you open up a command window at the root folder, you have to run a command to setup the appropriate environment.
For my setup (WebLogic 10.3.2) installed under windows, the command can be run as follows:
Following the tutorial
Creating the EJB jar file
* Change to the sfsb3 folder
Run the commands:
* compile the code:
<pre>javac -d . ReplicableSDSBean.java</pre>
<pre>javac -d . ReplicableSFSLocalIntf.java</pre>
These compile the source code into java class files. Note the fact that there is a “dot” in the midst of the commands. This will create a folder named sfsb3 – and place the class files into it.
<pre>jar -cvf Test.jar sfsb3 *.java</pre>
This creates a jar file – which will include all of the files in the sfsb3 folder, as well as all of the java files that are in the current directory.
The specifics of the command line are:
-c – create a new archive
– v – generate verbose output
-f – specify archive file name
The files name is “test.jar”. The files to include are
- Contenst of the sfsb3 folder
- All java files in the current folder.The jar command will also, within the jar file, create a META-INF folder – which contains a MANIFEST.MF file.
Creating the Web App
Change to the folder
It will have the 2 jsp files in the root directory, and the web.xml in the WEB-INF folder.
The command to run is
jar -cvf mwm39webapp.war .Please note the “dot” at the end.
This will create the Web Archive (WAR) file for the Web App. Note that it will include the WEB-INF folder and contents. This is because the file “dot” that was specified on the command line, is a directory – and the help
jar help specifies that “If any file is a directory then it is processed recursively.”
What we have at this point – is:
- Test.jar – an EJB Jar file in the sfsb3 directory
- mwm39webapp.war in the mwm39webapp directory
- a folder mwm39ear that has a META-INF folder with an
First thing is to correct the application.xml. The tutorial uses a
<web> <web-uri>WebApp1</web-uri> <context-root>WebApp1</context-root> </web>
however – we have compiled the war file to be mwm39webapp.war.
From the older Oracle documentation
Defines a Web application module in the application file. The web element contains a web-uri element and a context-root element.
Defines the location of a Web module in the application file. This is the name of the .war file.
Required. Specifies a context root for the Web application.
<web> <web-uri>petStore.war</web-uri> <context-root>estore</context-root> </web>
This means that we should use the war file name in the
The final version of application.xml is.
<web> <web-uri>mwm39webapp.war</web-uri> <context-root>mwm39webapp</context-root> </web>
Creating the EAR file
To simplify the concepts of creating the EAR file – create a new folder (e.g. genear). Place the Test.jar, WAR file (mwm39webapp.war) and the META-INF containing the application.xml into that folder.
From the command line, run the command:
<code>jav -cvf mwm39EAR.ear .<code>
Note again that this command ends in a “dot”.
This will create an EAR file that will contain the jar and war files in the root, and also contain the META-INF file.
This can be deployed directly to a WLS that is installed on the localhost.
The console for WLS is located at: http://localhost:7001/console
The URL for the initial page is at: http://localhost:7001/mwm39webapp
This is the equivalent of: http://localhost:7001/mwm39webapp/index.jsp
The output of the page is: