这个checkstyle信息意味着什么?

时间:2010-08-05 17:24:20

标签: java checkstyle

这是我的代码(摘自SO question发布的回复):

package my;
import java.net.MalformedURLException;
import java.net.URL;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;
@FacesConverter(forClass = URL.class)
public class UrlConverter implements Converter {
  @Override
  public final Object getAsObject(
    final FacesContext context,
    final UIComponent component,
    final String value) throws ConverterException {
    try {
        return new URL(value);
    } catch (MalformedURLException ex) {
        throw new ConverterException(
            String.format("Cannot convert %s to URL", value),
            ex
        );
    }
  }
  @Override
  public final String getAsString(
    final FacesContext context,
    final UIComponent component,
    final Object value) {
    return ((URL)value).toString();
  }
}

这是maven-checkstyle-plugin所说的:

UrlConverter.java:0: Got an exception - java.lang.ClassFormatError: 
Absent Code attribute in method that is not native or abstract 
in class file javax/faces/convert/ConverterException

它是什么意思以及如何解决它?

3 个答案:

答案 0 :(得分:0)

您可以尝试排除要检查的文件: How do I suppress all checks for a file in checkstyle

答案 1 :(得分:0)

问题是checkstyle在类路径中找不到javax.faces.convert.ConverterException类。将此依赖项添加到pom.xml解决了问题:

<dependency>
  <groupId>javax.faces</groupId>
  <artifactId>jsf-api</artifactId>
  <version>1.2</version>
</dependency>

答案 2 :(得分:0)

您可能正在使用已删除代码属性的javax:javaee-api:6.0依赖项。你可以使用org.jboss.spec:jboss-javaee-6.0,只要你没有使用Karaf的features-maven-plugin。