Tuesday, October 24, 2017

unable to find valid certification path to requested target

1. Add certificate to cacerts with InstallCert.java or linux command line. Put it to %JAVA_HOME%\jre\lib\security\

2. Check or add usage correct -Djavax.net.ssl.trustStore="...\cacerts"

3. Check Network, Firewall and Proxy settings by accessing the site with:
      Try:
         ping host 
         ping ip
      Try:
         telnet hostname port 

AWS SES - Amazon Send Email Service

COMMANDS
javac -cp *; MailTest.java
java -cp *;  -Dlog4j.configurationFile=log4j2-console.xml MailTest

DIR
aws-java-sdk-core-1.11.119.jar
aws-java-sdk-ses-1.11.119.jar
httpclient-4.5.3.jar
httpcore-4.4.6.jar
jackson-annotations-2.7.0.jar
jackson-core-2.7.1.jar
jackson-databind-2.7.1.jar
jcl-over-slf4j-1.7.7.jar
joda-time-2.8.1.jar
log4j-api-2.1.jar
log4j-core-2.1.jar
log4j-slf4j-impl-2.1.jar
log4j2-console.xml
MailTest.class
MailTest.java

slf4j-api-1.7.7.jar




MailTest.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.simpleemail.AmazonSimpleEmailService;
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClientBuilder;
import com.amazonaws.services.simpleemail.model.Body;
import com.amazonaws.services.simpleemail.model.Content;
import com.amazonaws.services.simpleemail.model.Destination;
import com.amazonaws.services.simpleemail.model.Message;
import com.amazonaws.services.simpleemail.model.SendEmailRequest;


public class MailTest {

private static final Logger LOGGER = LoggerFactory.getLogger(MailTest.class);

public static void main(String[] args) {

System.out.println("=start=");

String awsAccessKey="change_it";
String awsSecretKey="change_it";
String awsSesRegion="us-west-2";

BasicAWSCredentials credentials = new BasicAWSCredentials(awsAccessKey, awsSecretKey);

AmazonSimpleEmailService amazonSesClient = AmazonSimpleEmailServiceClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.withRegion(awsSesRegion)
.build();


Content subjectContent = new Content("subject");
Content bodyContent = new Content("body email content");

Body mailBody = new Body().withText(bodyContent);

Message message = new Message().withSubject(subjectContent).withBody(mailBody);

Destination destination = new Destination().withToAddresses("alexey.zavizionov@gmail.com");
SendEmailRequest request = new SendEmailRequest()
.withSource("alexey.zavizionov@gmail.com")
.withDestination(destination)
.withMessage(message);

System.out.println("===============");
System.out.println(request);
System.out.println("---------------");

try {
amazonSesClient.sendEmail(request);
LOGGER.debug("Email with subject '{}' was sent to: {}", "subject", "alexey.zavizionov@gmail.com");
return;
} catch (AmazonServiceException a) {
LOGGER.error("Maximum sending rate exceeded when sending email: {}", message, a);
return;
} catch (Exception e) {
LOGGER.error("Failed to send email: {}", message, e);
return;
} finally {
System.out.println("=THE END=");
}

}

}


log4j2-console.xml
code
   
       
           
                %level{length=1} %date{MMdd-HHmm:ss,SSS} %logger{1.} %message [%thread]%n
           
       
   
   
       
           
       
   

Error: Could not find or load main class - SOLUTION

PROBLEM:
Error: Could not find or load main class

SOLUTION:
java -cp *;  MyTest
Don't forget to use ";"!


Wednesday, October 11, 2017

Eclipse + OSGi + m2e + Tycho plugin

Eclipse Java EE IDE for Web Developers.

Version: Mars Release (4.5.0)
Build id: 20150621-1200




Or use a new one
https://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/oxygen1


---
m2e should be already installed in eclipse



---

Tycho software site

org.sonatype.tycho.repository -
http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-tycho/0.8.0/N/0.8.0.201409231215/




Open resource


Click at "Set as Target Platform"




Eclipse download statistic



Version                 Year    EE         ide    classic      size ee
Galileo 3.5.2        2009 745 1094 651 190
Helios 3.6.2         2010 3982 934 421 206
Indigo 3.7.2         2011 4671156 1659485 3223475 213
Juno 4.2.2            2012 2825040 1119755 1827173 229
Kepler 4.3.2        2013 4174634 1235322 5699326 250
Luna 4.4.2           2014 2561008 4392111 347281 254
Mars 4.5.2           2015 3419709 1479877 169154 275
Neon                    2016 1805982 804094 54177 304
Oxygen                2017 136808 88226 8991 328