问题描述
配置好struts2osgi环境后,tomcat启动后报错:[ERROR]Unabletoextractversionfrom[jar:file:/E:/BSOSGI/WebRoot/WEB-INF/lib/xwork-core-2.3.16.3.jar!/com/opensymphony/xwork2/],defaultingto'1.0.0'[ERROR]Unabletoextractversionfrom[jar:file:/E:/BSOSGI/WebRoot/WEB-INF/lib/struts2-osgi-plugin-2.3.16.3.jar!/org/apache/struts2/],defaultingto'1.0.0'[ERROR]Unabletoextractversionfrom[jar:file:/E:/BSOSGI/WebRoot/WEB-INF/lib/ognl-3.0.6.jar!/ognl/],defaultingto'1.0.0'[ERROR]Unabletoextractversionfrom[jar:file:/E:/BSOSGI/WebRoot/WEB-INF/lib/freemarker-2.3.19.jar!/freemarker/],defaultingto'1.0.0'[ERROR]Unabletoextractversionfrom[jar:file:/E:/BSOSGI/WebRoot/WEB-INF/lib/velocity-1.6.4.jar!/org/apache/velocity/],defaultingto'1.0.0'ERROR:Bundleorg.apache.struts.2-osgi-admin-bundle[3]Errorstartingfile:/E:/BSOSGI/WebRoot/WEB-INF/classes/bundles/2/struts2-osgi-admin-bundle-2.3.16.3.jar(org.osgi.framework.BundleException:Unresolvedconstraintinbundleorg.apache.struts.2-osgi-admin-bundle[3]:Unabletoresolve3.0:missingrequirement[3.0]osgi.wiring.package;(&(osgi.wiring.package=com.opensymphony.xwork2)(version>=2.3.0)))bunddle起不来,看错误好像是无法获得这些包的版本,不知道哪里有问题。用的struts-2.3.16.3、jdk1.6、tomcat7lib包结构:asm-3.3.jarasm-commons-3.3.jarasm-tree-3.3.jarcglib-2.2.2.jarcommons-io-2.2.jarcommons-lang-2.4.jarcommons-lang3-3.1.jarcommons-logging-1.1.3.jardom4j-1.6.1.jarfreemarker-2.3.19.jarjavassist-3.11.0.GA.jarlog4j-1.2.17.jarlog4j-api-2.0-rc1.jarlog4j-core-2.0-rc1.jarognl-3.0.6.jarorg.apache.felix.main-4.0.3.jarorg.apache.felix.shell-1.4.3.jarslf4j-api-1.7.5.jarslf4j-log4j12-1.7.5.jarstruts2-core-2.3.16.3.jarstruts2-osgi-plugin-2.3.16.3.jarvelocity-1.6.4.jarvelocity-tools-1.3.jarxwork-core-2.3.16.3.jarweb.xml配置如下:<filter><filter-name>struts2-prepare</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class></filter><filter><filter-name>struts2-execute</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class></filter><filter-mapping><filter-name>struts2-prepare</filter-name><url-pattern>/*</url-pattern></filter-mapping><filter-mapping><filter-name>struts2-execute</filter-name><url-pattern>/*</url-pattern></filter-mapping><listener><listener-class>org.apache.struts2.osgi.StrutsOsgiListener</listener-class></listener><listener><listener-class>org.apache.struts2.dispatcher.ng.listener.StrutsListener</listener-class></listener><context-param><param-name>TemplatePath</param-name><param-value>class://</param-value></context-param><context-param><param-name>struts.osgi.clearBundleCache</param-name><param-value>false</param-value></context-param>struts.xml配置:<struts><constantname="struts.objectFactory"value="osgi"/></struts>
解决方案
解决方案二:
我也遇到这个问题了,楼主解决了吗?
解决方案三:
懂这个的人貌似不多..
解决方案四:
楼主请参考http://blog.csdn.net/icecream0/article/details/7579496
解决方案五:
http://bill-xing.iteye.com/blog/793412这个链接的清单10中写道:如果无法连接上http://struts.apache.org/,那么在加载Struts的bundle时也将会出错,因为bundle与WebApplication的lib的加载路径不一致,无法从WebApplication的lib下面找到XXX.dtd文件。我按照这个去修改了,把"http://struts.apache.org/dtds/struts-2.0.dtd"直接改为本地的dtd,没用;还试了一种方法:在prefreces->catalog中添加"http://struts.apache.org/dtds/struts-2.0.dtd"与本地dtd关联,但是最后也没用。本来这样改了dtd之后,应该在struts2.xml中有提示的啊,但是也没有提示。然后在https://github.com/cenobites/struts2-json-plugin中提到:TofixthisaddthislinetoMANIFEST.MF:DynamicImport-Package:es.cenobit.struts2.json.annotationsOrifusingTheApacheFelixmavenplugin(seebelowfordetails):<DynamicImport-Package>es.cenobit.struts2.json.annotations</DynamicImport-Package>试着改了一下,也是没用!望高手解答啊!!
解决方案六:
引用3楼baohuan_love的回复:
楼主请参考http://blog.csdn.net/icecream0/article/details/7579496
这篇文章跟这个话题有关吗?
解决方案七:
我将struts的包换成2.3.4,包括struts-ogsi-plugin也换成2.3.4.这个错就没了,用struts2.3.16发现拿不到相关jar的version。在FelixOsgiHost的addExportedPackages方法中,你可以debug下。