What does this checkstyle message mean?

This is my code (taken from the answer sent to the 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();
  }
}

Here is what it says 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

What does this mean and how to solve it?

+3
source share
3 answers

The problem is that checkstyle cannot find the class javax.faces.convert.ConverterExceptionin the classpath. Adding this dependency to pom.xmlsolved the problem:

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

You can try and exclude the file for checking: How to suppress all file checks in checkstyle

0
source

, javax: javaee-api: 6.0, . org.jboss.spec: jboss-javaee-6.0, -maven-plugin Karaf.

0

Source: https://habr.com/ru/post/1758259/


All Articles