https://testsortedset.wordpress.com/javasnippets/my-tiny-mini-orm-with-commons-dbutils-and-generics-2/
Saturday, October 30, 2021
Thursday, October 28, 2021
SSL or no SSL ?
https://mkyong.com/webservices/jax-ws/java-security-cert-certificateexception-no-name-matching-localhost-found/
Friday, October 22, 2021
Fat runnable jars with maven
First read this for the different ways:
https://www.baeldung.com/executable-jar-with-maven
If you have external/local jars, understand the problem:
https://stackoverflow.com/questions/364114/can-i-add-jars-to-maven-2-build-classpath-without-installing-them
One possible dirty way:
https://github.com/stephenc/non-maven-jar-maven-plugin
Apache CXF and SOAP XML Logging
Phew this one was tough..but managed to solve it eventually using the following:
https://newbedev.com/apache-cxf-loggingininterceptor-is-deprecated-what-to-use-instead
https://stackoverflow.com/questions/56356503/how-to-log-soap-request-response-using-log4j2-in-separate-log-files-dynamically
And this one did the most work
https://newbedev.com/how-to-modify-the-raw-xml-message-of-an-outbound-cxf-request
In between, had to mess with Streams.. it was crazy:
https://newbedev.com/convert-outputstream-to-bytearrayoutputstream
https://stackoverflow.com/questions/5923817/how-to-clone-an-inputstream/5924132#5924132
https://stackoverflow.com/questions/33014035/write-from-output-stream-to-output-stream
Finally .. learnt alot again.
Wednesday, July 7, 2021
Jar with dependencies using maven
This works for me:
https://www.programmersought.com/article/82714095304/
Thursday, June 17, 2021
Using maven to package
https://maven.apache.org/plugins/maven-assembly-plugin/examples/sharing-descriptors.html
Found the above and managed to use it in my project!
Wednesday, June 9, 2021
Monday, May 24, 2021
Tomcat console access
For Tomcat v8.5.4 and above, the file <tomcat>/webapps/manager/META-INF/context.xml
has been adjusted:
<Context antiResourceLocking="false" privileged="true" >
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
</Context>
Change this file to comment the Valve
:
<Context antiResourceLocking="false" privileged="true" >
<!--
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
-->
</Context>
After that, refresh your browser (not need to restart Tomcat), you can see the manager page.
Tuesday, May 18, 2021
Multiple Tomcat Instances
https://dzone.com/articles/run-configure-multiple-instance-in-a-single-tomcat
https://crunchify.com/how-to-run-multiple-tomcat-instances-on-one-server/
Thursday, March 25, 2021
Useful site for generating sample codes for post JSON
https://reqbin.com/req/java/h4rnefmw/post-json-with-bearer-token-authorization-header
Wednesday, March 24, 2021
Java Client to do a HTTP post
Had so much trouble to do this on a J2EE 6 using Jersey 1 and Apache HTTPClient.
Finally resolved using pure java.io classes:
https://gist.github.com/dnetix/db23658cb308a0f2ac1b09f2ddb726d3
Monday, March 22, 2021
Dependency management in Maven
Interesting:
https://blogs.oracle.com/developers/mastering-maven-dependency-exclusions
Using Maven to generate "fat" jars or "uber" jars
This one worked for me:
http://tutorials.jenkov.com/maven/maven-build-fat-jar.html
Here are other ways to do it:
https://mkyong.com/maven/how-to-create-a-jar-file-with-maven/
Remember to put the xml outside of pluginManagement
https://stackoverflow.com/questions/33261354/maven-copy-dependecies-not-working
If you have some jars referenced as external jars, you can try this: (didn't work for me)
https://programmersought.com/article/90075878511/
Some useful background info:
https://imagej.net/Uber-JAR
What works for me:
<build>
<finalName>icommogateway</finalName>
<pluginManagement>
<!-- lock down plugins versions to avoid using Maven defaults (may be
moved to parent pom) -->
</pluginManagement>
<plugins>
<!-- download source code in Eclipse, best practice -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
<dependencySets>
<dependencySet>
<excludes>
<exclude>log4j:log4j</exclude>
</excludes>
</dependencySet>
</dependencySets>
</configuration>
</plugin>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArgs>
<!-- The parameter name and the parameter value appear in pairs, that
is, the first is the name, and the second is the value -->
<arg>-extdirs</arg>
<arg>M:/Development/Unica/Interact/912/interact.jar</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
To exclude some jars:
https://stackoverflow.com/questions/42412964/maven-depenency-plugin-copy-dependencies-exclude-single-artifact
https://github.com/albertattard/how-to-exclude-dependencies-from-maven-assembly-plugin/blob/master/pom.xml
https://blog.csdn.net/yh_zeng2/article/details/82859914