21
Thu, Nov
1 New Articles

TechTip: Explore and Leverage EJB3 on System i Now!

Java
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Have you noticed the ever-increasing buzz around the EJB3 specification? Personally, I am very excited that this new attempt to standardize the Java persistence programming model is gaining momentum. It seems that finally the J2EE architects got that part of the specification right. In previous versions, the EJB spec was so complex that many developers simply didn't have time to read and understand it. EJB3 and its core element, Java Persistence API (JPA), reestablish the sanity in the world of enterprise Java development.

EJB3 is not just a programming API. It is a new paradigm that rests on Plain Old Java Objects (POJOs), Java annotations, and the dependency injection design pattern. With EJB3, you can create well-performing, high-quality applications faster and at a lower cost. So, did you know that you can learn, explore, and implement this technology on System i? In this TechTip, I show you how to install and set up open-source application server JBoss on System i. I also cover the steps necessary to deploy the sample EJB3Trail application, which constitutes an excellent EJB3 tutorial.

Software Prerequisites

Although I could use the System i classic 64-bit JVM to install JBoss, I decided to leverage the powerful, new 32-bit IBM Technology for Java JVM, often called J9. The IBM J9 JVM is available on i5/OS V5R4M0 as 5722-JV1, Option 8, and is compliant with JSE Version 5. The sample application uses DB2 for i5/OS to persist data. For maximum server stability, I strongly recommend that you install the latest cumulative PTF (SF99540) and database group PTF (SF99504) on your System i machine. In addition, you need to load the PTF MF41385.

I downloaded the JBoss application server installer (jems-installer-1.2.0.GA) and the EJB3Trail sample application from the JBoss Web site. To take advantage of the EJB3 support, you must download the installer rather than the application server. You'll also need X-Windows-capable software—such as Hummingbird's Exceed or VNC—to properly render the installer's GUI on your workstation. This is needed only for the installation.

Installation

The installation process is pretty straightforward. I focus only on the steps that are specific to System i, such as integration with DB2 for i5/OS:

Step 1: Enable the J9 JVM

On System i, create in your IFS home directory (such as /home/Jarek) a file called .profile. You can use the EDTF command to edit this file. For example:

edtf '/home/jarek/.profile'

Add the following shell commands to the .profile file:

JAVA_HOME=/QOpenSys/QIBM/ProdData/JavaVM/jdk50/32bit  
export JAVA_HOME                                      

From an i5/OS command prompt, start QShell using the  STRQSH command. Verify that the J9 is enabled by typing the following command:

java –version

The JVM should produce messages similar to the ones shown below:

java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build jclap32dev)
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 OS400 ppc-32 j9vmap3223-20061001 (JIT enabled)
J9VM - 20060915_08260_bHdSMR
JIT  - 20060908_1811_r8
GC   - 20060906_AA)
JCL  - jclap32dev

Step 2: Set Up the TCP/IP Host Table Entries

Use the CFGTCP command, Option 10, to add LOCALHOST and IIOP as the aliases for the local machine. These aliases are used by the JBoss application server. For example:

Internet       Host
Address        Name
               
192.168.100.1  MYI5                
               MYI5.BSEISV.IBM.COM
127.0.0.1      LOOPBACK               
               LOCALHOST              
               IIOP                        

Step 3: Set Up the SQL Schema

Although this step is optional, I recommend that you create a separate DB2 schema (SQL collection) for the sample application. Using either the iSeries Navigator's Run SQL Script utility or the interactive SQL session, run the following SQL statement:

CREATE SCHEMA JBOSSDS

Step 4: Install JBoss Application Server

Copy the installer file jems-installer-1.2.0.jar to an IFS directory on System—for example, /opt.

Start the X-Windows server such as Exceed on your workstation.

From an i5/OS command prompt, start QShell and execute the following command to export the display to enable the connectivity to the X-Windows server now running on your workstation:

export DISPLAY=jarek.bseisv.ibm.com:0.0

Here, jarek.bseisv.ibm.com is the host name of the workstation. Use the host name appropriate for your network configuration. You can also use the IP address of the workstation in place of the host name.

Still in QShell, change the directory to /opt and type the following command:

java -jar jems-installer-1.2.0.GA.jar

The dialog shown in Figure 1 should appear on your workstation:

http://www.mcpressonline.com/articles/images/2002/Explore%20and%20Leverage%20EJB3%20on%20System%20i%20now!V300.png

Figure 1: The language selection dialog will appear. (Click images to enlarge.)

Click OK to continue. The Jems dialog appears. Click Next. The next dialog shows the JBoss Release Notes. Click Next. The License Agreement dialog is displayed. Read the agreement and click the radio button to accept it. Click Next. The dialog that appears allows you to change the installation path. Change it to /opt/jboss-4.0.5.GA as shown in Figure 2.

http://www.mcpressonline.com/articles/images/2002/Explore%20and%20Leverage%20EJB3%20on%20System%20i%20now!V301.png

Figure 2: Select the installation path.

Click Next to navigate to the dialog that allows you to specify the installation type. Make sure that you change the default to ejb3 as shown in Figure 3.

http://www.mcpressonline.com/articles/images/2002/Explore%20and%20Leverage%20EJB3%20on%20System%20i%20now!V302.png

Figure 3: Specify the installation type.

Click Next. On the next dialog, leave all the packs selected and click Next. The dialog that is shown now allows you to select either Standard or Advanced installation. Make sure to click the Advanced radio button. Move to the next dialog by clicking Next. Leave the configuration name as default and click Next.

Now, you've arrived at the DataSource Configuration dialog. Since the goal is to use DB2 as the data repository, click the Configure radio button and, from the Select Database pull-down box, choose DB2-400. This is illustrated in Figure 4.

http://www.mcpressonline.com/articles/images/2002/Explore%20and%20Leverage%20EJB3%20on%20System%20i%20now!V303.png

Figure 4: Configure DB2 for i5/OS as the DataSource.

The next dialog is DataSource Configuration. Since the application server will run natively on i5/OS, I recommend, for performance reasons, to use the native (Type 2) JDBC driver rather than the IBM Toolbox driver. Figure 5 shows the necessary changes to configure JBoss with the native driver.

http://www.mcpressonline.com/articles/images/2002/Explore%20and%20Leverage%20EJB3%20on%20System%20i%20now!V304.png

Figure 5: Configure the native DB2 for i5/OS JDBC driver.

Note that the Connection URL contains the reference to the SQL schema that you created in step 3. The Driver Class property points to the DB2Driver class contained in the native JDBC driver. The driver JAR does not need to be copied to the JBoss' lib directory. By default, it is on the JVM classpath, so JBoss will be able to locate and load it. Navigate to the JMS Security dialog by clicking Next twice. Set the password for the JBoss admin and click Next. The Installation Summary that appears lists all the components to be installed. Click Next to kick off the install process. The Installation Progress dialog is shown. When the installation is finished, click Next. Finally, on the last dialog, click Done.

You need to perform just one more small tweak to make the EJB3 component work correctly with DB2. Edit the persistence.properties file located in the /opt/jboss-4.0.5.GA/server/default/deploy/ejb3.deployer/META-INF directory. Find the following line in the properties file:

#hibernate.dialect=org.hibernate.dialect.HSQLDialect

Uncomment the property and change the dialect to DB2400Dialect. The modified line should look as shown below:

hibernate.dialect=org.hibernate.dialect.DB2400Dialect

Save the changes.

The JBoss 4.0.5 with EJB3 support is now installed and configured on your System i machine!

Running the Application Server

To run the application server, start the Qshell session and change the directory to /opt/jboss-4.0.5.GA/bin. Type the following command from the QShell prompt:

./run.sh &

Watch the messages produced by the JBoss run time. The last message should be similar to the following:

[Server] JBoss (MX MicroKernel) [4.0.5.GA (build: CVSTag=Branch_4_0 date=200610162339)] Started in 21s:747ms

To verify that the application server is working, open a browser on your workstation and use the following URL to connect to the JBoss instance on your System i:

http:// MYI5.BSEISV.IBM.COM:8080/

Note: Use your System i host name that you set up in step 2.

The "Welcome to JBoss" Web page should appear.

You can stop the server using the WRKACTJOB command. Find the batch immediate job named QP0ZSPWP with the function set to JVM-org.jboss. Use Option 4 to terminate the job.

A future TechTip will show you how to better integrate JBoss with i5/OS work management. I'll cover topics such as creating the JBoss' own subsystem, creating separate memory pools for the JBoss runtime, creating separate memory pools for the database server jobs, and more....

Deploying the EJB3Trail Sample Application

To deploy the sample application, copy the EJB3Trail.ear file to the following directory on System i:

/opt/jboss-4.0.5.GA/server/default/deploy

That's all it takes! Now you can run the application by pointing your browser to the following URL:

http:// MYI5.BSEISV.IBM.COM:8080/EJB3Trail

The following page appears in your browser:

http://www.mcpressonline.com/articles/images/2002/Explore%20and%20Leverage%20EJB3%20on%20System%20i%20now!V305.png

Figure 6: This is the EJB3 Trailblazer sample application.

Start exploring EJB3 by following the tutorial.

Alternatives

I realize that a lot of System i customers use WebSphere as the J2EE-compliant application server. If you are one of them, I have good news to report. You can explore EJB3 via an early release of the EJB3.0 Feature Pack (FEP), which is currently available in alpha. The EJB3 FEP will move to beta and finally will receive production support for EJB3 when it goes to GA later this year.

Additional Material

The JBoss installer and the sample application can be downloaded from the following URL: http://www.jboss.com/products/index

The IBM Technology for Java Virtual Machine in IBM i5/OS ITSO Redbook can be helpful to those who want to learn more about the IBM J9 JVM.

Jarek Miszczyk is the Senior Software Engineer, ISV Solutions Enablement, IBM Rochester. He can be reached by email at This email address is being protected from spambots. You need JavaScript enabled to view it..

Jarek Miszczyk

Jarek Miszczyk is a Lead Technical Consultant for System x Virtualization and Cloud Computing at the IBM STG Global ISV Enablement organization. He is located in Rochester, Minnesota. He can be reached by email at This email address is being protected from spambots. You need JavaScript enabled to view it..

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: