JSF如何在Netbeans7.1中升级到Mojarra 2.1.21(只是sub jsf-api.jar和jsf-impl.jar失败)

时间:2013-05-23 13:33:00

标签: jsf jsf-2 glassfish mojarra

我想从Netbeans7.1(Glassfish 3.1.1)中的JSF实现Mojarra 2.1.3升级。

您可能会先问为什么我不只是升级到Netbeans7.3,原因包括它运行Glassfish 3.1.2.2并且我的Web应用程序中还有一些其他第三方软件尚未兼容Glassfish高于3.1.1,而且无论如何它只有Mojarra 2.1.6。

我曾经只能通过简单地替换/ glassfish / modules下的jsf-api.jar和jsf-impl.jar来升级Mojarra,但这不适用于:

https://maven.java.net/content/repositories/releases/com/sun/faces/jsf-api/2.1.21/jsf-api-2.1.21.jar https://maven.java.net/content/repositories/releases/com/sun/faces/jsf-impl/2.1.21/jsf-impl-2.1.21.jar

我收到以下错误:

    SEVERE: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:55)
Caused by: com.sun.enterprise.module.ResolveError: Failed to start Bundle Id [301] State [INSTALLED] [org.glassfish.web.weld-integration(Weld integration for glassfish):3.1.1]
at org.jvnet.hk2.osgiadapter.OSGiModuleImpl.start(OSGiModuleImpl.java:177)
at org.jvnet.hk2.osgiadapter.OSGiModuleImpl$2$1$1.loadClass(OSGiModuleImpl.java:344)
at com.sun.hk2.component.LazyInhabitant.loadClass(LazyInhabitant.java:124)
at com.sun.hk2.component.LazyInhabitant.fetch(LazyInhabitant.java:111)
at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:135)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:76)
at org.jvnet.hk2.component.Habitat$5.get(Habitat.java:701)
at java.util.AbstractList$Itr.next(AbstractList.java:345)
at java.util.AbstractCollection.toArray(AbstractCollection.java:124)
at java.util.ArrayList.addAll(ArrayList.java:472)
at com.sun.enterprise.v3.server.SnifferManagerImpl.getSniffers(SnifferManagerImpl.java:92)
at com.sun.enterprise.v3.server.SnifferManagerImpl.getSniffer(SnifferManagerImpl.java:120)
at com.sun.enterprise.v3.server.ApplicationLifecycle.getSniffersFromApp(ApplicationLifecycle.java:2140)
at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:375)
at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:219)
at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:131)
at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:91)
at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:82)
at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:67)
at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:139)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:76)
at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:253)
at com.sun.enterprise.v3.server.AppServerStartup.doStart(AppServerStartup.java:145)
at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:136)
at com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.start(GlassFishImpl.java:79)
at com.sun.enterprise.glassfish.bootstrap.GlassFishDecorator.start(GlassFishDecorator.java:63)
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishImpl.start(OSGiGlassFishImpl.java:69)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:117)
... 6 more
Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle org.glassfish.web.weld-integration [301]: Unable to resolve 301.0: missing requirement [301.0] package; (&(package=com.sun.faces.spi)(version>=2.1.0)) [caused by: Unable to resolve 213.1: missing requirement [213.1] package; (package=javax.faces) [caused by: Unable to resolve 211.1: missing requirement [211.1] package; (&(package=javax.el)(version>=2.2.1))]]
at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3443)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1727)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:922)
at org.jvnet.hk2.osgiadapter.OSGiModuleImpl.start(OSGiModuleImpl.java:169)

我尝试了特定于Web应用的JSF,但也失败了:

glassfish change default jsf impl

添加到web.xml:

<class-loader delegate="false" />
<property name="useBundledJsf" value="true" />

我收到错误:

Error occurred during deployment: Exception while loading the app :    
java.lang.IllegalStateException: ContainerBase.addChild: start:  
org.apache.catalina.LifecycleException: java.lang.RuntimeException: 
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! 
org.glassfish.weld.jsf.WeldFacesConfigProvider cannot be cast to 
com.sun.faces.spi.ConfigurationResourceProvider. Please see server.log for more details.

感谢建议。

2 个答案:

答案 0 :(得分:2)

尝试以下步骤

  • here
  • 下载jsf 2.1.21 jar
  • 将其重命名为javax.faces.jar。
  • 备份docroot \ glassfish \ modules
  • 中提供的javax.faces.jar
  • 使用docroot \ glassfish \ modules
  • 下载的javax.faces.jar粘贴并替换旧的javax.faces.jar
  • 删除osgi cache glassfish3 \ glassfish \ osgi以进行更改 生效

答案 1 :(得分:2)

好的,我终于有2个解决办法(仅)使Mojarra-2.1.21与Netbeans7.1一起运行。

首先,以下推荐的方法并不是我在Netbeans7.1中可以说的工作,它固执地拒绝识别安装了javax.faces.jar的服务器。

来自https://weblogs.java.net/blog/edburns/archive/2011/09/26/try-out-mojarra-220-snapshot?force=714

  

下载javax.faces.jar后,必须采取一些步骤将其安装在GlassFish 3.1或3.1.1中。

     

从modules目录中删除jsf-api.jar和jsf-impl.jar。

     

将javax.faces.jar放在modules目录中。

     

您必须修改domains / domain1 / config和lib / templates中的default-web.xml文件。在   每个目录,从default.web.xml文件中删除对jsf-api.jar和jsf-impl.jar的任何提及。   代替两个jar,添加对javax.faces.jar的引用。

无论我使用Netbeans7.1做什么(无论是清除osgi-cache和netbeans缓存还是删除然后在Netbeans7.1中重新添加服务器或重启glassfish3.1.1和/或netbeans7多少次。 1),Netbeans7.1不会看到javax.faces.jar。

如果您尝试将javax.faces.jar(仅)添加到您的Web应用程序库并在glassfish-web.xml中使用它来使用特定于Web应用程序的JSF,它将防止您的Netbeans7中的导入错误.1项目,但它仍然无法运行:

<class-loader delegate="false" />
<property name="useBundledJsf" value="true" />

我收到此错误:

Error occurred during deployment: Exception while loading the app :   
java.lang.IllegalStateException: ContainerBase.addChild: start:   
org.apache.catalina.LifecycleException: java.lang.RuntimeException:   
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED!   
org.glassfish.weld.jsf.WeldFacesConfigProvider cannot be cast to 
com.sun.faces.spi.ConfigurationResourceProvider.

原因如下所述:http://java.dzone.com/articles/upgrading-latest-mojarra

  

问题似乎是有两个版本   类路径上的ConfigurationResourceProvider:Web应用程序中的一个   level(您的捆绑jar文件)和父类加载器的第二个   级别(由GlassFish提供)。 WeldFacesConfigProvider扩展   父类加载器上的ConfigurationResourceProvider,但它结束了   将此转换为Web应用程序类的ConfigurationResourceProvider   装载机。 ...   解决方法:将缺少的依赖项添加到您的应用如果您无法跨类加载器进行强制转换,则必须使缺少的部分可用   到正确的类加载器。不替换你的javax.faces.jar   服务器的模块导致添加神奇的WeldFacesConfigProvider   你的应用。它包含在   glassfish3 \ glassfish \ modules \ weld-integration.jar简单地说   将它作为附加库添加到您的应用程序中   解决问题。

您现在有2个解决方法选项:

  1. 在您的网络应用程序库中包含weld-integration.jar,并使用glassfish-web.xml中的Web应用程序JSF设置运行。

  2. 肮脏的伎俩:在... / glassfish / modules / javax.faces.jar仍然存在并且也在您的Web应用程序库中,禁用或取消注释glassfish-web.xml中的位。然后它将与服务器javax.faces.jar一起运行(并将看到/modules/weld-integration.jar),Netbeans将看到用于导入的特定于Web应用程序的库。

  3. 这是不能令人满意的,我不认为这个问题得到了充分的回答。

    问:如何在NetBeans7.1中将JSF Mojarra 2.1.21作为Glassfish3.1.1服务器JSF库运行?

    而且,我不能只升级Netbeans + Glassfish的原因是我在使用3.1.1以上版本的Glassfish时遇到了ObjectDB的多个问题,这就是我对安装JSF Mojarra 2.1如此坚定的原因。 21关于Netbeans7.1 + Glassfish3.1.1。

    感谢任何进一步的建议。

相关问题