running the springMVC-petclinic-hibernate sample app,
got this:
SEVERE: Exception Processing ErrorPage[exceptionType=java.lang.Exception, location=/WEB-INF/jsp/uncaughtException.jsp]
org.apache.jasper.JasperException: /WEB-INF/jsp/uncaughtException.jsp(1,1) Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
solution: create a folder springMVC-petclinic-hibernate\web\WEB-INF\lib, then put jstl.jar and standard.jar inside it.
reason: even though the jstl.jar is already in classpath, it’s ignored by the servlet container; have to put the jar along with jsp pages manually.
November 21, 2008
Failed to load or instantiate TagLibraryValidator class
November 19, 2008
hibernate-validator-3.1.0.GA not compatible with Core_hibernate-distribution-3.3.1.GA
Use hibernate-validator-3.1.0.GA with Core_hibernate-distribution-3.3.1.GA,
got this error:
java.lang.NoSuchMethodError: org.hibernate.event.PreUpdateEvent.getSource()Lorg/hibernate/engine/SessionImplementor;
at org.hibernate.validator.event.ValidateEventListener.onPreUpdate(ValidateEventListener.java:177)
at org.hibernate.action.EntityUpdateAction.preUpdate(EntityUpdateAction.java:237)
solution: download hibernate-distribution-3.3.0.SP1, use the old hibernate3.jar to replace the new one in distribution-3.3.1.GA.
http://opensource.atlassian.com/projects/hibernate/browse/HV-66
java.lang.NoSuchFieldError: name org.slf4j.impl.Log4jLoggerAdapter.(Log4jLoggerAdapter.java
problem: AnnotationConfiguration cfg = new AnnotationConfiguration(); fails
and javax.servlet.ServletException: Servlet.init() for servlet PersistentController threw exception
java.lang.NoSuchFieldError: name
org.slf4j.impl.Log4jLoggerAdapter.<init>(Log4jLoggerAdapter.java:75)
solution: download a new http://www.slf4j.org/dist/slf4j-1.5.2.tar.gz
(having multiple javassist.jar doesn’t matter)
http://groups.google.com/group/comp.lang.java.programmer/browse_thread/thread/c6d647699b02fb5e/becc5c738902506b?tvc=2#becc5c738902506b
November 17, 2008
servlet problem: hibernate-validator (requestValidator.getInvalidValues(data) fails)
This section of code fails (data is the bean object):
InvalidValue[] validationMessages;
ClassValidator requestValidator = new ClassValidator(data.getClass());
validationMessages = requestValidator.getInvalidValues(data); //fails here!
Don’t know why but this works (“hobby” is one of the fields of the data bean):
requestValidator.getInvalidValues(data, “hobby”)
So, I modified the whole section to use request’s getParameterMap to traverse each bean property:
InvalidValue[] validationMessages;
List<InvalidValue[]> validationMsgList = new ArrayList<InvalidValue[]>();
ClassValidator requestValidator = new ClassValidator(data.getClass());
Map pMap = request.getParameterMap();
Iterator ParIt = pMap.entrySet().iterator();
while (ParIt.hasNext()) {
Map.Entry pairs = (Map.Entry) ParIt.next();
String key = “” + pairs.getKey();
validationMessages = requestValidator.getInvalidValues(data, key);
validationMsgList.add(validationMessages);
}
App finally runs.
November 14, 2008
Java regex (Regular expression)
regex java
US Zip Code: \d{5}(?:-\d{4})?
A zip code has two formats: five digits OR five digits, a hyphen and four more digits.
\d{5}: the pattern starts with five digits. The 5 within the braces indicates that the previous pattern should match five times.
(?:-\d{4})?: It’s a non-capturing parenthesis, starts with (?:. Question mark at the end means optional.
-\d{4}: a hyphen followed by four digits
US SSN(social security number): \d{3}([-]?)\d{2}\1\d{4}
the digits are written in two different ways: as nine digits or as three digits, a hyphen, two digits, another hyphen and four more digits.
\d{3}: The pattern starts with three digits
([-]?): is a capturing group. Inside the group is an optional hyphen. Whatever matches inside the parentheses will be remembered and can be recalled later in the pattern as \1.
\d{2}: two more digits.
\1: the symbol for the grouped pattern from earlier in the regular expression. If a hyphen was used earlier in the expression, then a hyphen must be used here. If a hyphen was not matched earlier, then a hyphen cannot be entered here.
\d{4}: four more digits.
User ID: [a-zA-Z]{3,5}[a-zA-Z0-9]?\d{2}
might be from three to five letters followed by three digits or three to six letters followed by two digits.
Note: When writing regular expressions in Java, each \ character must be written as double backslashes, \\.
1. Square brackets define a character class. [xyz] will match x, y or z, but only one of them.
2. If the class starts with ^, then it will match all characters that are not listed inside the brackets: [^abc] any character except a, b or c (negation)
3. A hyphen can be used to include a range of characters: [a-z] will match any lowercase letter. [a-zA-Z] a through z or A through Z, inclusive (range)
| Character Class | Meaning |
|---|---|
| . | Any character, except line terminators |
| \d | A digit: [0-9] |
| \D | A non-digit: [^0-9] |
| \s | A whitespace character: [ \t\n\x0B\f\r] |
| \S | A non-whitespace character: [^\s] |
| \w | A word character: [a-zA-Z_0-9] |
| \W | A non-word character: [^\w] |
November 13, 2008
using local Subversion server with Netbeans
tool subversion
1. download CollabNet Subversion Server and Client v1.5.4 (for Windows) and install (Apache mod is not necessary)
2. make local repository from command line c:\: svnadmin create svn_repository
3. (folder c:\svn_repository will be created with some svn contents)
4. (from server point of view) import a project into the repository, from Netbeans: right click the project……, repository url: file:///svn_repository
also, to delete a repository, just do it through windows explorer. no this command from svnadmin.
November 5, 2008
access Google Data APIs, behind proxy
google, java
(libraries needed: gdata, JavaMail, servlet2.4)
In Eclipse, under application’s context menu “run as, run configurations”:
program arguments: xxzhao@gmail.com xxzhaospsw
VM arguments: -Dhttp.proxyHost=proxysrv007-zhengxian -Dhttp.proxyPort=8080 -Dhttps.proxyHost=proxysrv007-zhengxian -Dhttps.proxyPort=8080 -Dhttp.proxyUser=liezi.info\xxing -Dhttp.proxyPassword=e*********