Recent Notes
Displaying keyword search results 1 - 10
Created by zhidao on April 06, 2012 13:03:20
Last update: April 06, 2012 13:03:20
1. pom.xml
<plugin>
<groupId>org.jvnet.jax-ws-commons<...
2. To ignore SSL cert errors:
<configuration>
<args>
<arg>...
3. To resolve class name conflict ("Use a class customization to resolve this conflict" error):
<configuration>
<args>
<arg>-B-Xaut...
Created by Fang on February 27, 2012 12:19:19
Last update: February 27, 2012 12:19:19
Mapping Java objects to Jackson JSON is pretty simple. But if you name a JSON field wrong, you'll get the "Unrecognized field ... (Class ...), not marked as ignorable" error. The rule for mapping a Java bean attribute name to a JSON field name is: lower all leading capital letters until the first lower case letter .
For example, this Java class:
package com.example;
public class Person {
...
maps to this JSON string:
{
"firstName": "Jane",
"lastName": "...
Test code:
package com.example;
import java.net.URL;
...
Created by Fang on February 21, 2012 20:33:58
Last update: February 21, 2012 20:33:58
You can customize Tomcat error page with error code:
<error-page>
<error-code>404</error-code>
...
or Java exception type:
<error-page>
<exception-type>java.lang.Throwab...
Either error-code or exception-type is required, but not both. There's no way to aggregate error codes, such as:
<!-- This does not work! -->
<error-page>
...
Customizing error pages is about the only way to suppress the default stack trace in Tomcat in case of an unhandled exception.
Created by Fang on February 15, 2012 21:11:02
Last update: February 15, 2012 21:11:02
Error:
java.lang.NoClassDefFoundError: org/slf4j/helpers/...
Cause: had slf4j-nop as dependency, but did not have slf4j-api.
Solution: add dependency for slf4j-api.
<dependency>
<groupId>org.slf4j</groupId>
...
Created by Fang on February 15, 2012 21:03:57
Last update: February 15, 2012 21:03:57
Error:
java.lang.NoClassDefFoundError: org/slf4j/impl/Sta...
Soluton: add Maven dependency for one of slf4j-nop , slf4j-simple , slf4j-log4j12 , slf4j-jdk14 . For example:
<dependency>
<groupId>org.slf4j</groupId>
...
or
<dependency>
<groupId>org.slf4j</groupId>
...
org.hibernate.MappingException: An AnnotationConfiguration instance is required to use mapping class
Created by Fang on February 15, 2012 20:52:57
Last update: February 15, 2012 20:52:57
I got this error while using Hibernate 3.5.6:
org.hibernate.MappingException: An AnnotationConfi...
where I used annotations for mapping in the ExampleEntity class.
Problem : I initialized the session factory with Configuration :
sessionFactory = new Configuration()
.co...
Solution : should use AnnotationConfiguration instead:
sessionFactory = new AnnotationConfiguration()
...
Additional Note: Hibernate 4.1 didn't seem to mind ( Configuration worked fine).
Created by Fang on February 08, 2012 21:21:01
Last update: February 08, 2012 21:21:17
Just a reminder that I got this error when I set the Java system property javax.net.ssl.trustStore to a non-existing file (typo). The full error message when running Maven was:
[ERROR] java.lang.RuntimeException: Unexpected e...
Created by Fang on February 08, 2012 21:15:00
Last update: February 08, 2012 21:15:00
This was the error message:
[ERROR] sun.security.validator.ValidatorExceptio...
The certificate was actually signed by Verisign, but somehow failed to pass Java cert validation.
To resolve the problem:
Download the cert from the server (with RetrieveSSLCert , for example)
Import the certificate into the keystore:
$ keytool -import -trustcacerts -alias myserver -f...
Define MAVEN_OPTS :
$ export MAVEN_OPTS='-Djavax.net.ssl.trustStore=/h...
The quotes must exist for the value of MAVEN_OPTS , and the path must be absolute ( ~/etc/mavenKeyStore.jks does not work).
Created by Fang on January 10, 2010 00:19:30
Last update: January 31, 2012 16:28:42
Maven is a powerful yet complex tool. When I started learning Maven, the first obstacle was, of course, its complexity. The second, was the lack of documentation that can get me off the ground quickly. This tutorial is an attempt to create a pragmatic guide that aims to get you familiar with Maven in the quickest way possible. The main theme is to get you on some hands on experience to start out and lead you through the creation of a simple Java EE project as quickly as possible. Instead of trying to give you a good read, I try to get you on the journey right away. The topics are roughly ordered by the logical sequence but you can jump around in any way...
Created by zhidao on January 23, 2012 15:00:19
Last update: January 23, 2012 15:00:19
The domain object is annotated @Entity , but Java runtime complains that it's not an entity class.
Cause: : class not listed in persistence.xml , or persistence.xml misplaced, or multiple persistence.xml files existed.