我有一个在WildFly 10.0.0.CR5容器中运行的servlet。我正在向servlet发送一个包含# Pig Latinify
vowels = ['a', 'e', 'i', 'o', 'u', 'y'] ## added 'y', .e.g hymn --> ymnhay
consonants = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z']
def pig_latinify():
user_input = raw_input("Enter a word to be translated: ").lower()
# If the first character in input is a vowel add 'yay' to input and print.
if user_input[0] in vowels[0:]:
print "\n%s begins with a vowel." %user_input
pig_output = user_input + "yay"
print "\n\t%s becomes: %s \n" %(user_input,pig_output)
else:
print "\n%s Doesn't begin with a vowel." %user_input
for i,l in enumerate(user_input):
if l in vowels:
x = user_input[:i] ## first part of word, to be moved
pig_output = user_input[i:] + x + "ay"
print "\n\t%s becomes: %s \n" %(user_input,pig_output)
break ## exit the for loop
return
pig_latinify()
的POST请求,该请求在servlet中得到验证:
SOAPMessage
一切都很好,但当它达到private void unmarshalXmlMsg(final Node node, final JAXBContext jaxbContext, final URL resourceUrl) {
try {
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = schemaFactory.newSchema(resourceUrl);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
unmarshaller.setSchema(schema);
unmarshaller.setEventHandler(e -> false);
Object unmarshalledObj;
String localName = node.getLocalName();
String classpath = CLASS_MAP.get(localName);
if (classpath == null) {
unmarshalledObj = unmarshaller.unmarshal(node);
} else {
unmarshalledObj = unmarshaller.unmarshal(node, Class.forName(classpath));
}
if (unmarshalledObj instanceof JAXBElement<?>) {
routeMessage((JAXBElement<?>) unmarshalledObj);
}
} catch (JAXBException | SAXException | ClassNotFoundException e) {
logger.error("Error unmarshalling xml from body of soapMessage", e);
}
}
时,我得到以下unmarshaller.setEventHandler(e -> false);
:
Exception
将其更改为以下内容可修复错误,其他所有内容都可以正常运行:
java.lang.ClassCastException: Cannot cast
com.lmco.spacefence.incoming.service.IncomingMessageServlet$$Lambda$154/468475414
to javax.xml.bind.ValidationEventHandler
我知道unmarshaller.setEventHandler(new ValidationEventHandler() {
@Override
public boolean handleEvent(ValidationEvent arg0) {
return false;
}
});
在这种情况下有效,但我不确定为什么它不能在WildFly容器中工作。提前感谢您的帮助。
编辑:我还应注意上述e -> false
是由此引起的:
Exception
编辑:我还检查了java.lang.BootstrapMethodError: call site initialization exception
和java -version
,两者都是1.8.0_05。我尝试创建一个javac -version
并在将其发送到servlet之前在我的客户端代码中以相同的方式设置事件处理程序,并且它工作正常。这让我相信这是WildFly中的一个问题...但我不知道从哪里开始。请帮忙!!!!
答案 0 :(得分:-1)
您好我认为ValidationEventHandler和Unmarshaller不会按预期工作接受功能接口\λ表达式。我试着看一下jar api和具体实现。 JAXB-2.2.x的