cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using the new "API" style with the JAVA SDK

Probably something stupid that I'm not doing, but I am having problems doing things using the new API. Sequences like the following (Which is exactly the ChargeCustomerProfile sample code from the samples on github):

 

 

//Common code to set for all requests
ApiOperationBase.setEnvironment(Environment.SANDBOX);

MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
merchantAuthenticationType.setName(apiLoginId);
merchantAuthenticationType.setTransactionKey(transactionKey);
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);

// Populate the payment data
PaymentType paymentType = new PaymentType();
CreditCardType creditCard = new CreditCardType();
creditCard.setCardNumber("4242424242424242");
creditCard.setExpirationDate("0822");
paymentType.setCreditCard(creditCard);

 

 

...

 

Always result in the following type of error:

29 [pool-1-thread-1] DEBUG net.authorize.util.HttpUtility - Posting request to Url: 'https://apitest.authorize.net/xml/v1/request.api'
126 [main] ERROR net.authorize.util.HttpUtility - Execution error for http post Message: 'java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy'
127 [main] DEBUG net.authorize.api.controller.base.ApiOperationBase - Got a 'null' Response for request:'net.authorize.api.contract.v1.CreateTransactionRequest@4eb3ea0f'

 

I have no trouble doing things the "old" way - ie:

 

Merchant merchant = Merchant.createMerchant(Environment.SANDBOX, apiLoginId,transactionKey);

// Create payment transaction
Transaction transaction = merchant.createCIMTransaction(TransactionType.CREATE_CUSTOMER_PROFILE_TRANSACTION);

// Set customer ID and customer's payment profile ID that you want to be billed
transaction.setCustomerProfileId(customerProfileID);
transaction.setCustomerPaymentProfileId(customerPaymentProfileID);

// Add information about the transaction
PaymentTransaction paymentTransaction = PaymentTransaction.createPaymentTransaction();
Order order = Order.createOrder();
order.setTotalAmount(new BigDecimal(9.99));
order.setDescription("Test charge");

...

 

 

Seems like it is probably an issue with serialization to XML? I downloaded the SDK from github and just did "ant jar" to make the SDK jar - nothing special there - it doesn't seem possible that I would not be able to get the samples to work with the SDK  "out of the box", so I'm assuming I did something stupid?

 

Any help gratefully appreciated - I can continue to use the old ways, but I would prefer to implement something more future-proof.

 

- Chris

 

cjh
Member
7 REPLIES 7

 

Hi Chris,

 

Can you please specify which sample code are you using and did you make any modifications to it?  It would also help to know the version and vendor of your JDK.

 

Thanks,

Joy

Joy
Administrator Administrator
Administrator

Hi, have you sorted out this issue ?

lpavone
Member

In case it helps, I am using Java 8:

java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

 

and I am trying to run the simple case of ChargeCreditCard. 

If I run the example I pulled from gitHub I got an approval transaction:

 

xxxx@xxxxxxxxxx:~/projects/[authorize.net]/sample-code-java$ java -jar target/SampleCode.jar ChargeCreditCard
12/21/15 12:12:21,865: INFO [pool-1-thread-1] (net.authorize.util.LogHelper:24) - Use Proxy: 'false'
1
Successful Credit Card Transaction
2BR065
2247246870

but then generating the JAR and including this in a separate project, without code changes, just creating a Java class with the same example code, I am unable to get a successfully transaction.

Error is:

SEVERE: Execution error for http post Message: 'java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy'

 

Hope you can help with this.

 

I am also seeing this problem when using the Transaction Detail API with a sdk checkout and build from today. I tried building with Java 1.6, 1.7, and 1.8 but had the same results.

 

APP ERROR [main 04-08 15:55:53.437] (HttpUtility.java:111) HttpUtility: Execution error for http post Message: 'java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy'
No response received
Exception in thread "main" java.lang.Exception: No response received

If I go back to a java sdk build I created on the 12th of November 2015 using java 1.6.0_45, then it all works fine. The only change is which anet-java-sdk.jar I drop into the project.

 

Note that I was originally trying to get this to work under a new java 1.8 project, but fell back to testing against a project running under java 1.7.

I have isolated the problem. Attempting to build the sdk using ant is what causes this issue. Building the sdk with Maven works fine. I suppose the first clue that ant was not maintained should have been that the ant version is 1.8.2 while the maven version is 1.8.9.

@mkienenb, thanks for providing feedback and opening the issue on GitHub for our developers to review.

 

Richard

Richard,

 

The issue was closed on github, but the problem remains in the master branch.

Added my latest experiences there as a comment.