× 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.



While editing an RPG source member pull up the context menu in the editor area and select New => Java Method Call ... the wizard will prompt you for the rest.

You can also get there from Source => New => Java Method Call ...


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Jan 9, 2017, at 2:54 PM, Don Brown <DBrown@xxxxxxxxxx> wrote:



Thanks Jon

No I did not use the wizard.

I have not used that wizard before and not sure how to?

Could you advise where to find or what to search on?

Thank you

Sent from my iPhone

On 10 Jan. 2017, at 01:21, Jon Paris <jon.paris@xxxxxxxxxxxxxx> wrote:

Glad it helped Dan - I'm afraid I don't have time to dig deeper right
now.

You didn't answer the question as to how you derived the prototypes. Did
you use the RDi wizard? If not, I would suggest trying that and comparing
the results with what you have - it has to be something relatively trivial.


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Jan 8, 2017, at 6:18 PM, Don Brown <DBrown@xxxxxxxxxx> wrote:

Thanks Jon.

I think you may have identified where this is failing.

The code that is attempting to retrieve the results of the search is
not
returning anything although it does not generate an error.

resultJ = search(transGatewayJ: transReqJ);

I believe my problem is working out how to call what seems to be a
complex
method.

If we look at the signature for that method we have;

public com.braintreegateway.DateRangeNode authorizedAt();
Signature: ()Lcom/braintreegateway/DateRangeNode;

The prototypes for this are;

D transReqC PR O ExtProc(*JAVA:
D 'com.braintreegateway.-
D TransactionSearchRequest':
D *CONSTRUCTOR)

D dateParams PR O ExtProc(*JAVA:
D 'com.braintreegateway.-
D TransactionSearchRequest':
D 'authorizedAt')
D
Class(*JAVA:'com.braintreegateway.-
D DateRangeNode')

D setRange PR O ExtProc(*JAVA:
D 'com.braintreegateway.-
D DateRangeNode':
D 'between')
D
Class(*JAVA:'com.braintreegateway.-
D SearchRequest')
D start O
Class(*JAVA:'java.util.Calendar')
D end O
Class(*JAVA:'java.util.Calendar')

D transGateway PR O ExtProc(*JAVA:
D 'com.braintreegateway.-
D BraintreeGateway':
D 'transaction')
D
Class(*JAVA:'com.braintreegateway.-
D TransactionGateway')


D transreqJ S O
Class(*JAVA:'com.braintreegateway.-
D TransactionSearchRequest')

D dateparamsJ S O
Class(*JAVA:'com.braintreegateway.-
D DateRangeNode')

D transgatewayJ S O Class(*JAVA:
D 'com.braintreegateway.-
D TransactionGateway')

transReqJ = transReqC();
dateParamsJ = dateParams(transReqJ);
transreqJ = setRange(dateParamsJ: startJ: endJ);
transGatewayJ = transGateway(gateway);

// Retrieve the transactions

resultJ = search(transGatewayJ: transReqJ);

The java line of code that does this is;

TransactionSearchRequest request = new
TransactionSearchRequest().authorizedAt().between(start, end);

Here is the full java test program that does retrieve a transaction ...

package test;

import java.util.Calendar;
import java.util.List;

import com.braintreegateway.BraintreeGateway;
import com.braintreegateway.Environment;
import com.braintreegateway.ResourceCollection;
import com.braintreegateway.Transaction;
import com.braintreegateway.TransactionGateway;
import com.braintreegateway.TransactionSearchRequest;
import com.braintreegateway.exceptions.AuthenticationException;

public class BraintreeClient {

public BraintreeClient() {
// System.out.println("Obtain client token from
Braintree
...");
// String clientToken = gateway.clientToken().generate
();
// System.out.println("Client Token received:
"+clientToken);
try {
BraintreeGateway gateway = new
BraintreeGateway(Environment.SANDBOX, "hvcftg4259dkhjx8",
"pf5dy7b252n3hxhz",
"55e295ac1d16137f6ae6a2b267be3de3");
System.out.println(gateway.getConfiguration().getMerchantPath());
Calendar start = Calendar.getInstance();
start.set(Calendar.DATE, 3);
start.set(Calendar.MONTH, 0);
start.set(Calendar.YEAR, 2017);
start.set(Calendar.HOUR, 0);
start.set(Calendar.MINUTE, 0);
start.set(Calendar.SECOND, 0);
start.set(Calendar.MILLISECOND, 0);
System.out.println("start = " + start.getTime
());
Calendar end = Calendar.getInstance();
end.set(Calendar.DATE, 5);
end.set(Calendar.HOUR, 23);
System.out.println("end = " + end.getTime());
TransactionSearchRequest request = new
TransactionSearchRequest().authorizedAt().between(start, end);
ResourceCollection<Transaction> collection =
gateway.transaction().search(request);
TransactionGateway tg = gateway.transaction();
// getFirst
Transaction t = collection.getFirst();
System.out.println("First Transaction: id =
"+t.getId()+", amount = "+t.getAmount());
} catch (AuthenticationException e) {
e.printStackTrace();
}
}

public static void main(String[] args) {
new BraintreeClient();
}

}

When run the following is the output ...

/merchants/hvcftg4259dkhjx8
start = Tue Jan 03 00:00:00 EST 2017
end = Thu Jan 05 23:08:59 EST 2017
Jan 09, 2017 7:09:00 AM com.braintreegateway.util.Http httpRequest
INFO: [Braintree] [9/Jan/2017 07:09:00 +1000]] POST
/merchants/hvcftg4259dkhjx8/transactions/advanced_search_ids
Jan 09, 2017 7:09:01 AM com.braintreegateway.util.Http httpRequest
INFO: [Braintree] [9/Jan/2017 07:09:01 +1000]] POST
/merchants/hvcftg4259dkhjx8/transactions/advanced_search
First Transaction: id = 787kawhf, amount = 200.00


The full source code is below ...

H DftActGrp(*no) Thread(*serialize) DATEDIT(*YMD)

D/SPACE 3
D****************************************************************
D* PROGRAM-STATUS DATA STRUCTURE
D* SDSPGM - PROGRAM NAME
D* SDSPSD - PROGRAM STATUS CODE WHEN ERROR OCCURRED
D* SDSRTN - RPG ROUTINE WHERE ERROR OCCURRED
D* SDSWS - WORKSTATION ID
D* SDSUSR - USER PROFILE
D****************************************************************
D SDS SDS 429
D SDSPGM *PROC
D SDSPSD *STATUS
D SDSRTN *ROUTINE
D SDSPRM *PARMS
D SDSWS 244 253
D SDSUSR 254 263

D****************************************************************
D* Definition of Gateway Java Class
D****************************************************************
D gatewayC PR O ExtProc(*JAVA:
D 'com.braintreegateway.-
D BraintreeGateway':
D *CONSTRUCTOR)
D env O CLASS
(*JAVA:'java.lang.String')
CONST
D merId O CLASS
(*JAVA:'java.lang.String')
CONST
D privKey O CLASS
(*JAVA:'java.lang.String')
CONST
D pubKey O CLASS
(*JAVA:'java.lang.String')
CONST
D*
D getConfig PR O ExtProc(*JAVA:
D 'com.braintreegateway.-
D BraintreeGateway':
D 'getConfiguration')
D
Class(*JAVA:'com.braintreegateway.-
D Configuration')
D*
D calendarC PR O ExtProc(*JAVA:
D
'java.util.Calendar':'getInstance')
D
Class(*JAVA:'java.util.Calendar')
D STATIC
D*
D setVal PR ExtProc(*JAVA:
D 'java.util.Calendar':
D 'set')
D field 10I 0 VALUE
D value 10I 0 VALUE
D*
D transReqC PR O ExtProc(*JAVA:
D 'com.braintreegateway.-
D TransactionSearchRequest':
D *CONSTRUCTOR)
D*
D getPath PR O ExtProc(*JAVA:
D
'com.braintreegateway.Configuration':
D 'getMerchantPath')
D Class
(*JAVA:'java.lang.String')
D*
D dateParams PR O ExtProc(*JAVA:
D 'com.braintreegateway.-
D TransactionSearchRequest':
D 'authorizedAt')
D
Class(*JAVA:'com.braintreegateway.-
D DateRangeNode')
D*
D setRange PR O ExtProc(*JAVA:
D 'com.braintreegateway.-
D DateRangeNode':
D 'between')
D
Class(*JAVA:'com.braintreegateway.-
D SearchRequest')
D start O
Class(*JAVA:'java.util.Calendar')
D end O
Class(*JAVA:'java.util.Calendar')
D*
D transGateway PR O ExtProc(*JAVA:
D 'com.braintreegateway.-
D BraintreeGateway':
D 'transaction')
D
Class(*JAVA:'com.braintreegateway.-
D TransactionGateway')
D*
D search PR O ExtProc(*JAVA:
D 'com.braintreegateway.-
D TransactionGateway':
D 'search')
D
Class(*JAVA:'com.braintreegateway.-
D ResourceCollection')
D O
Class(*JAVA:'com.braintreegateway.-
D TransactionSearchRequest')
D*
D makestring PR O EXTPROC(*JAVA:
D 'java.lang.String':
D *CONSTRUCTOR)
D bytes 30A CONST VARYING
D*
D getId PR O ExtProc(*JAVA:
D
'com.braintreegateway.Transaction':
D 'getId')
D Class
(*JAVA:'java.lang.String')
D*
D getAmount PR O ExtProc(*JAVA:
D
'com.braintreegateway.Transaction':
D 'getAmount')
D Class
(*JAVA:'java.lang.String')
D*
D getFirst PR O ExtProc(*JAVA:
D 'com.braintreegateway.-
D
ResourceCollection':'getFirst')
D Class
(*JAVA:'java.lang.Object')
D*
D getIds PR O ExtProc(*JAVA:
D 'com.braintreegateway.-
D ResourceCollection':'getIds')
D*** Class(*java:'com.braintreegateway.-
D*** ResourceCollection')
D Class(*JAVA:'java.util.List')
D*
D get pr o class(*java :
'java.lang.Object')
D extproc(*java
D : 'java.util.List'
D : 'get')
D index 10i 0 value
D*
D newString pr o extproc(*java
D : 'java.lang.String'
D : *constructor)
D value 25a const varying
D*
D stringC PR O ExtProc(*JAVA:
D 'java.lang.String':
D *CONSTRUCTOR)
D 120A Const Varying
D*
D getBytes PR 40A ExtProc(*JAVA:
D 'java.lang.String':
D 'getBytes') Varying
*
D getBytesLong PR 120A ExtProc(*JAVA:
D 'java.lang.String':
D 'getBytes') Varying
*
D gateway S O Class(*JAVA:
D 'com.braintreegateway.-
D BraintreeGateway')
*
D transgatewayJ S O Class(*JAVA:
D 'com.braintreegateway.-
D TransactionGateway')
*
* display message without reply
*
D debugMessage PR
D PRMDBG 1 CONST
D PRMMSG 51 CONST
*
* display message with reply
*
D debugMessage2 PR 2
D PRMDBG 1 CONST
D PRMMSG 50 CONST
D PRMRTN S 2
*
D envJ S O Class
(*JAVA:'java.lang.String')
D env S 40A
D meridJ S O Class
(*JAVA:'java.lang.String')
D merid S 40A
D privKeyJ S O Class
(*JAVA:'java.lang.String')
D privKey S 40A
D pubKeyJ S O Class
(*JAVA:'java.lang.String')
D pubKey S 40A
D configJ S O
Class(*JAVA:'com.braintreegateway.-
D Configuration')
D config S 40A
D pathJ S O Class
(*JAVA:'java.lang.String')
D path S 40A
D dateparamsJ S O
Class(*JAVA:'com.braintreegateway.-
D DateRangeNode')
D dateparamsX S 40A
D startJ S O
Class(*JAVA:'java.util.Calendar')
D start S 40A
D endJ S O
Class(*JAVA:'java.util.Calendar')
D end S 40A
D transreqJ S O
Class(*JAVA:'com.braintreegateway.-
D TransactionSearchRequest')
D transactionJ S O Class
(*JAVA:'java.lang.Object')
D resultJ S O
Class(*JAVA:'com.braintreegateway.-
D ResourceCollection')
D transJ S O
Class(*JAVA:'com.braintreegateway.-
D Transaction')


/free

exsr test01;

*inlr = *on;

begsr test01;

//***************************//
// Authentication credential //
//***************************//
envJ = makestring('sandbox');
merIdJ = makestring('hvcftg4259dkhjx8');
privKeyJ = makestring('pf5dy7b252n3hxhz');
pubKeyJ = makestring('55e295ac1d16137f6ae6a2b267be3de3');

//***************************//
// Setup sdtart and End dates//
//***************************//
startJ = calendarC();
setVal(startJ: 5: 1); // day
setVal(startJ: 2: 0); // month
setVal(startJ: 1: 2017); // year
setVal(StartJ: 10: 0); // hour
setVal(startJ: 12: 0); // minute
setVal(startJ: 13: 0); // second
setVal(startJ: 14: 0); // millisecon

endJ = calendarC();
setVal(endJ: 5: 5); // day
setVal(endJ: 2: 0); // month
setVal(endJ: 1: 2017); // year
setVal(endJ: 10: 0); // hour
setVal(endJ: 12: 0); // minute
setVal(endJ: 13: 0); // second
setVal(endJ: 14: 0); // millisecond

//**************************//
// Connect to Gateway //
//**************************//
gateway = gatewayC(envJ: merIdJ: privKeyJ: pubKeyJ);

// Checking if we got a conection by retrieving the path
configJ = getConfig(gateway);
config = getBytes(configJ);
pathJ = getPath(configJ);
path = getBytes(pathJ);

// Create search request

transReqJ = transReqC();
dateParamsJ = dateParams(transReqJ);
transreqJ = setRange(dateParamsJ: startJ: endJ);
transGatewayJ = transGateway(gateway);

// Retrieve the transactions

monitor;
resultJ = search(transGatewayJ: transReqJ);
on-error;
endmon;

transJ = getFirst(resultJ);

endsr;
/end-free
C/SPACE 3

D****************************************************************
D* Define procedure - debug message
D****************************************************************
P debugMessage B
D debugMessage PI
D PRMDBG 1 CONST
D PRMMSG 51 CONST

C PRMDBG IFEQ 'Y'
C PRMMSG DSPLY
C ENDIF

P DebugMessage E

D****************************************************************
D* Define procedure - debug message with reply
D****************************************************************
P debugMessage2 B
D debugMessage2 PI 2
D PRMDBG 1 CONST
D PRMMSG 50 CONST
D PRMRTN S 2

C PRMDBG IFEQ 'Y'
C PRMMSG DSPLY PRMRTN
C ENDIF
C
C RETURN PRMRTN

P DebugMessage2 E


Don Brown





From: Jon Paris <jon.paris@xxxxxxxxxxxxxx>
To: Java400 <java400-l@xxxxxxxxxxxx>
Date: 09/01/2017 04:09 AM
Subject: Re: ILERPG call to Java get list fails and generates
core
dump
Sent by: "JAVA400-L" <java400-l-bounces@xxxxxxxxxxxx>



Without the whole thing I'm afraid I can't help much ... too many
unknowns
here. The fact that earlier method calls didn't blow up doesn't mean
they
worked! So all of the protos etc. need checking.

How did you create the prototypes? Using the RDi tooling?

One thing I did notice was that in the error messages you posted, many
of
the names are prefixed by a capital L. Is that a typo? or did they
really
paper that way in the log? for example shouldn't Ljava.util.List be
java.util.List ?


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Jan 7, 2017, at 10:47 PM, Don Brown <DBrown@xxxxxxxxxx> wrote:

The definition of result is;

D result S O Class
(*JAVA:'com.braintreegateway.-
D ResourceCollection')

I thought the problem may have been java version related but I have
now
tried it on 1.7 64 bit and exactly the same error.




Don Brown

MSD Information Technology

Suite 5/29 McDougall Street Milton Q 4064
( 07 3368 7888
+ PO Box 1629 MILTON Q 4054
Ê 07 3368 7877
* Don.Brown@xxxxxxxxxx
È 0408 751 644
þ www.msd.net.au www.architect4web.com.au





I am a proud supporter of THE REFERRAL NETWORK and recommend the
services
of the other member businesses. For more information please checkout
the

website www.refnet.net.au





From: Jon Paris <jon.paris@xxxxxxxxxxxxxx>
To: Java400 <java400-l@xxxxxxxxxxxx>
Date: 07/01/2017 12:52 AM
Subject: Re: ILERPG call to Java get list fails and generates
core
dump
Sent by: "JAVA400-L" <java400-l-bounces@xxxxxxxxxxxx>



What is the definition of the object result?


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Jan 5, 2017, at 11:56 PM, Don Brown <DBrown@xxxxxxxxxx> wrote:

I posted this on the Midrange-L list and it was suggested I post it
here.


I am hoping someone can point me in the right direction with this
one.

Java is crashing when I use a method that should return a java list
object..

I checked the class using the javap -s command in qsh I get the
details

about the class; (All class details from this are included below)

The method I am using is gstIds
public java.util.List getIds();
Signature: ()Ljava/util/List;

I have the prototype defined in my program as follows;

D getIds PR O ExtProc(*JAVA:
D 'com.braintreegateway.-
D ResourceCollection':'getIds')
D Class(*JAVA:'java.util.List')

D listIdJ S O Class(*JAVA:'java.util.List')

The following code snippet precedes the error but running in debug
all
statements complete normally

// Create search request
transReqJ = transReqC();
dateParamsJ = dateParams(transReqJ);
transreqJ = setRange(dateParamsJ: startJ: endJ);
transGatewayJ = transGateway(gateway);

// Retrieve the transactions
result = search(transGatewayJ: transReqJ);

When the following line is executed it results in a gpf and system
dump.

There is a stack trace showing on the screen but is meaningless to me
-

See below.

listIdJ = getIds(result);

The joblog shows error MSG:RNX0301 Java exception received when
calling

Java method.
Cause . . . . . : RPG procedure STTAPP100R in program
XAPSW/STTAPP100R

received Java exception "**UNKNOWN ERROR**" when calling method
"getIds"


with signature "()Ljava.util.List;" in class
"com.braintreegateway.ResourceCollection".


Results from javap -s

javap -s com.braintreegateway.ResourceCollection

The java.version property was detected as input. This property is
used
as
output only and has no effect on JVM initialization.
Compiled from "ResourceCollection.java"
public class com.braintreegateway.ResourceCollection extends
java.lang.Object implements java.lang.Iterable{
public
com.braintreegateway.ResourceCollection(com.braintreegateway.Pager,

com.braintreegateway.util.NodeWrapper);
Signature:

(Lcom/braintreegateway/Pager;Lcom/braintreegateway/util/NodeWrapper;)V

public int getMaximumSize();
Signature: ()I
public java.util.Iterator iterator();
Signature: ()Ljava/util/Iterator;
public java.lang.Object getFirst();
Signature: ()Ljava/lang/Object;
public java.util.List getIds();
Signature: ()Ljava/util/List;
static java.util.List
access$000(com.braintreegateway.ResourceCollection);


Signature:
(Lcom/braintreegateway/ResourceCollection;)Ljava/util/List;


Stack Trace from screen when error occurs

----------- Stack Backtrace -----------
gpProtectedRunCallInMethod+0x24 (0xD07F3BC0 [libj9vm24.so+0x15bc0])
signalProtectAndRunGlue+0x14 (0xD080F090 [libj9vm24.so+0x31090])
j9sig_protect+0x138 (0xD0872F54 [libj9prt24.so+0x1f54])
gpProtectAndRun+0xc4 (0xD080F19C [libj9vm24.so+0x3119c])
gpCheckCallin+0x44 (0xD07F4398 [libj9vm24.so+0x16398])
callVirtualObjectMethodA+0x38 (0xD07F8538 [libj9vm24.so+0x1a538])
J9_i5OS_CallObjectMethodA+0xac (0xD054C8B0 [libi5osenv.so+0xd8b0])
(0x000036F0)



Don Brown

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


--
This is the Java Programming on and around the IBM i (JAVA400-L)
mailing

list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.



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


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



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


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

--
This is the Java Programming on and around the IBM i (JAVA400-L) mailing list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
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 ...

Replies:

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.