Recent Notes
Displaying keyword search results 1 - 10
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...
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 James on January 10, 2011 15:20:10
Last update: February 03, 2012 10:10:14
Dojo ShrinkSafe: http://shrinksafe.dojotoolkit.org/ : command line utility written in Java, based on Rhino - JavaScript engine written in Java.
Douglas Crockford's JSMIN: http://crockford.com/javascript/jsmin : command line utility written in C, can download MS-DOS exe.
Dean Edwards' Packer: http://dean.edwards.name/packer/ : online tool, or .NET, Perl, PHP application.
YUI Compressor: http://developer.yahoo.com/yui/compressor/ : command line utility written in Java.
Google Closure Compiler : command line Java application, web application, or RESTful API.
One problem is, the compressor utility may not be 100% reliable. So make sure to test the compressed script.