Mulesoft NetSuite Connector throw java.lang.NullPointerException: charsetName Error - mule

I am getting this error in my mulesoft application while making a search call to NetSuite connector (v11.5.12).
org.apache.cxf.phase.PhaseInterceptorChain: Interceptor for {http://client.internal.soap.mule.org/}ProxyService#{http://client.internal.soap.mule.org/}invoke has thrown exception, unwinding now
java.lang.NullPointerException: charsetName
This error has suddenly started to come in the production environment. I am not able to replicate the same in lower environment.
Mule Application is deployment on Anypoint CloudHub with Mule Runtime version 4.4.0
NetSuite connector version v11.5.12
No recent changes deployed to production, existing application started to throw this error while searching
I enabled NetSuite Debug Logger and below are the logs it generated.
DEBUG 2023-02-15 13:50:53,636 [[finance-bulk-api].NetSuite_Config.04 SelectorRunner] [processor: netsuite-advance-search/processors/1/processors/0/processors/0; event: a91c2ba0-ad09-11ed-b6b5-88665a243a09] org.mule.service.http.impl.service.HttpMessageLogger.NetSuite_Config: REQUESTER
POST /services/NetSuitePort_2021_1 HTTP/1.1
SOAPAction: search
Host: 1111.suitetalk.api.netsuite.com
User-Agent: AHC/1.0
Connection: keep-alive
Accept: */*
Content-Type: text/xml
Transfer-Encoding: chunked
c57
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><preferences xmlns="urn:messages_2021_1.platform.webservices.netsuite.com"><warningAsError>false</warningAsError><disableMandatoryCustomFieldValidation>false</disableMandatoryCustomFieldValidation><disableSystemNotesForCustomFields>false</disableSystemNotesForCustomFields><ignoreReadOnlyFields>false</ignoreReadOnlyFields><runServerSuiteScriptAndTriggerWorkflows>false</runServerSuiteScriptAndTriggerWorkflows></preferences><tokenPassport xmlns="urn:messages_2021_1.platform.webservices.netsuite.com"><account xmlns="urn:core_2021_1.platform.webservices.netsuite.com">****</account><consumerKey xmlns="urn:core_2021_1.platform.webservices.netsuite.com">*****</consumerKey><token xmlns="urn:core_2021_1.platform.webservices.netsuite.com">****</token><nonce xmlns="urn:core_2021_1.platform.webservices.netsuite.com">****</nonce><timestamp xmlns="urn:core_2021_1.platform.webservices.netsuite.com">****</timestamp><signature xmlns="urn:core_2021_1.platform.webservices.netsuite.com" algorithm="HMAC_SHA256">fhpl/bxKP/cfuAYhSQ/MULWdkfjfnkfkUlMbWguVr9a6MaXS5fhRUDJVIdjdonddU=</signature></tokenPassport><searchPreferences xmlns="urn:messages_2021_1.platform.webservices.netsuite.com"><bodyFieldsOnly>false</bodyFieldsOnly><returnSearchColumns>true</returnSearchColumns><pageSize>10</pageSize></searchPreferences></soap:Header><soap:Body><ns0:search xmlns:ns0="urn:messages_2021_1.platform.webservices.netsuite.com">
<ns0:searchRecord xmlns:ns01="urn:sales_2021_1.transactions.webservices.netsuite.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns01:TransactionSearchAdvanced">
<ns01:criteria xmlns:ns01="urn:sales_2021_1.transactions.webservices.netsuite.com">
<ns01:basic>
<ns02:lastModifiedDate xmlns:ns02="urn:common_2021_1.platform.webservices.netsuite.com" operator="within">
<ns03:searchValue xmlns:ns03="urn:core_2021_1.platform.webservices.netsuite.com">2023-02-13T22:00:49</ns03:searchValue>
<ns03:searchValue2 xmlns:ns03="urn:core_2021_1.platform.webservices.netsuite.com">2023-02-14T22:00:49</ns03:searchValue2>
</ns02:lastModifiedDate>
<ns02:recordType xmlns:ns02="urn:common_2021_1.platform.webservices.netsuite.com" operator="is">
<ns03:searchValue xmlns:ns03="urn:core_2021_1.platform.webservices.netsuite.com">Invoice</ns03:searchValue>
</ns02:recordType>
</ns01:basic>
</ns01:criteria>
<ns01:columns xmlns:ns01="urn:sales_2021_1.transactions.webservices.netsuite.com">
<ns01:basic>
<ns02:amountRemaining xmlns:ns02="urn:common_2021_1.platform.webservices.netsuite.com"/>
<ns02:internalId xmlns:ns02="urn:common_2021_1.platform.webservices.netsuite.com">
<ns03:searchValue xmlns:ns03="urn:core_2021_1.platform.webservices.netsuite.com" internalId="null"/>
</ns02:internalId>
</ns01:basic>
</ns01:columns>
</ns0:searchRecord>
</ns0:search></soap:Body></soap:Envelope>
DEBUG 2023-02-15 13:50:53,636 [[biz-prc-ent-finance-bulk-api].NetSuite_Config.04 SelectorRunner] [processor: netsuite-advance-search/processors/1/processors/0/processors/0; event: a91c2ba0-ad09-11ed-b6b5-88665a243a09] org.mule.service.http.impl.service.HttpMessageLogger.NetSuite_Config: REQUESTER
0
DEBUG 2023-02-15 13:50:58,153 [[finance-bulk-api].NetSuite_Config.04 SelectorRunner] [processor: netsuite-advance-search/processors/1/processors/0/processors/0; event: a91c2ba0-ad09-11ed-b6b5-88665a243a09] org.mule.service.http.impl.service.HttpMessageLogger.NetSuite_Config: REQUESTER
HTTP/1.1 504 Gateway Time-out
Server: AkamaiGHost
Mime-Version: 1.0
Content-Type: text/html
Content-Length: 176
Expires: Wed, 15 Feb 2023 08:20:58 GMT
X-Reference-Error: 97.27697c68.1676449258.23382b2c
Date: Wed, 15 Feb 2023 08:20:58 GMT
Connection: close
Akamai-GRN: 0.df523617.1676449254.1f240dc8
<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>
An error occurred while processing your request.<p>
Reference &#3
5;97.27697c68.1676449258.23382b2c
</BODY></HTML>
WARN 2023-02-15 13:50:58,155 [[MuleRuntime].uber.02: [finance-bulk-api].netsuite-to-salesforce-sync-shcedular-flow.BLOCKING #32c6a070] [processor: netsuite-advance-search/processors/1/processors/0/processors/0; event: a91c2ba0-ad09-11ed-b6b5-88665a243a09] org.apache.cxf.phase.PhaseInterceptorChain: Interceptor for {http://client.internal.soap.mule.org/}ProxyService#{http://client.internal.soap.mule.org/}invoke has thrown exception, unwinding now
java.lang.NullPointerException: charsetName
at java.io.InputStreamReader.<init>(InputStreamReader.java:99) ~[?:1.8.0_312]

Clearly the error is a timeout on the Netsuite infrastructure:
HTTP/1.1 504 Gateway Time-out
It it not possible to know the cause of the error from the data provided. It could be a Netsuite issue, a configuration issue (wrong connection address?), or simply that the operation takes too long to complete (data issue, which may vary between environments).
It would be recommended to upgrade to the latest Mule Netsuite connector release and test again. There have several fixes and improvements since the version you are using was released, including security fixes and error messages improvements. Even if it doesn't solve the issue you are experiencing you would be better covered against those issues.

Related

SAPUI5 OData v4 Batch Requests Header Parsing

I'm trying to implement a UI5 service using an OData v4 backend.
In general my bindings seem to work, however, there seems to be a problem parsing the headers of the batch requests. Parsing the batch parts by skipping the code in the debugger works fine.
In the console I get the following error:
2022-10-11 13:14:09.584899 $batch failed - Error: Expected 'OData-Version' header with value '4.0' but received value 'null' in response for http://localhost:8080/odata/$batch
at h.doCheckVersionHeader (http://localhost:1337/resources/sap/ui/core/library-preload.js:4753:314)
at Object.<anonymous> (http://localhost:1337/resources/sap/ui/core/library-preload.js:4786:415)
at Object.<anonymous> (http://localhost:1337/resources/sap-ui-core.js:2099:9272)
at p (http://localhost:1337/resources/sap-ui-core.js:2219:26833)
at Object.fireWith [as resolveWith] (http://localhost:1337/resources/sap-ui-core.js:2219:27676)
at y3 (http://localhost:1337/resources/sap-ui-core.js:2219:84906)
at XMLHttpRequest.<anonymous> (http://localhost:1337/resources/sap-ui-core.js:2219:87536) sap.ui.model.odata.v4.ODataModel`
However, inspecting the headers in the developer tools the OData-Version header seems to be set
HTTP/1.1 202
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Access-Control-Allow-Origin: *
OData-Version: 4.0
Content-Type: multipart/mixed;boundary=batch_63059dbf-3e96-4650-b6b9-c6237b7e3b9e
Content-Length: 3848
Date: Tue, 11 Oct 2022 11:14:06 GMT
Keep-Alive: timeout=60
Connection: keep-alive
In the function h.doCheckVersionHeader only the Content-Type and Content-Length are aviable.
I start my project via ui5 serve and seem to be using version 1.102.1.
Does anyone know how I can get the requests to work?
I have resolved the issue by adding the
Access-Control-Expose-Headers header to the response: https://github.com/SAP/openui5/issues/3613#issuecomment-1274609280
The section "Response Headers" from the documentation topic "Model Instantiation and Data Access" now lists headers that need to be added to the Access-Control-Expose-Headers response header:
The OData model processes some of the response headers, namely:
DataServiceVersion (only when consuming an OData V2 service),
Date,
ETag,
OData-Version,
Preference-Applied,
Retry-After,
SAP-Messages,
X-CSRF-Token.
Some SAP applications will also require the processing of SAP-ContextId, SAP-Err-Id, and SAP-Http-Session-Timeout. When using cross-origin resource sharing (CORS), it is important to add all these headers to the Access-Control-Expose-Headers response header.
Also, make sure that values assigned to the headers are syntactically valid. E.g. no dangling characters: OData-Version: 4.0; → OData-Version: 4.0.

Net Core 3.1: Soap Request returns 403 Unauthorized

I have the following question. We are using net core 3.1.
We make a soap request (HttpWebRequest) to a external webservice where they only allow a whitelist of IP addresses into the portal. Our VPN Ipadress is in the whitelist.
But when i send a request (Via Visual studio debugger) it get rejected by de external webservice: 403 Unauthorized.
But when starting Fiddler and then sending the same request again, via Visual studio debugger, we get a 200 OK.
The same is with Postman. When fiddler is not running the request gets rejected. When Fiddler
is running the request is accepted and the response is 200 OK.
I dont understand what is happening, How to solve this.
NOT VIA Fiddler:
Status: 500 Internal Server Error
Version HTTP/1.1
Transferred 408 B (233 B size)
Referrer Policy strict-origin-when-cross-origin
Request Priority Highest
Response Headers:
Content-Type: application/json
Date: Thu, 28 Jul 2022 08:42:32 GMT
Server: Kestrel
Transfer-Encoding: chunked
X-Powered-By: ASP.NET
VIA Fiddler:
Status 200 OK
Version HTTP/1.1
Transferred 1.57 KB (1.41 KB size)
Referrer Policy strict-origin-when-cross-origin
Request Priority Highest
Content-Type text/plain; charset=utf-8
Date Thu, 28 Jul 2022 09:01:24 GMT
Server Kestrel
Transfer-Encoding chunked
X-Powered-By ASP.NET

Glassfish Server Hell - GZip JSON - No Stacktrace Printed

I never liked these heavy weight servers like Glassfish, Weblogic etc., but I had to do some implementation by exposing some of the endpoints through http served via Glassfish. In one particular case, I have to send to the Glassfish server a Post request that takes a GZipped input, decompresses it and send a GZipped response back. Here is what I have so far:
On the Glassfish Server:
#Path("/")
class MyService extends BaseService {
#POST
#Path("/myService")
#Consumes(Array("application/json"))
#Produces(Array("application/json"))
#GZIP
def myService(#GZIP json: String): Response = {
println("Message received") // Not getting printed as well!!!
Response.status(200).header("Content-Encoding", "gzip").entity(JsonMarshall.deserialize(json)).build()
}
}
I'm using the JBoss rest easy API's to expose myService endpoint. In my client, I set the necessary headers (snippet shown below)
post.addHeader("Content-Encoding", "gzip")
post.addHeader("Accept-Encoding", "gzip, deflate")
But when I run my client, here is what I see as response:
[main] INFO ServerPingTest - Calling URL http://localhost:8080/glassfish-server/myService
[main] INFO ServerPingTest - --- RESPONSE HEADERS ---
[main] INFO ServerPingTest - X-Powered-By: Servlet/3.1 JSP/2.3 (GlassFish Server Open Source Edition 4.0 Java/Oracle Corporation/1.7)
[main] INFO ServerPingTest - Server: GlassFish Server Open Source Edition 4.0
[main] INFO ServerPingTest - Content-Language:
[main] INFO ServerPingTest - Content-Type: text/html
[main] INFO ServerPingTest - Date: Tue, 11 Mar 2014 16:39:17 GMT
[main] INFO ServerPingTest - Content-Length: 1217
[main] ERROR ServerPingTest - Error occurred when ping testing !!!!! Please see the stacktrace below!
java.util.zip.ZipException: Not in GZIP format
at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:164)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:78)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:90)
......
......
This is what I see on the server;
[#|2014-03-11T17:39:17.557+0100|SEVERE|glassfish 4.0||_ThreadID=21;_ThreadName=Thread-4;_TimeMillis=1394555957557;_LevelValue=1000;|
[http-listener-1(3)] WARN org.jboss.resteasy.core.SynchronousDispatcher - Failed executing POST /myService|#]
I also do not see any stack trace. Can anyone please help as to what went wrong?
Looks like I have managed to solve this. I did the following:
Used the latest version of the rest easy API (version 3.0.6.Final) against using an older version 2.2.1 (See this post http://sourceforge.net/p/resteasy/mailman/resteasy-developers/thread/BDED22DA-ACDC-47F5-9B14-30A202B52981#redhat.com/)
I added an additional header on my client (post.addHeader("Content-Type", "application/json"))
Bang it worked!

How do I handle WCF SOAP deserialization errors in HTTP Reponse?

How do I hide the following error information and show custom message in WCF? This error occur when we inject invalid parameter in http request
HTTP/1.0 500 Internal Server Error
Cache-Control: private
Content-Length: 494
Content-Type: text/xml; charset=utf-8
Date: Mon, 23 Jan 2012 22:34:36 GMT
X-Cache: MISS from test.int.testgroup.com
Via: 1.0 test.int.testgroup.com:80 (squid/2.6.STABLE22)
Proxy-Connection: close
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:DeserializationFailed</faultcode><faultstring xml:lang="en-US">The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'GetData'. Character reference not valid. Line 1, position 121.</faultstring></s:Fault></s:Body></s:Envelope>
You will need a custom WCF deserializer that can catch the errors and produce custom error messages. Have a look here: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/dcd48a7f-4494-455f-8504-cbdc372badcf/

Is it possible to log the first line of the response in apache?

We have an Tomcat server where we're trying to log the HTTP version which the response is sent with. We've seen a few times that it seems to be HTTP/0.9, which kills the content (not supported I guess?). We would like to get some stats on this by using the access log in apache. However, since the header line for this isn't prefixed by anything, we cannot use the %{xxx}o logging.
Is there a way to get this?
An example:
Response is:
HTTP/1.1 503 This application is not currently available
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=utf-8
Content-Length: 1090
Date: Wed, 12 May 2010 12:53:16 GMT
Connection: close
And we'd like the catch HTTP/1.1 (alternatively, HTTP/1.1 503 This application is not currently available.
Is this possible? We do not have access to the application being served, so we need to do this either as a Java filter, or in the tomcat access log - Preferably in the access log.
Enabling the <Valve className="org.apache.catalina.valves.RequestDumperValve"/> in server.xml writes out the request and response headers for each request.
Example:
19-May-2010 12:26:18 org.apache.catalina.valves.RequestDumperValve invoke
INFO: protocol=HTTP/1.1