Sam Gho

Greenhorn
+ Follow
since Jun 20, 2020
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sam Gho

I am trying to run the Java-driver-code (e.g. Java mani) locally inside in my Windows-Eclipse and this code makes an HTTPS call to a webservice deployed in Windows-Tomcat deployed in a different Windows server.

The webservice URL deployed in the Windows-Tomcat server is similar to: https://mydomain.org/alfresco/service/extract/abc



This is what I have attempted:

I took the valid certificate from the Tomcat-Windows server and added it to my local-Eclipse-Windows machine’s JRE using the following:

keytool -import -trustcacerts -alias mycertificate -file C:\Documentation\ mycertificate.cer -keystore keystore.jks

After that, I also made sure that the certificate is indeed installed and verified that using:

keytool -list -v -keystore keystore.jks



I also verified that Eclipse in my local Windows machine is also configured to use the same JRE, where I imported the certificate from the Windows-Tomcat server.

Even with that, I still get the error as follows, when I attempt to execute the Java-driver-client-code from my locals-Eclipse-Windows-Eclipse machine, which attempts to call the URL deployed in the remote Windows-Tomcat server:

Called URL =https://mydomain.org/abc

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target


sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1946)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:316)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:310)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1639)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:223)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1037)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:965)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1064)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:263)
at MyDriver.java:63)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:397)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:302)
at sun.security.validator.Validator.validate(Validator.java:262)
at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1621)
... 15 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:392)
... 21 more



My question:

1. Any suggestion will be appreciated on how to add this certificate to my local-Windows-Eclipse machine so that I can call the URL deplotyed in Windows-Tomcat in a remoted Windows server.
1 month ago
The code works well for a limited number of calls (sequential), say up to HTTP(s) 1,000 calls. However, when we make say over 1,000 HTTP(s) calls, and the Tomcat-Alfresco server is flooded with calls (sequential), a 502 HTTP exception is thrown.

The exception is thrown by org.springframework.extensions.webscripts.AbstractWebScriptin, which is a part of Spring-API.

I am invoking a URL, which is deployed in Alfresco-Tomcat (enterprise version 5.1.x) Windows Server 2012, R2, 64-bit operating system. The driver Java-code also runs on the same Windows machine.


I am attempting to call the Web service URL deployed in Alfresco-Windows-machine as:
https://mydomain.org/alfresco/service/getdata/xyz

The 502 exception is thrown ONLY-IF the server is flooded with hundreds of calls. It is a GET call to retrieve documents and metadata. I tried giving a time-out (pause/sleep after a certain number of calls and tried various combinations for the value of sleep and the number of calls), but it still throws 502 exception if the system is flooded with calls.


The execption stacktrace is:


java.io.IOException: Server returned HTTP response code: 502 for URL: https://mydomain.org/alfresco/service/getdata/xyz
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at MyDriver.java:63
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)


It is indeed true that the exception gets thrown from line number 63 of MyDriver.java, where I make the HTTP(s) call to the URL of the Java-webscript deployed in Alfresco-Windows.



The MyDriver.java code is similar to:

URL url = new URL("https://mydomain.org/alfresco/service/getdata/xyz");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod(GET_REQUEST_METHOD);
conn.setRequestProperty(ACCEPT_REQUEST_PROPERTY, APPLICATION_JSON);
BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));


Line number 63 (which throws the 502 exception is thrown) is the line:

BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));



Can you suggest:

1. Any code change in the MyDriver.java code?

2. Any Java-spring related change?
1 month ago
In the same Windows server machine (Windows 2016 server, 64 bit), Apache 2.2 is correctly loading PHP. I have a need to upgrade to Apache 2.4.46 on the same Windows server. In order to do so, I first uninstalled the existing Apache2.2 from the server. After that, I installed Apache2.4.6 in that server. In the new Apache2.4.46, I am not able to load PHP (5.3.29, from 2014).

Operating System in which I am working=Windows Server 2016, 64 bit

I attempted with both 64 bit and 32 bit of Apache.24 and both gave different errors, which made me think 32-bit needs to be installed.

With 64bit Apache2.4.46

With 64 bit, httpd-2.4.46-win64-VS16 download from Apache Lounge (https://www.apachelounge.com/download/), install gives PHP related error as:

httpd.exe: Syntax error on line 583 of D:/Program Files (x86)/Apache Software Foundation/Apache24/conf/httpd.conf: Cannot load D:/Program Files (x86)/PHP/php5apache2_2.dll into server: %1 is not a valid Win32 application


With 32 bit Apache2.4.46
The above error made me think that I should use 32 bit.

With httpd-2.4.46-win32-VS16 (1) from Apache Lounge, the install gave me an error also.

I executed:
D:\Program Files (x86)\Apache Software Foundation\Apache2.4.46\bin>httpd.exe -k install

The error obtained in executing the above command for 32 bit was:
httpd.exe: Syntax error on line 584 of D:/Program Files (x86)/Apache Software Foundation/Apache24/conf/httpd.conf: Cannot load D:/Program Files (x86)/PHP/php5apache2_2.dll into server: The specified procedure could not be found.


I have the httpd.config entry as:


<IfModule dir_module>
   DirectoryIndex index.html
   #Needed to add
   DirectoryIndex index.php
   DirectoryIndex index.php3
   DirectoryIndex index.php4
   DirectoryIndex index.php5
</IfModule>


PHPIniDir "D:/Program Files (x86)/PHP"
AddType application/x-httpd-php .php
LoadModule php5_module "D:/Program Files (x86)/PHP/php5apache2_2.dll"


The PHP version is 5.3.29 from 2014. I do not wish to upgrade PHP, and it was correctly working with Apache2.2. The PHP dll file indeed exists in the correct folder. The PHP directory (which was correctly working with Apache 2.2) is not changed.

Any suggestions on:
1. Is 32-bit Apache2.4.46 the correct one?
2. Is ApacheLonge the correct one? As some other posts noted to go to this site instead of Apache.
3. Any help on what other configuration is needed in Apache, without requiring to change PHP.





2 months ago
PHP
In my Java code, I have a String as:

public final static String ROW_GAP = "«¶»n«¶«§»\\r\\n"

The above ROW_GAP String is used to separate the rows written in a text file (my.txt)

In order to write to my.txt, I write Java code similar to (by appending String):
String StringToWriteToFile= "Here comes row 11111"+ "ROW_GAP +"Here comes row 222222"

The expected values in my.txt are:

Here comes row 11111
«¶»n«¶»«§»\\r\\n
Here comes row 222222
«¶»n«¶»«§»\\r\\n
Here comes row 333333
«¶»n«¶»«§»\\r\\n
Here comes row444444


The code is deployed in the server (Windows server, JDK 1.8, Tomcat).

The problem is, the values written in my.txt in the server does NOT have the correct value of ROW_GAP.


Instead of «¶»n«¶»«§»\\r\\n, the value of ROW_GAP in my.txt in the server comes something as:

Here comes row 11111
???
Here comes row 222222
???
Here comes row 333333
???
Here comes row444444


I do not have the ability to run it in local Eclipse. It is indeed true that a simple Java main method with the above/similar code correctly shows the value or ROW_GAP. But in the server where it is deployed, it gets somewhat translated. The version of JDK, version of the Windows platform are the same in both coding/development environment and in the server, where the code is deployed.

What can be done to retain the correct value of ROW_GAP in my.txt? Can I wrap the value of the ROW_GAP String with some other API so that it always retains the correct value? Instead of String, can I use some other API variation that is a part of core JDK1.8?


4 months ago
I need to execute a Java Driver class (with the main method) from the command prompt as:


MyDriver.java in turn uses log4J.

In order to do so, I need to first set log4J in the open command prompt shell, so that I can run the java MyDriver later).

In order to first set log4j, I do as:



However, I get an error as:
no main manifest attribute, in D:\mylib\log4j-1.2.17.jar

How should I set up the Log4J properties in the command prompt?
5 months ago