3

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!

elcadro
  • 1,482
  • 3
  • 21
  • 45
  • This may just be a typo when you obviscated the code for posting, but the package in the exception doesn't seem to match the package in the Java code. – CodeChimp Mar 20 '13 at 13:23
  • Yep, u are right, it's just a typo. – elcadro Mar 20 '13 at 15:16
  • I'm not even near to be sure about this, but the error didn't appear to me again, after delete the Netbeans cache folder. Anyone could confirm it? – elcadro Mar 22 '13 at 11:01
  • Could it be that you had a different version of java.beans.PropertyEditor in some jar somewhere in your cache which was not compatible with your PropertyEditor? Clearing the cache would have got rid of that old jar perhaps. – Mark Chorley Apr 13 '13 at 20:55
  • Could be something like that, but not sure if the problem was a jar or any other thing. Anyway, I'm not even sure if this was what fix my problem (but it's true that it didn't appear again so far) I'd like someone to confirm this... – elcadro Apr 17 '13 at 06:34

0 Answers0