Recent Notes
Displaying keyword search results 41 - 50
Created by Dr. Xi on February 25, 2012 09:25:23
Last update: February 25, 2012 09:25:23
By default, Java uses $JAVA_HOME/jre/lib/security/cacerts to very an SSL certificate. You can add a certificate to this file:
$ keytool -importcert -alias VeriSignClass3Interna...
The default password for cacerts is: "changeit".
Created by Dr. Xi on May 02, 2011 15:59:37
Last update: February 25, 2012 09:16:37
This code snippet gets the default keystore used by the Java keytool and displays the list of aliases along with the key type (certificate or private key).
import java.io.File;
import java.io.FileInputSt...
The default keystore used by the above code is: $HOME/.keystore .
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 16, 2012 12:27:55
Last update: February 16, 2012 12:34:58
Here are some ways to run a main method using Maven:
Use the exec plugin:
mvn exec:java -Dexec.mainClass="com.example.App"
or, with arguments:
mvn exec:java -Dexec.mainClass="com.example.App" -...
Attach it to a build phase with the build element:
<build>
<plugins>
<plugin>
...
If you want to run main from Maven, it's probably just some test code. You are better off just to write a test case, or call the main method from a test class:
package com.example;
import junit.framework...
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 10, 2012 16:17:13
Last update: February 10, 2012 16:17:13
The annotation @org.hibernate.annotations.Type overrides the default hibernate mapping type used for a column. This can usually be omitted since Hibernate normaly infers the correct type to use.
But @Type is required in ambiguous scenarios such as a java.util.Date attribute, which can map to SQL DATE , TIME or TIMESTAMP . You use the @Type("timestamp") annotation to tell Hibernate that a timestamp converter should be used, which identifies an instance of org.hibernate.type.TimestampType .
@Type can also be used to identify custom type converters, which can be defined with @TypeDef at the class level:
@TypeDefs(
{
@TypeDef(
na...
or with an xml file:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mappi...
Created by meiu on February 09, 2012 09:55:26
Last update: February 09, 2012 09:55:26
In the package explorer pane:
Right click on the folder
Move mouse to Build Path
Select Use as Source Folder
To revert a source folder selection: mouse over Build Path and select Remove from Build Path .
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...