JSF如何升级到Netbeans7.1中的Mojarra 2.1.21(只是sub jsf-api.jar和jsf-impl.jar失败) [英] JSF how upgrade to Mojarra 2.1.21 in Netbeans7.1 (just sub jsf-api.jar and jsf-impl.jar fails)

查看:130
本文介绍了JSF如何升级到Netbeans7.1中的Mojarra 2.1.21(只是sub jsf-api.jar和jsf-impl.jar失败)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从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/conten t / 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。在com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
处com.sun.enterprise.glassfish反映.Method.invoke(Method.java:597)
。 bootstrap.ASMain.main(ASMain.java:55)
导致:com.sun.enterprise.module.ResolveError:无法启动Bundle Id [301] State [INSTALLED] [org.glassfish.web.weld-整合(玻璃鱼类的焊接集成):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)$ b $ 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.processApplica (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)
在com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.s tart(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
造成者:org.osgi.framework.BundleException:bundle中的未解析约束org.glassfish.web.weld-integration [301]:无法解析301.0:缺少需求[301.0]包; (&(package = com.sun.faces.spi)(version> = 2.1.0))[由于:无法解析213.1:缺少需求[213.1]包; (package = javax.faces)[由:无法解析211.1:缺少需求[211.1]包; (&(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更改默认jsf impl



添加到web.xml中:

  < class-loader delegate =false/> 
< property name =useBundledJsfvalue =true/>

我收到错误消息:

 部署期间发生错误:加载应用程序时发生异常:
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不能转换为
com.sun.faces.spi.ConfigurationResourceProvider。有关更多详细信息,请参阅server.log。

感谢您的建议。

解决方案

好的,我终于有了2个解决方法(仅限于)使用Netbeans7.1运行Mojarra-2.1.21。

首先,下面的建议方法并不像我在Netbeans7.1中所说的那样工作,它顽固地拒绝识别安装的javax.faces.jar服务器。



From https://weblogs.java。 net / blog / edburns / archive / 2011/09/26 / try-out-mojarra-220-snapshot?force = 714
$ b


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



删除jsf-api。 jar和jsf-impl.jar来自modules目录。



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



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

无论我做什么Netbeans7.1(无论是清除osgi缓存和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 =useBundledJsfvalue =true/>

我得到这个错误:

 部署期间发生错误:加载应用程序时发生异常:
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不能转换为
com.sun.faces.spi.ConfigurationResourceProvider。

原因在这里描述: http://java.dzone.com/articles/upgrading-latest-mojarra


问题似乎是在类路径中有两个版本的
ConfigurationResourceProvider:一个在web应用程序
级别(您的捆绑jar文件),另一个在父级类加载器
级别(由GlassFish提供)。 WeldFacesConfigProvider在父类加载器上扩展了
ConfigurationResourceProvider,但它将
转换为Web应用程序类
加载器中的ConfigurationResourceProvider。 ...
解决方法:将缺失的依赖项添加到您的应用中如果您无法跨类加载器进行投射,则必须将缺少的部分可用
添加到正确的类加载器。在
服务器模块中不替换javax.faces.jar会导致添加魔术WeldFacesConfigProvider到
您的应用程序。它被包含在
glassfish3 \glassfish\modules\weld-integration.jar中,并且只需
把它作为一个额外的库文件添加到您的应用程序中,您也可以
解决这个问题。 / p>

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


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


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

这是不令人满意的,我不认为这个问题完全得到了答案。

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


$ b 同样,我不能只升级Netbeans + Glassfish的原因是我在3.1.1版本的Glassfish上使用ObjectDB时遇到了多个问题,这就是为什么我坚持在Netbeans7.1 + Glassfish3.1.1上安装JSF Mojarra 2.1.21的原因。



感谢您提供任何进一步的建议。

I want to upgrade from JSF implementation Mojarra 2.1.3 in Netbeans7.1 (Glassfish 3.1.1).

You might ask first why I don't just upgrade to Netbeans7.3, and the reasons include that it it runs Glassfish 3.1.2.2 and that I have some other 3rd party software in my web application that is not yet compatible with Glassfish higher than 3.1.1, and besides it only has Mojarra 2.1.6 anyway.

I used to be able to upgrade Mojarra by simply replacing jsf-api.jar and jsf-impl.jar under /glassfish/modules, but that does not work with:

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

I get the following error:

    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)

I tried web app specific JSF but that also fails:

glassfish change default jsf impl

Added to web.xml:

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

I get the error:

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.

Grateful for suggestions.

解决方案

OK I finally have 2 workarounds (only) for getting Mojarra-2.1.21 running with Netbeans7.1.

Firstly, the following recommended approach does not as far as I can tell work in Netbeans7.1, it stubbornly refuses to recognise the server installed javax.faces.jar.

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

Once you download the javax.faces.jar, you must take some steps to install it in GlassFish 3.1 or 3.1.1.

Remove jsf-api.jar and jsf-impl.jar from the modules directory.

Put javax.faces.jar in the modules directory.

You must modify the default-web.xml file in domains/domain1/config and lib/templates. In each directory, remove any mention of jsf-api.jar and jsf-impl.jar from the default.web.xml file. In place of the two jars, add a reference to javax.faces.jar.

No matter what I do with Netbeans7.1 (and no matter whether clear osgi-cache and netbeans cache or whether remove then re-add server in Netbeans7.1 or how many times I restart glassfish3.1.1 and/or netbeans7.1), Netbeans7.1 will NOT see javax.faces.jar.

If you try to add the javax.faces.jar (only) to your web app libs and use this in glassfish-web.xml to for it to use web-app specific JSF, it will prevent import errors in your Netbeans7.1 project, but it still will not run:

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

I get this error:

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.

The reason is described here: http://java.dzone.com/articles/upgrading-latest-mojarra

The issue seems to be that there are two versions of ConfigurationResourceProvider on the class path: one at the web app level (your bundled jar file) and a second at the parent class loader level (provided by GlassFish). WeldFacesConfigProvider extends ConfigurationResourceProvider at the parent class loader, but it ends up casting this to ConfigurationResourceProvider at the web app class loader. ... Workaround: Adding the missing dependency to your app If you can't cast across class loaders you have to make the missing part available to the right class-loader. Not replacing the javax.faces.jar in your server's modules leads to adding the magic WeldFacesConfigProvider to your app. It is contained in the glassfish3\glassfish\modules\weld-integration.jar and by simply putting that as an additional library to your application you also solve the issue.

You now have 2 workaround choices:

  1. Include the weld-integration.jar in your web app libs, and run with web app JSF settings in glassfish-web.xml.

  2. Dirty trick: With .../glassfish/modules/javax.faces.jar still in place and also in your web app libs, disable or uncomment the bit in your glassfish-web.xml. It will then run with the server javax.faces.jar (and will see /modules/weld-integration.jar), and Netbeans will see the web app specific lib for imports.

This is unsatisfactory, I don't consider the question fully answered.

Q: How can one run JSF Mojarra 2.1.21 as Glassfish3.1.1 server JSF libs in NetBeans7.1 ?

And again, the reason I can't just upgrade Netbeans+Glassfish is that I have multiple problems with ObjectDB with versions of Glassfish above 3.1.1, which is why I am so adamant about installing JSF Mojarra 2.1.21 on Netbeans7.1+Glassfish3.1.1.

Grateful for any further suggestions.

这篇关于JSF如何升级到Netbeans7.1中的Mojarra 2.1.21(只是sub jsf-api.jar和jsf-impl.jar失败)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆