WildFly 8中的InvalidBytecodeException [英] InvalidBytecodeException in WildFly 8
问题描述
我有一个正在运行的项目设置,其中包含一些bean和WildFly 8.2.0.我刚刚添加了以下课程:
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;
}
}
现在,当我使用此类部署EAR时,会收到以下非常奇怪的异常:
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
如果我从EAR中删除了该类,它将再次起作用. Google表示,如果您想使用全新的Java 8功能,则WildFly 9中存在一个错误,但是我不使用WildFly 9,并且该类中也没有Java 8功能.
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.
怎么了?
推荐答案
此异常与WildFly抱怨的类无关.远程接口具有以下方法:
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;
}
由于某种原因,lambda不起作用,因此我们不得不编写如下方法:
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;
}
这篇关于WildFly 8中的InvalidBytecodeException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!