?
Solved

JSP -> JavaBean -> PCML -> RPG

Posted on 2003-03-27
11
Medium Priority
?
1,672 Views
Last Modified: 2012-08-13
Based on the title of the question i think you guys also agree that I have no ideas where should i post this question in. :-)

Anyway, since this JSP sites which I think the respond time is tremendous, and also it's involve more on JSP tech, so i prefer post it here. Hope you guys would dissapointed me.

Before we start, have a look on this pdf files.
www.ignite400.org/news/pdf/news2002040104.pdf 

This pdf files is the base file that I refering. The main purpose for me to do this is to call my RPG program using JavaBean and JSP technology.

This is the few steps that I have done successfully.

1. Create a PCML (Program Call Markup Language)

<pcml version="1.0">
<program name="JFOONG" path="/QSYS.LIB/LMLIB/LIB/JFOONG.PGM">
<data name="name" type="char" usage="input" />
<data name="division" type="char" usage="input" />
</program>
</pcml>

2. Create a RPG program (This one you must trust me that it's running fine.  because i have tested it in the AS400 command line.)

3. Code my JavaBean and compiled it. And I got zero error or exception.

/**
* Testing Java call RPG program.
* Creation date: (11/13/2001 11:35:27 AM)
* @author: James Zhang
*/

import com.ibm.as400.data.*;
import com.ibm.as400.access.*;
import java.lang.*;
import java.io.*;
import java.util.*;

public class testjava {

/**
* TestCallRpg constructor.
*/

public testjava() { }

/**
* This program is written as an application
* to easily demonstrate calling an RPG program
* and run the program from your development environment.
*/
public void header() {

/* Create a connection the iSeries where the program you wish to call
resides */
      AS400 sys = new AS400("AS400_name","username","password");
      if(sys == null){
            System.out.println("Connection failed");
            System.exit(1);
      } else {
            System.out.println("Manage to connect to AS400");
      }
      
      
      ProgramCallDocument pcml;
      try{
            pcml = new ProgramCallDocument(sys, "Test"); // open the PCML File
            // set all the input parameters for program alias DateCalc
            pcml.setValue("JFOONG.name", "FOONG");
            pcml.setValue("JFOONG.division", "FP");
            // call the program
            boolean rc = pcml.callProgram("JFOONG");
            if(rc == false){
                  System.out.println("Program failed");
            }else{
                  System.out.println("Program OK");
            }
      }catch(PcmlException pe){
            System.out.println(" Caught Exception ");
            pe.printStackTrace();
            }finally{
                  System.exit(0);
                  }      

      }

}

4. Code my JSP page to call this JavaBean.

<%@ page language="java" import="java.sql.*, java.io.*, java.util.*, com.wrox.cars.* "
%>
<jsp:useBean id="person" class="com.wrox.cars.testjava" />
<html>
 
<body>
<%
person.header();
%>
</body>
</html>

5. Make sure that my IBM WebSphere Application class path will include in my com.ibm.as400 JAR file.

* Done!!

6. Open a browser and call the page, error come out.
Root Error-1:
java.lang.NoClassDefFoundError
     java/lang/Throwable.<init>()V+4 (Throwable.java:82)
     java/lang/LinkageError.<init>()V+1 (LinkageError.java:33)
     java/lang/NoClassDefFoundError.<init>()V+1 (NoClassDefFoundError.java:37)
java/lang/ClassLoader.defineClass(Ljava/lang/String;[BII)Ljava/lang/Class;+1 (ClassLoader.java:424)
com/ibm/servlet/classloader/DynamicClassLoader.loadNonSystemClass(Ljava/lang/String;)Ljava/lang/Class;+381


Wrapped Error-2:
javax.servlet.ServletException
     java/lang/Throwable.<init>(Ljava/lang/String;)V+4 (Throwable.java:94)
     java/lang/Exception.<init>(Ljava/lang/String;)V+1 (Exception.java:42)
     javax/servlet/ServletException.<init>(Ljava/lang/Throwable;)V+5 (ServletException.java:161)


Wrapped Error-3: Server caught unhandled exception from servlet [jsp10]: null
com.ibm.servlet.engine.webapp.UncaughtServletException: Server caught unhandled exception from servlet [jsp10]: null
     java/lang/Throwable.(Ljava/lang/String;)V+4 (Throwable.java:94)
     java/lang/Exception.(Ljava/lang/String;)V+1 (Exception.java:42)
javax/servlet/ServletException.(Ljava/lang/String;Ljava/lang/Throwable;)V+1 (ServletException


*********************************
*********************************

Friends, this is all what I hope you can help. ANy comments, any brainstorming is appreciated.

And let me share my experience in troubleshooting this. At first, i thougt it maybe because some of the java library i didn't add it. So i have tried to add in all the possible library in. Second, I have remark off all the important code in my javaBean (suspected is in JavaBean).  Yet, this error code still in.

..........

Thank you for reading it.......

0
Comment
Question by:xman19
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 

Author Comment

by:xman19
ID: 8217338
Guys, my apology.

I know the errors... after I tested one by one.

The Java Bean, forget this,

packages com.wrox.cars.

:-)

But I am having another problem....

//This is the error log from AS400 File system
Manage to connect to AS400                                                                                                
[03.03.27 12:38:32:028 GMT+00:00] 9e93f864 SecurityManag A SECJ0021I: Illegal System exit() : java.lang.SecurityException
      java/lang/Throwable.<init>()V+4 (Throwable.java:82)                                                                

And ths is the problem  that caused by the browser..

Root Error-1:
java.lang.SecurityException
     java/lang/Throwable.<init>()V+4 (Throwable.java:82)
     java/lang/Exception.<init>()V+1 (Exception.java:33)


So, I am looking into it. Maybe youcan conrtibute some brain Storming....
`
0
 
LVL 14

Accepted Solution

by:
kennethxu earned 1860 total points
ID: 8218863
do you have some code that when error occur you calls System.exit() ? the application server will not allow your application to do this, because this will bring the entire application server down. So the application throw you SecurityExcetion when it sees System.exit() in your web applicaiton code.

please also post full stacktrace of the error you get, it helps us to determine the problem.
0
 

Author Comment

by:xman19
ID: 8221922
ken, since I am rushing to make this program done, thus I have temporary rem off the System.exit() statement.

But I am facing another problem. It's complainting couldn't find the PCML files that I coded....

:-((((

And I have no experience in this PCML and where should it stored.

Any ideas?? I put it in the CLASSPATH of my App Server's classpath.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 14

Expert Comment

by:kennethxu
ID: 8222008
not sure what is PCML. can you post the full stacktrace of the exception?
0
 

Author Comment

by:xman19
ID: 8223941
ken this is the stackTrace,

                                                                                         
 java.util.MissingResourceException: PCML document source 'JFOONG' cannot be found.      
       java/lang/Throwable.<init>(Ljava/lang/String;)V+4 (Throwable.java:94)              
       java/lang/Exception.<init>(Ljava/lang/String;)V+1 (Exception.java:42)              
       java/lang/RuntimeException.<init>(Ljava/lang/String;)V+1 (RuntimeException.java:47)
       java/util/MissingResourceException.<init>(Ljava/lang/String;Ljava/lang/String;Ljava
       com/ibm/as400/data/SystemResourceFinder.getPCMLDocument(Ljava/lang/String;Ljava/lan
       com/ibm/as400/data/PcmlSAXParser.<init>(Ljava/lang/String;Ljava/lang/ClassLoader;)V
       com/ibm/as400/data/ProgramCallDocument.loadSourcePcmlDocument(Ljava/lang/String;Lja
       com/ibm/as400/data/ProgramCallDocument.loadPcmlDocument(Ljava/lang/String;Ljava/lan
       com/ibm/as400/data/ProgramCallDocument.<init>(Lcom/ibm/as400/access/AS400;Ljava/lan
       com/wrox/cars/testjava.call()V+0 (testjava.java:44)                                

 java.util.MissingResourceException: PCML document source 'JFOONG' cannot be found.
       java/lang/Throwable.<init>(Ljava/lang/String;)V+4 (Throwable.java:94)      
       java/lang/Exception.<init>(Ljava/lang/String;)V+1 (Exception.java:42)    


Can not find the PCML files right?
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 8225401
seems that way.. do you have the path right.  Can you output where it is looking for the files?

CJ
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8225822
can you post the line testjava.java:44
it says JFOONG is not found, where did you put this file? it should be named as JFOONG.pcml, and the directory should be in classpath.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8225901
0
 

Author Comment

by:xman19
ID: 8250786
kennethxu, still couldn't locate my PCML files.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8256222
can you show me the testjava.java?
you should create JFOONG.pcml file and place in under a dir which is in classpath.
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 8612967
Hi,
this this is quite a old post, I am not sure if you already finished with it or not.
You should be putting your PCML file at the same location where your bean resides. i.e. if you have jared your bean than your PCML file should also be avialble in the jar file and that too with the same directory structure as your bean package name.

Regards
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Check out the latest tech news, community articles, and expert highlights in August's newsletter.
The top devops trends for 2017 are focused on improved deployment frequency, decreased lead time for change and decreased MTTR.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question