3

これは私のコードです( SOの質問に投稿された返信から取得):

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

それはどういう意味で、どのように解決するのですか?

4

3 に答える 3

1

問題は、checkstyleがクラスパスでクラスを見つけられないことですjavax.faces.convert.ConverterException。この依存関係を追加しpom.xmlて問題を解決しました。

<dependency>
  <groupId>javax.faces</groupId>
  <artifactId>jsf-api</artifactId>
  <version>1.2</version>
</dependency>
于 2010-11-15T14:43:25.837 に答える
0

チェック対象のファイルを除外してみてください: checkstyleでファイルのすべてのチェックを抑制するにはどうすればよいですか?

于 2010-08-15T10:15:00.893 に答える
0

コード属性が削除されたjavax:javaee-api:6.0依存関係を使用している可能性があります。Karafのfeatures-maven-pluginを使用していない限り、org.jboss.spec:jboss-javaee-6.0を使用できます。

于 2012-07-09T03:03:49.587 に答える