× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



My guess is you need additional classes in your classpath.

   If on v5r1 or later use Toolbox classes from
   /qibm/proddata/os400/jt400/lib/jt400Native.jar

   If on v4r5 or ealier use jt400.jar plus
   /qibm/proddata/java400/jt400ntv.jar

David Wall
Toolbox for Java
iSeries ODBC Driver for Linux




                      "Murphy, Guy"
                      <murphy@uif.uilli        To:       java400-l@midrange.com
                      nois.edu>                cc:
                      Sent by:                 Subject:  Java Program calling 
RPG failure
                      java400-l-admin@m
                      idrange.com


                      06/05/2002 10:32
                      AM
                      Please respond to
                      java400-l





This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
--
[ Picked text/plain from multipart/alternative ]



             One of our programmers is trying to call an RPG program from a
Java
servlet.  The code uses the ProgramCall class and it's straight from the
InfoCenter code.  My knowledge of Java is not sufficient (yet) to be of any
help.  According to the documentation we do not need a user profile and
password but the errors in the strerr.txt file seems to indicate that we
do.
I've included the Java code and the contents of strerr.txt and strout.txt.
             Any help is really appreciated.  I apologize for the length of
the
e-mail

Java Code

package org.uiaa.www.alumnidirectory;

import javax.servlet.*;
import javax.servlet.http.*;
import com.ibm.as400.access.*;
import com.ibm.as400.access.AS400;
import java.io.*;
import java.sql.*;
import java.util.*;
import java.text.*;

public class LoginServlet extends HttpServlet {

             DatabaseAccessBean databaseAccessBean = new
DatabaseAccessBean("jdbc/Facts");

             public void doGet(HttpServletRequest request,
HttpServletResponse
response) {
                         performTask(request, response);
             }
             public void doPost(HttpServletRequest request,
HttpServletResponse
response) {
                         performTask(request, response);
             }
             public void performTask(HttpServletRequest request,
HttpServletResponse response) {

                         //     Uncomment the following line to aid in
debugging DB
servlets.
                         //     This can help isolate problems when the
servlet
appears to be unable to make
                         //     a connection to the database. You must
recompile,
republish, and then shutdown and
                         //     restart the server for this change to take
effect.
                         //
java.sql.DriverManager.setLogStream(System.out);

                         // Get userID and password from form.
                         String userID = request.getParameter("userID");
                         String password = request.getParameter
("password");
                         String returnStr = new String();

                         try {
                                     UserInfoBean userInfoBean = new
UserInfoBean();

                                     try {

                                                 ResultSet rs =
databaseAccessBean.executeQuery("SELECT ALEMAIL, ALMSTID, ALFNAME, ALLNAME,
ALISMBR FROM AW@LIB2.AW@P110 WHERE ALLOGIN = '" + userID + "'AND ALPWD = '"
+ password + "'");

                                                 if (rs.next()) {
                                                             // Persist
basic user info

userInfoBean.setEmail(rs.getString("ALEMAIL").trim());

userInfoBean.setUserMSTID(rs.getInt("ALMSTID"));

userInfoBean.setFirstName(rs.getString("ALFNAME").trim());

userInfoBean.setLastName(rs.getString("ALLNAME").trim());

userInfoBean.setUserMEM(rs.getString("ALISMBR"));

                                                             // Call RPG
program to write record
to AW@P130
                                                             //
AS400 system = new AS400("localhost", "*CURRENT", "*CURRENT");
                                                             AS400 system
= new AS400("REALITY");

System.out.println("Line 1");
                                                             ProgramCall
program = new
ProgramCall(system);

System.out.println("Line 2");
                                                             try {
                                                                         //
Initialize the name of
the program to run.

String programName =
"/QSYS.LIB/AACGITST.LIB/AW@R130.PGM";

System.out.println("Line
3");
                                                                         //
Set up the 1 parameter.

ProgramParameter[]
parameterList = new ProgramParameter[1];

System.out.println("Line
4");
                                                                         //
Parameter is to input a
mstid.

AS400PackedDecimal parameter
= new AS400PackedDecimal(9, 0);

System.out.println("Line
5");

parameterList[0] = new
ProgramParameter(parameter.toBytes(rs.getBigDecimal("ALMSTID")));

System.out.println("Line
6");
                                                                         //
Set the program name and
parameter list.

program.setProgram(programName, parameterList);

System.out.println("Line
7");
                                                                         //
Run the program.
                                                                         if
(program.run() != true) {

       // Report failure.

System.out.println("Program failed!");

       // Show the
messages.

       AS400Message[]
messagelist = program.getMessageList();

       for (int i = 0; i <
messagelist.length; ++i) {

                   // Show each
message.

System.out.println(messagelist[i]);

       }
                                                                         }
                                                             } catch
(Exception e) {

System.out.println("Program
" + program.getProgram() + " did not run!  " + new java.util.Date());

e.printStackTrace();
                                                             }
                                                             // Done with
the system.

system.disconnectAllServices();
                                                             returnStr
= "/Options.jsp";
                                                 } else {
                                                             returnStr
= "/Login_Error.jsp";
                                                 }
                                     } catch (Exception e) {
                                                 e.printStackTrace();
                                     } finally {

databaseAccessBean.closeConnection();
                                     }

                                     if (returnStr.equals("/Options.jsp"))
{
                                                 try {
                                                             Calendar now
= new
GregorianCalendar();
                                                             java.util.Date
date = now.getTime();
                                                             DateFormat fm1
= new
SimpleDateFormat("yyyy-MM-dd-HH.mm.ss");
                                                             String StrDate
= fm1.format(date);

                                                             String
ChangePWD = "update
AW@LIB2.aw@p110 set alusgtd = '" + StrDate + "' where almstid = " +
userInfoBean.getUserMSTID();

                                                             int status =
databaseAccessBean.executeUpdate(ChangePWD);

                                                             if (status ==
1) {

returnStr = "/Options.jsp";
                                                             } else {

returnStr =
"/Login_Error.jsp";
                                                             }
                                                 } catch (Exception e) {

e.printStackTrace();
                                                 } finally {

databaseAccessBean.closeConnection();
                                                 }

                                                 // Get or create a
session.
                                                 HttpSession session =
request.getSession(true);

                                                 // Place the user info
bean in the session.
                                                 session.setAttribute
("userInfoBean",
userInfoBean);
                                     }
                                     response.sendRedirect(returnStr);

                         } catch (Exception e) {
                                     e.printStackTrace();
                         } finally {
                                     databaseAccessBean.closeConnection();
                         }
             }
}

STDERR.TXT

java.io.IOException
      com/ibm/as400/access/SocketContainerUnix.getSubstPassword([B[B)[B+8
(SocketContainerUnix.java:97)
      com/ibm/as400/access/AS400ImplRemote.getPassword([B[B)[B+34
(AS400ImplRemote.java:909)

com/ibm/as400/access/AS400ImplRemote.getConnection(IZ)Lcom/ibm/as400/access/

AS400Server;+252 (AS400ImplRemote.java:850)
      com/ibm/as400/access/RemoteCommandImplRemote.open(Z)V+5
(RemoteCommandImplRemote.java:211)

com/ibm/as400/access/RemoteCommandImplRemote.runProgram(Ljava/lang/String;Lj

ava/lang/String;[Lcom/ibm/as400/access/ProgramParameter;Z)Z+32
(RemoteCommandImplRemote.java:352)

com/ibm/as400/access/RemoteCommandImplNative.runProgram(Ljava/lang/String;Lj

ava/lang/String;[Lcom/ibm/as400/access/ProgramParameter;Z)Z+17
(RemoteCommandImplNative.java:473)
      com/ibm/as400/access/ProgramCall.run()Z+148 (ProgramCall.java:563)

org/uiaa/www/alumnidirectory/LoginServlet.performTask(Ljavax/servlet/http/Ht

tpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V+0
(LoginServlet.java:31)

org/uiaa/www/alumnidirectory/LoginServlet.doPost(Ljavax/servlet/http/HttpSer

vletRequest;Ljavax/servlet/http/HttpServletResponse;)V+0
(LoginServlet.java:20)

javax/servlet/http/HttpServlet.service(Ljavax/servlet/http/HttpServletReques

t;Ljavax/servlet/http/HttpServletResponse;)V+136 (HttpServlet.java:760)

javax/servlet/http/HttpServlet.service(Ljavax/servlet/ServletRequest;Ljavax/

servlet/ServletResponse;)V+25 (HttpServlet.java:853)

com/ibm/servlet/engine/webapp/StrictServletInstance.doService(Ljavax/servlet

/ServletRequest;Ljavax/servlet/ServletResponse;)V+21
(ServletManager.java:644)

com/ibm/servlet/engine/webapp/StrictLifecycleServlet.
_service(Ljavax/servlet
/ServletRequest;Ljavax/servlet/ServletResponse;)V+46
(StrictLifecycleServlet.java:160)

com/ibm/servlet/engine/webapp/ServletInstance.service(Ljavax/servlet/Servlet

Request;Ljavax/servlet/ServletResponse;Lcom/ibm/servlet/engine/webapp/WebApp

ServletInvocationEvent;)V+186 (ServletManager.java:371)

com/ibm/servlet/engine/webapp/WebAppRequestDispatcher.handleWebAppDispatch(L

com/ibm/servlet/engine/webapp/WebAppRequest;Ljavax/servlet/http/HttpServletR

esponse;Z)V+993 (WebAppRequestDispatcher.java:632)

com/ibm/servlet/engine/webapp/WebAppRequestDispatcher.dispatch(Ljavax/servle

t/ServletRequest;Ljavax/servlet/ServletResponse;Z)V+443
(WebAppRequestDispatcher.java:290)

com/ibm/servlet/engine/webapp/WebAppRequestDispatcher.forward(Ljavax/servlet

/ServletRequest;Ljavax/servlet/ServletResponse;)V+258
(WebAppRequestDispatcher.java:189)

com/ibm/servlet/engine/srt/WebAppInvoker.doForward(Ljavax/servlet/http/HttpS

ervletRequest;Ljavax/servlet/http/HttpServletResponse;)V+4
(WebAppInvoker.java:61)

com/ibm/servlet/engine/srt/WebAppInvoker.handleInvocationHook(Ljava/lang/Obj

ect;)V+130 (WebAppInvoker.java:133)

com/ibm/servlet/engine/invocation/CachedInvocation.handleInvocation(Ljava/la

ng/Object;)V+25 (CachedInvocation.java:67)

com/ibm/servlet/engine/srp/ServletRequestProcessor.dispatchByURI(Ljava/lang/

String;Lcom/ibm/servlet/engine/srp/ISRPConnection;)V+839
(ServletRequestProcessor.java:155)

com/ibm/servlet/engine/oselistener/OSEListenerDispatcher.service(Lcom/ibm/se

rvlet/engine/oselistener/api/IOSEConnection;)V+95 (OSEListener.java:300)

com/ibm/servlet/engine/oselistener/SQEventListenerImp$ServiceRunnable.run
()V
+155 (SQEventListenerImp.java:230)

com/ibm/servlet/engine/oselistener/SQEventListenerImp.notifySQEvent(Lcom/ibm

/servlet/engine/oselistener/api/ISQEvent;)V+184
(SQEventListenerImp.java:104)

com/ibm/servlet/engine/oselistener/serverqueue/SQEventSource.notifyEvent(Lco

m/ibm/servlet/engine/oselistener/api/SQEventImp;)V+40
(SQEventSource.java:216)

com/ibm/servlet/engine/oselistener/serverqueue/SQWrapperEventSource$SelectRu

nnable.notifyService()V+116 (SQWrapperEventSource.java:354)

com/ibm/servlet/engine/oselistener/serverqueue/SQWrapperEventSource$SelectRu

nnable.run()V+124 (SQWrapperEventSource.java:221)

com/ibm/servlet/engine/oselistener/outofproc/OutOfProcThread$CtlRunnable.run

()V+104 (OutOfProcThread.java:248)
      java/lang/Thread.run()V+11 (Thread.java:479)

STROUT.TXT

Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Program /QSYS.LIB/AACGITST.LIB/AW@R130.PGM did not run!  Wed Jun 05
15:05:01
GMT+00:00 2002

Guy Murphy
murphyfa@uiuc.edu
UDIS at the University of Illinois
217-333-8670
http://www.heisercoaching.com

_______________________________________________
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
mailing list
To post a message email: JAVA400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l
or email: JAVA400-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.








As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.