I have a real weird problem trying to deploy my portlet.
The error shown in the log is:
Context initialization failed
java.lang.IllegalArgumentException: class myPackage.SqlTimestampPropertyEditor is not assignable to interface java.beans.PropertyEditor
at org.springframework.util.Assert.isAssignable(Assert.java:368)
at org.springframework.util.Assert.isAssignable(Assert.java:351)
at org.springframework.beans.factory.config.CustomEditorConfigurer.postProcessBeanFactory(CustomEditorConfigurer.java:199)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:664)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:446)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
This is my Property Editor:
package myPackage;
import myPackage.util.Util;
import java.beans.PropertyEditorSupport;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
public class SqlTimestampPropertyEditor extends PropertyEditorSupport {
public static final String TIMESTAMP_BATCH_PATTERN = "yyyy-MM-dd HH:mm:ss.SSS";
private final SimpleDateFormat sdf;
/**
* uses default pattern yyyy-MM-dd for date parsing.
*/
public SqlTimestampPropertyEditor() {
this.sdf = new SimpleDateFormat(SqlTimestampPropertyEditor.TIMESTAMP_BATCH_PATTERN);
}
/**
* Uses the given pattern for dateparsing, see {@link SimpleDateFormat} for
* allowed patterns.
*
* @param pattern the pattern describing the date and time format
* @see SimpleDateFormat#SimpleDateFormat(String)
*/
public SqlTimestampPropertyEditor(SimpleDateFormat dateFormat) {
this.sdf = dateFormat;
}
/**
* @see java.beans.PropertyEditorSupport#setAsText(java.lang.String)
*/
@Override
public final void setAsText(String text) throws IllegalArgumentException {
try {
if (!Util.emptyString(text)) {
setValue(new Timestamp(this.sdf.parse(text).getTime()));
}
} catch (ParseException ex) {
throw new IllegalArgumentException("Non se pudo parsear o timestamp: " + ex.getMessage(), ex);
}
}
/**
* Format the Timestamp as String, using the specified DateFormat.
*/
@Override
public final String getAsText() {
Timestamp value = (Timestamp) getValue();
return (value != null ? this.sdf.format(value) : "");
}
}
The weirdest thing is that this just happens sometimes, and it's solved by itself, and the log say "PortalPack Message : Deployed Successfully." but I can't add the portlet to the webspace, even though, I can see it deployed into the glassfish console.
it doesn't make any sense to me and I'd really appreciate any kind of help with this issue... Thanks in advance!