Friday, May 27, 2016

Scala SBT error: sun.security.validator.ValidatorException: PKIX path building failed

Environment: 
Windows 7 in the company, no proxy
No installation on Scala SDK

When run "sbt" from command line, got the error:
sun.security.validator.ValidatorException: PKIX path building failed Error ...

The reason is that Java cannot access https website without trusted key store.
The below two articles explained very well and have the detailed solution, after put the key file to folder jre\lib\security, and rerun "sbt", the error is gone. (my concern, why "mvn" has no such error?)

http://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to-find-valid-certification-path-to-requested-target/
https://github.com/escline/InstallCert

Thursday, May 19, 2016

mvn archetype:generate does not work-no plugin found

When run the below:
mvn archetype:generate
got the below error:

mvn archetype:generate does not work-no plugin found for prefix 'archetype'

add -X and search metadata.xml:
mvn -X archetype:generate
It cannot get the *metadata.xml from the central repository because of the firewall/certification
although from the web browser the link is accessible:
Two solutions:
1. add settings.xml in the mvn .m2 folder:
<settings>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>securecentral</activeProfile>
  </activeProfiles>
  <profiles>
    <profile>
      <id>securecentral</id>
      <!--Override the repository (and pluginRepository) "central" from the
         Maven Super POM -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://repo1.maven.org/maven2</url>
          <releases>
            <enabled>true</enabled>
          </releases>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://repo1.maven.org/maven2</url>
          <releases>
            <enabled>true</enabled>
          </releases>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
</settings>
2. get and set the certificate file
See:
http://stackoverflow.com/questions/25911623/problems-using-maven-and-ssl-behind-proxy

Monday, May 9, 2016

健身

心肺能力的提高,靠的是长时间的低强度运动,俗称有氧运动,也就是长跑、游泳等。 
我认识一个人,只做俯卧撑,一天做3种变式的俯卧撑,共12组,每组15个,胸肌腹肌分离度和形状都非常棒
【无氧运动的时间】如果是力量训练,实际上时间控制在1小时为最佳,因为男性在进行力量训练的时候,会分泌睾酮,但是睾酮在训练后半小时大幅减少,所以无氧锻炼是前半小时的效率是最高的,因此时间控制在30~60min最好。

蛋清可以多吃,蛋黄一天一个或者两个就够了

https://www.zhihu.com/question/20687290/answer/15853608
最简单的锻炼计划
1.慢跑3~5分钟。总之达到身体微微出汗或者发热的效果即可停止。
2.做仰卧起坐和俯卧撑。
3.然后出去跑5公里,两天或者三天一次。


要保证每天至少7小时的睡眠,让肌肉在睡眠中得到充分的增长。而且每块大肌肉(胸背肩腿)每周练到力竭不要超过两次,小肌肉(手臂、腹部)每周练到力竭不要超过三次。这样能够保证最好的增长。

https://www.zhihu.com/question/19850561/answer/91268580

https://www.zhihu.com/question/29083850/answer/44593248

Sunday, May 1, 2016

How to trace SOAP message in Eclipse IDE

http://www.mkyong.com/webservices/jax-ws/how-to-trace-soap-message-in-eclipse-ide/

1. Endpoint publish
public class HelloWorldPublisher {
public static void main(String[] args) {
Endpoint.publish("http://localhost:9999/ws/hello", new HelloWorldImpl());
}
}

2. Soap client
public class HelloClient {
public static void main(String[] args) throws Exception {

URL url = new URL("http://localhost:8080/ws/hello?wsdl");
QName qname = new QName("http://ws.mkyong.com/", "HelloWorldImplService");
Service service = Service.create(url, qname);
HelloWorld hello = service.getPort(HelloWorld.class);
System.out.println(hello.getHelloWorldAsString("test"));
}
}

3. Eclipse configuration
Hostname: localhost:9999
Local port: 8080

4. Response message:
<?xml version="1.0" encoding="UTF-8"?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.4-b01. --><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.4-b01. --><definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.mkyong.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://ws.mkyong.com/" name="HelloWorldImplService">
<types>
<xsd:schema>
<xsd:import namespace="http://ws.mkyong.com/" schemaLocation="http://localhost:9999/ws/hello?xsd=1"></xsd:import>
</xsd:schema>
</types>
<message name="getHelloWorldAsString">
<part name="parameters" element="tns:getHelloWorldAsString"></part>
</message>
<message name="getHelloWorldAsStringResponse">
<part name="parameters" element="tns:getHelloWorldAsStringResponse"></part>
</message>
<portType name="HelloWorld">
<operation name="getHelloWorldAsString">
<input wsam:Action="http://ws.mkyong.com/HelloWorld/getHelloWorldAsStringRequest" message="tns:getHelloWorldAsString"></input>
<output wsam:Action="http://ws.mkyong.com/HelloWorld/getHelloWorldAsStringResponse" message="tns:getHelloWorldAsStringResponse"></output>
</operation>
</portType>
<binding name="HelloWorldImplPortBinding" type="tns:HelloWorld">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding>
<operation name="getHelloWorldAsString">
<soap:operation soapAction=""></soap:operation>
<input>
<soap:body use="literal"></soap:body>
</input>
<output>
<soap:body use="literal"></soap:body>
</output>
</operation>
</binding>
<service name="HelloWorldImplService">
<port name="HelloWorldImplPort" binding="tns:HelloWorldImplPortBinding">
<soap:address location="http://localhost:9999/ws/hello"></soap:address>
</port>
</service>
</definitions>