1

I have a working project setup with some beans and a WildFly 8.2.0. I just added the following class:

public class CatalogFilter implements Serializable {

    private static final long serialVersionUID = 3028220029652090421L;

    private final String catalogName;
    private Boolean active;

    public CatalogFilter(String catalogName) {
        this.catalogName = catalogName;
    }

    public String getCatalogName() {
        return this.catalogName;
    }

    public Boolean getActive() {
        return this.active;
    }

    public void setActive(Boolean active) {
        this.active = active;
    }

}

And now when I deploy an EAR with this class I get the following very weird exception:

Caused by: org.jboss.classfilewriter.InvalidBytecodeException: Cannot load variable at 2. Local Variables: Local Variables: [StackEntry [descriptor=Lorg/acme/catalog/CatalogFilter;, type=OBJECT], StackEntry [descriptor=Lorg/acme/catalog/CatalogElement;, type=OBJECT]]
at org.jboss.classfilewriter.code.CodeAttribute.aload(CodeAttribute.java:185)
at org.jboss.invocation.proxy.ProxyFactory$ProxyMethodBodyCreator.overrideMethod(ProxyFactory.java:150) [jboss-invocation-1.2.1.Final.jar:1.2.1.Final]
at org.jboss.invocation.proxy.AbstractSubclassFactory.overrideMethod(AbstractSubclassFactory.java:106) [jboss-invocation-1.2.1.Final.jar:1.2.1.Final]
at org.jboss.invocation.proxy.AbstractSubclassFactory.addInterface(AbstractSubclassFactory.java:363) [jboss-invocation-1.2.1.Final.jar:1.2.1.Final]
at org.jboss.invocation.proxy.ProxyFactory.generateClass(ProxyFactory.java:286) [jboss-invocation-1.2.1.Final.jar:1.2.1.Final]
at org.jboss.invocation.proxy.AbstractClassFactory.buildClassDefinition(AbstractClassFactory.java:207) [jboss-invocation-1.2.1.Final.jar:1.2.1.Final]
at org.jboss.invocation.proxy.AbstractClassFactory.defineClass(AbstractClassFactory.java:160) [jboss-invocation-1.2.1.Final.jar:1.2.1.Final]
at org.jboss.invocation.proxy.AbstractProxyFactory.getCachedMethods(AbstractProxyFactory.java:150) [jboss-invocation-1.2.1.Final.jar:1.2.1.Final]
at org.jboss.as.ejb3.component.stateless.StatelessComponentDescription$3.configure(StatelessComponentDescription.java:150)
at org.jboss.as.ee.component.DefaultComponentViewConfigurator.configure(DefaultComponentViewConfigurator.java:68)
at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:81)
... 6 more

If I remove the class from the EAR it works again. Google says there is a bug in WildFly 9 if you want to use the brand new Java 8 features, but I don't use WildFly 9 and neither are there any Java 8 features in the class.

What's wrong?

Stefan S.
  • 3,950
  • 5
  • 25
  • 77

1 Answers1

1

This exception had nothing to do with the class WildFly complained about. The remote interface had the following method:

default List<CatalogElement> findCatalogElements(CatalogFilter catalogFilter) throws CatalogManagerException {
    List<CatalogElement> result = findCatalogElements(catalogFilter.getCatalogName());
    if (catalogFilter.getActive() != null) {
        result.removeIf(e -> e.isActive() != catalogFilter.getActive().booleanValue());
    }
    return result;
}

For some reason, lambdas don't work, so we had to write the method like this:

default List<CatalogElement> findCatalogElements(CatalogFilter catalogFilter) throws CatalogManagerException {
    List<CatalogElement> result = findCatalogElements(catalogFilter.getCatalogName());
    if (catalogFilter.getActive() != null) {
        result.removeIf(new Predicate<CatalogElement>() {

            @Override
            public boolean test(CatalogElement e) {
                return e.isActive() != catalogFilter.getActive().booleanValue();
            }
        });
    }
    return result;
}
Stefan S.
  • 3,950
  • 5
  • 25
  • 77