玻璃鱼 3.1 + MyFaces - 类格式错误
我正在尝试使用 MyFaces 覆盖 Glassfish 中的 Mojarra。我已将 myfaces-impl 依赖项放入 Maven 中,并删除了 RI 依赖项 - jsf-api.jar 和 jsf-impl.jar。我还很好地要求 Glassfish 使用捆绑的 JSF 实现,如 此处< /a> 在 glassfish-web.xml 中使用这些行:
<glassfish-web-app error-url="">
<context-root>/Grandis</context-root>
<class-loader delegate="false" />
<property name="useBundledJsf" value="true"/>
</glassfish-web-app>
但是,当我尝试部署应用程序时,出现以下错误:
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/webapp/FacesServlet
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at org.glassfish.web.loader.WebappClassLoader.findClass(WebappClassLoader.java:927)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1486)
我还尝试下载 MyFaces罐子(myfaces-2.1.3.jar,myfaces-api-2.1.3.jar,myfaces-bundle-2.1.3.jar和一堆 apache commons 库)手动并将它们放入应用程序的类路径中。相同的结果。
有什么想法吗?
更新:当我通过maven添加依赖项时,在WAR内发布WEB-INF/lib的内容(仅不包括我自己的jar):
commons-beanutils-1.8.3.jar
commons-codec-1.3.jar
commons-collections-3.2.jar
commons-digester-1.8.jar
commons-logging-1.1.1.jar
javaee-api-6.0.jar
jstl-1.1.2.jar
log4j-1.2.16.jar
myfaces-api-2.1.3.jar
myfaces-impl-2.1.3.jar
org.eclipse.persistence.antlr-2.0.0.jar
org.eclipse.persistence.asm-2.0.0.jar
org.eclipse.persistence.core-2.0.0.jar
org.eclipse.persistence.jpa-2.0.0.jar
prettyfaces-jsf2-3.3.0.jar
primefaces-3.0.M4-SNAPSHOT.jar
standard-1.1.2.jar
xpp3_min-1.1.4c.jar
xstream-1.3.1.jar
I am trying to override Mojarra in Glassfish with MyFaces. I have put myfaces-impl dependency in maven and removed the RI dependencies - jsf-api.jar and jsf-impl.jar. I've also asked Glassfish nicely to use bundled JSF implementation as shown in here using these lines in glassfish-web.xml:
<glassfish-web-app error-url="">
<context-root>/Grandis</context-root>
<class-loader delegate="false" />
<property name="useBundledJsf" value="true"/>
</glassfish-web-app>
However, when I try to deploy the application I get the following error:
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/webapp/FacesServlet
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at org.glassfish.web.loader.WebappClassLoader.findClass(WebappClassLoader.java:927)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1486)
I also tried downloading MyFaces jars(myfaces-2.1.3.jar, myfaces-api-2.1.3.jar, myfaces-bundle-2.1.3.jar and a bunch of apache commons libraries) manually and putting them in the classpath of application. Same result.
Any ideas?
UPDATE: Posting the contents of WEB-INF/lib inside WAR when I add dependency through maven (excluding only my own jars):
commons-beanutils-1.8.3.jar
commons-codec-1.3.jar
commons-collections-3.2.jar
commons-digester-1.8.jar
commons-logging-1.1.1.jar
javaee-api-6.0.jar
jstl-1.1.2.jar
log4j-1.2.16.jar
myfaces-api-2.1.3.jar
myfaces-impl-2.1.3.jar
org.eclipse.persistence.antlr-2.0.0.jar
org.eclipse.persistence.asm-2.0.0.jar
org.eclipse.persistence.core-2.0.0.jar
org.eclipse.persistence.jpa-2.0.0.jar
prettyfaces-jsf2-3.3.0.jar
primefaces-3.0.M4-SNAPSHOT.jar
standard-1.1.2.jar
xpp3_min-1.1.4c.jar
xstream-1.3.1.jar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从
/WEB-INF/lib
中的 JAR 列表中:删除它。不仅 Glassfish 已经 附带了它(我不使用 Maven,但从我读到的内容来看,您应该将其标记为
provided
),而且它还包含Mojarra(JSF 参考实现)库也解释了您的问题。它与 MyFaces 库冲突。此外,Glassfish 还已经附带 JPA 和 JSTL(1.2!),因此也将它们从构建中删除。
From your JAR listing in
/WEB-INF/lib
:Remove this. Not only Glassfish already ships with it (I don't do Maven, but from what I've read is that you should mark it as
provided
), but this also contains Mojarra (the JSF reference implementation) libraries as well which in turn explains your problem. It was conflicting with MyFaces libraries.Further, Glassfish also already ships with JPA and JSTL (1.2!), so remove them from the build as well.