Discussion:
Inline::Java problem dealing with PayPal .jar file
Tom Kane
2012-10-31 22:20:58 UTC
Permalink
Hi,

I am trying to work with Inline::Java from within a Linux/nginx/fastcgi/Catalyst framework. I need to be able to interface to a PayPal .jar file, which is the only method of access I have to their "Hosted Checkout" credit card processing.

I have a perl module (.pm) that executes an Inline Java STUDY on the PayPal .jar file. I can access this module from a non-Catalyst perl program and everything works fine. However, if I try to execute this same module from within a Catalyst module, there is a problem and I don't know if this stems from something being done within Inline::Java's STUDY process or whether Catalyst is doing or missing something.

Before going forward, I would like to add that I have been able to successfully use Catalyst together with Inline::Java where I have a simple class defined in a very simple .jar file. Works like a champ. I use a simple STUDY command:

use Inline Java => 'STUDY',
CLASSPATH => "/path/to/Greeter.jar",
STUDY => [ Greeter ] ;

So it's not as if there are incompatibilities between Catalyst and Inline::Java.

The problem comes from the fact that the PayPal .jar file's methods are more complex than the simple methods used in my successful Catalyst-Inline::Java test.

I declare the PayPal methods that I'm trying to use as follows:

use Inline Java => 'STUDY',
CLASSPATH => "/path/to/payflow.jar",
STUDY => [
'paypal.payflow.AuthorizationTransaction',
'paypal.payflow.BillTo',
'paypal.payflow.Currency',
'paypal.payflow.Invoice',
'paypal.payflow.PayflowConnectionData',
etc.
];

The problem seems to be a namespace issue as I get the error message:

... (perhaps you forgot to load "paypal::payflow::Invoice"?)

As I said, the multi-layered PayPal methods declaration works successfully when I execute it from a non-Catalyst perl program. But it seems as though Catalyst expects there to be separate sub-directories for each of the methods (given the use of the :: separators between paypal, payflow, and Invoice).

Have I missed something with regard to how Inline::Java STUDY works when there is a multi-layered library? (Except it works okay outside of Catalyst, which, of course, may be purely accidental.)

Thanks for any help.

Tom
Patrick LeBoutillier
2012-10-31 22:50:11 UTC
Permalink
Tom,

I don't know anything about Catalyst, but my guess is that it puts your
code into some
autogenerated namespace, and that why you can't find your methods.

If you set the DEBUG Inline::Java option to 5, you should get a lot of
output that should tell
you where the methodds are being bound. If it's too cryptic, you can post
it to this list and I'll
look at it.

If that's the case, you can look at the PACKAGE option that allows you to
force where
the code will be bound.


Patrick
Post by Tom Kane
Hi,
I am trying to work with Inline::Java from within a
Linux/nginx/fastcgi/Catalyst framework. I need to be able to interface to a
PayPal .jar file, which is the only method of access I have to their
"Hosted Checkout" credit card processing.
I have a perl module (.pm) that executes an Inline Java STUDY on the
PayPal .jar file. I can access this module from a non-Catalyst perl program
and everything works fine. However, if I try to execute this same module
from within a Catalyst module, there is a problem and I don't know if this
stems from something being done within Inline::Java's STUDY process or
whether Catalyst is doing or missing something.
Before going forward, I would like to add that I have been able to
successfully use Catalyst together with Inline::Java where I have a simple
class defined in a very simple .jar file. Works like a champ. I use a
use Inline Java => 'STUDY',
CLASSPATH => "/path/to/Greeter.jar",
STUDY => [ Greeter ] ;
So it's not as if there are incompatibilities between Catalyst and Inline::Java.
The problem comes from the fact that the PayPal .jar file's methods are
more complex than the simple methods used in my successful
Catalyst-Inline::Java test.
use Inline Java => 'STUDY',
CLASSPATH => "/path/to/payflow.jar",
STUDY => [
'paypal.payflow.AuthorizationTransaction',
'paypal.payflow.BillTo',
'paypal.payflow.Currency',
'paypal.payflow.Invoice',
'paypal.payflow.PayflowConnectionData',
etc.
];
... (perhaps you forgot to load "paypal::payflow::Invoice"?)
As I said, the multi-layered PayPal methods declaration works successfully
when I execute it from a non-Catalyst perl program. But it seems as though
Catalyst expects there to be separate sub-directories for each of the
methods (given the use of the :: separators between paypal, payflow, and
Invoice).
Have I missed something with regard to how Inline::Java STUDY works when
there is a multi-layered library? (Except it works okay outside of
Catalyst, which, of course, may be purely accidental.)
Thanks for any help.
Tom
--
=====================
Patrick LeBoutillier
Rosemère, Québec, Canada
Tom Kane
2012-11-01 14:10:21 UTC
Permalink
For those of you who are reading this post about using Inline::Java with Catalyst, the following is provided so the issue's resolution is shared.

Patrick asked me to create a debug dump by adding the option DEBUG => 5. I added the option and created the dump, which was huge (6Mb+). I forwarded the dump directly to Patrick's email address because of its size. That was last night. This morning I opened my email and found that Patrick had already scanned the dump and come up with an answer. I have performed initial testing within the Catalyst framework and found that his suggestion worked. Fantastic!

Unfortunately, I used a different email address to send the dump to Patrick and he responded to that email address. I cannot directly forward his response to inline-RykgAxdMFBPhvxM+***@public.gmane.org So I have simply copied and pasted his response here.

==================
Patrick's response
==================

Thomas,

Basically your Java classes end up under these namespaces:

myJava::Controller::Root::paypal::payflow::AuthorizationTransaction
myJava::Controller::Root::paypal::payflow::BillTo
myJava::Controller::Root::paypal::payflow::Currency
myJava::Controller::Root::paypal::payflow::Invoice
myJava::Controller::Root::paypal::payflow::PayflowConnectionData
myJava::Controller::Root::paypal::payflow::PayflowUtility
myJava::Controller::Root::paypal::payflow::Response
myJava::Controller::Root::paypal::payflow::SDKProperties
myJava::Controller::Root::paypal::payflow::TransactionResponse
myJava::Controller::Root::paypal::payflow::UserInfo

So, for example, to create an object, you have to go something like this:

my $ui = new myJava::Controller::Root::paypal::payflow::UserInfo(...) ;


Patrick

=========================
end of Patrick's response
=========================

I modified my code to use the extended naming scheme to test out if the PayFlow methods were really accessible that way. It worked without a hitch.

In my original module, I was trying to access the methods like this:

my $sdk = new paypal::payflow::SDKProperties() ;

That worked fine if I was using a non-Catalyst perl program. But Catalyst adds plenty of its own namespace processing, so I had to use the full path from the very top of the Catalyst program, where

1) myJava:: represents the main Catalyst framework application,

2) Controller:: is the subdirectory under the main application (the 'C' part of Catalyst's 'MVC' functionality), and

3) Root:: is the actual module containing the executable code (and which was the module with the "use" clause that loaded the module containing the use "Inline Java => 'STUDY'" in it (note that the latter module's name does not appear in the namespace hierarchy)).

Thank you so very much Patrick. I will follow up as I move from my test framework to my actual module.

Tom

Loading...