学习OSGi Web开发过程中遇到的问题及解决方案汇总,以便查询。

 

学习过程

1. 利用felix和struts2实现osgi web(一)

引用文章:http://xingtongkun-tom-com.javaeye.com/blog/793517

问题汇总:

1. java.lang.RuntimeException: java.lang.reflect.InvocationTargetException 

严重: Dispatcher initialization failed
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
 at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:295)
 at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:431)
 at com.opensymphony.xwork2.inject.ContainerBuilder$5.create(ContainerBuilder.java:207)
 at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51)
 at com.opensymphony.xwork2.inject.ContainerBuilder$3.create(ContainerBuilder.java:93)
 ……

Caused by: java.lang.reflect.InvocationTargetException

今天试了一下一下Struts2.2.1,按照tutorials方式部署后启动tomcat就报这个错误,后来查询网上讲要放一个javassist-3.7.ga.jar进去,解压了一个war,然后把这个包放进去,就没有这个错误了!

2. org.osgi.framework.BundleException: Fragments with exports, imports, or native code are not currently supported.

Felix 1.4是tmd半成品,更新版本

3. java.lang.IllegalArgumentException: Can't convert argument: null
 at org.apache.tomcat.util.IntrospectionUtils.convert(IntrospectionUtils.java:1005)
 at org.apache.tomcat.util.digester.CallMethodRule.end(CallMethodRule.java:523)
 at org.apache.tomcat.util.digester.Rule.end(Rule.java:229)
 at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1138)
 at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
 ……

web.xml文件中参数格式不正确

4. 在根据上文启动struts-osgi-demo-bundle-2.2.1.1.jar时出现以下错误:

严重: Exception sending context initialized event to listener instance of class org.apache.struts2.dispatcher.ng.listener.StrutsListener
Unable to load configuration. - action - bundle://2.0:1/struts.xml:9:64
 at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:428)
 at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
 at org.apache.struts2.dispatcher.ng.listener.StrutsListener.contextInitialized(StrutsListener.java:47)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
 ……

Caused by: Unable to load configuration. - action - bundle://2.0:1/struts.xml:9:64
 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69)
 at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371)
 at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
 ... 26 more
Caused by: Action class [helloWorldAction] not found - action - bundle://2.0:1/struts.xml:9:64
 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:420)
 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:365)
 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:479)
 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:275)
 at org.apache.struts2.osgi.BundlePackageLoader.loadPackages(BundlePackageLoader.java:58)
 at org.apache.struts2.osgi.OsgiConfigurationProvider.loadConfigFromBundle(OsgiConfigurationProvider.java:135)
 at org.apache.struts2.osgi.OsgiConfigurationProvider.loadPackages(OsgiConfigurationProvider.java:100)
 at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:215)
 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
 ... 28 more

这个应该是找不到xml配置文件,据说只要在struts.xml文件中加入如下配置即可:

 <constant name="struts.objectFactory" value="osgi" />
 <constant name="struts.objectFactory.delegate" value="springOsgi" />

5. 严重: Exception sending context initialized event to listener instance of class org.apache.struts2.dispatcher.ng.listener.StrutsListener
Class: com.opensymphony.xwork2.spring.SpringObjectFactory
File: SpringObjectFactory.java
Method: getClassInstance
Line: 220 - com/opensymphony/xwork2/spring/SpringObjectFactory.java:220:-1
 at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:428)
 at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
 at org.apache.struts2.dispatcher.ng.listener.StrutsListener.contextInitialized(StrutsListener.java:47)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
 ……
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.NullPointerException
 at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:220)
 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyResultType(XmlConfigurationProvider.java:530)
 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addResultTypes(XmlConfigurationProvider.java:501)
 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:457)
 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:275)
 at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
 ... 26 more

把struts-spring-plugin.jar从lib中去掉

 posted on 2011-02-15 11:40  TechNick  阅读(1379)  评论(1编辑  收藏  举报