[开发] liferay6.0.5 插件模式开发portlet能用struts1吗?
真liuyake
2010-10-20
试过直接用portlet和struts2 portlet都能行,但是唯独struts1不行,我的配置文件如下:
portlet.xml <?xml version="1.0"?> <portlet-app version="2.0" xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" > portlet.xml <portlet> <portlet-name>strutsportlet</portlet-name> <display-name>StrutsPortlet</display-name> <portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class> <init-param> <name>view-action</name> <value>/hellostruts_portlet/viewp</value> </init-param> <expiration-cache>0</expiration-cache> <supports> <mime-type>text/html</mime-type> <portlet-mode>VIEW</portlet-mode> </supports> <portlet-info> <title>StrutsPortlet</title> <short-title>StrutsPortlet</short-title> <keywords></keywords> </portlet-info> <security-role-ref> <role-name>administrator</role-name> </security-role-ref> <security-role-ref> <role-name>guest</role-name> </security-role-ref> <security-role-ref> <role-name>power-user</role-name> </security-role-ref> <security-role-ref> <role-name>user</role-name> </security-role-ref> </portlet> </portlet-app> liferay-portlet.xml <portlet> <portlet-name>strutsportlet</portlet-name> <icon>/icon.png</icon> <instanceable>true</instanceable> <header-portlet-css>/css/portlet.css</header-portlet-css> <footer-portlet-javascript> /js/javascript.js </footer-portlet-javascript> <css-class-wrapper>strutsportlet-portlet</css-class-wrapper> </portlet> <role-mapper> <role-name>administrator</role-name> <role-link>Administrator</role-link> </role-mapper> <role-mapper> <role-name>guest</role-name> <role-link>Guest</role-link> </role-mapper> <role-mapper> <role-name>power-user</role-name> <role-link>Power User</role-link> </role-mapper> <role-mapper> <role-name>user</role-name> <role-link>User</role-link> </role-mapper> liferay-display.xml[/color] <portlet id="strutsportlet"></portlet> [color=red]struts-config.xml <?xml version="1.0"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd"> <struts-config> <action-mappings> <action path="/hellostruts_portlet/view" type="demo.StrutsPortlet" forward="portlet.hellostruts_portlet.view" /> </action-mappings> <plug-in className="org.apache.struts.tiles.TilesPlugin"> <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml"/> <set-property property="moduleAware" value="true"/> <set-property property="definitions-parser-validate" value="true"/> </plug-in> </struts-config> tiles-defs.xml <?xml version="1.0"?> <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd"> <tiles-definitions> <definition name="portlet.hellostruts_portlet" path="/strutsportlet/view.jsp" /> <definition name="portlet.hellostruts_portlet.view" extends="portlet.hellostruts_portlet"> <put name="portlet_content" value="/strutsportlet/view.jsp"/> </definition> </tiles-definitions> web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <servlet> <servlet-name>PortletActionServlet</servlet-name> <servlet-class>com.liferay.portal.struts.PortletActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>PortletActionServlet</servlet-name> <url-pattern>/portlet_action/*</url-pattern> </servlet-mapping> <jsp-config> <taglib> <taglib-uri>http://struts.apache.org/tags-bean</taglib-uri> <taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://struts.apache.org/tags-bean-el</taglib-uri> <taglib-location>/WEB-INF/tld/struts-bean-el.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://struts.apache.org/tags-html</taglib-uri> <taglib-location>/WEB-INF/tld/struts-html.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://struts.apache.org/tags-html-el</taglib-uri> <taglib-location>/WEB-INF/tld/struts-html-el.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://struts.apache.org/tags-logic</taglib-uri> <taglib-location>/WEB-INF/tld/struts-logic.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://struts.apache.org/tags-logic-el</taglib-uri> <taglib-location>/WEB-INF/tld/struts-logic-el.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://struts.apache.org/tags-nested</taglib-uri> <taglib-location>/WEB-INF/tld/struts-nested.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://struts.apache.org/tags-tiles</taglib-uri> <taglib-location>/WEB-INF/tld/struts-tiles.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://struts.apache.org/tags-tiles-el</taglib-uri> <taglib-location>/WEB-INF/tld/struts-tiles-el.tld</taglib-location> </taglib> </jsp-config> </web-app> liferay-plugin-package.properties name=MyPortlet module-group-id=liferay module-incremental-version=1 tags= short-description= change-log= page-url=http://www.liferay.com author=Liferay, Inc. licenses=LGPL portal-dependency-jars=\ axis-ant.jar,\ axis.jar,\ wsdl4j.jar,\ commons-logging.jar,\ commons-discovery.jar,\ jaxrpc.jar,\ jstl-api.jar,\ jstl-impl.jar,\ struts-el.jar,\ struts.jar,\ portal-impl.jar portal-dependency-tlds=\ struts-bean-el.tld,\ struts-bean.tld,\ struts-html-el.tld,\ struts-html.tld,\ struts-logic-el.tld,\ struts-logic.tld,\ struts-nested.tld,\ struts-tiles-el.tld,\ struts-tiles.tld,\ x.tld demo.StrutsPortlet.java public class StrutsPortlet extends PortletAction { @Override @Override public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { System.out.println("struts render..."); return super .render(mapping, form, portletConfig, renderRequest, renderResponse); } 无论我META-INF目录下是否有context.xml都是相同的错。 context.xml <Context> <Loader loaderClass="com.liferay.support.tomcat.loader.PortalClassLoader" /> </Context> 错误如下: log4j:ERROR Could not create an Appender. Reported error follows. java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot be cast to org.apache.log4j.Appender at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:165) at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:140) at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:153) at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:415) at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:384) at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:783) at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:666) at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:616) at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:602) at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:697) at com.liferay.util.log4j.Log4JUtil.configureLog4J(Log4JUtil.java:48) at com.liferay.portal.deploy.hot.PortletHotDeployListener.initLogger(PortletHotDeployListener.java:448) at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:235) at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:101) at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:109) at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:182) at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:38) at com.liferay.portal.kernel.servlet.HookContextListener.contextInitialized(HookContextListener.java:36) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637) at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498) at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1345) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590) at java.lang.Thread.run(Thread.java:619) log4j:ERROR Could not parse input source [org.xml.sax.InputSource@2a188b]. java.lang.NullPointerException at java.util.Hashtable.put(Hashtable.java:394) at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:141) at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:153) at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:415) at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:384) at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:783) at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:666) at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:616) at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:602) at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:697) at com.liferay.util.log4j.Log4JUtil.configureLog4J(Log4JUtil.java:48) at com.liferay.portal.deploy.hot.PortletHotDeployListener.initLogger(PortletHotDeployListener.java:448) at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:235) at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:101) at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:109) at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:182) at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:38) at com.liferay.portal.kernel.servlet.HookContextListener.contextInitialized(HookContextListener.java:36) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637) at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498) at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1345) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590) at java.lang.Thread.run(Thread.java:619) 7:00:13,640 ERROR [PortletBagFactory:293] java.lang.ClassCastException: com.liferay.portlet.PortletConfigImpl cannot be cast to com.liferay.portlet.PortletConfigImpl java.lang.ClassCastException: com.liferay.portlet.PortletConfigImpl cannot be cast to com.liferay.portlet.PortletConfigImpl at com.liferay.portlet.StrutsPortlet.init(StrutsPortlet.java:164) at com.liferay.portlet.InvokerPortletImpl.init(InvokerPortletImpl.java:245) at com.liferay.portlet.PortletInstanceFactoryImpl.init(PortletInstanceFactoryImpl.java:216) at com.liferay.portlet.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:139) at com.liferay.portlet.PortletInstanceFactoryUtil.create(PortletInstanceFactoryUtil.java:40) at com.liferay.portlet.PortletBagFactory.create(PortletBagFactory.java:290) at com.liferay.portal.deploy.hot.PortletHotDeployListener.initPortlet(PortletHotDeployListener.java:456) at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:253) at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:101) at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:109) at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:182) at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:38) at com.liferay.portal.kernel.servlet.HookContextListener.contextInitialized(HookContextListener.java:36) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467) at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3228) at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:403) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1309) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590) at java.lang.Thread.run(Thread.java:619) 07:00:15,656 INFO [PortletHotDeployListener:374] 4 portlets for MyPortlet-portlet are available for use 我自己怀疑是因为liferay6.0以插件形式开发的portlet的war中,WEB-INF/lib 有的portal-impl.jar、log4j.jar 与共享 的classloader加载的类有冲突,不知道该如何解决,又或者是插件形式不能用struts1? |
|
andy19801210
2010-12-21
以前kernel.jar包没有了,它合并到service.jar中,所以对应的PortletAction没有对应的实现。
|
相关讨论
相关资源推荐
- WINDOWS系统日志导出工具及使用方法
- 使用非管理员实现系统事件日志的自动备份与清除
- Windows下怎样用Dell Dset工具收集系统日志
- liferay 使用struts2 开发portlet
- struts2_spring_json.rar_liferay struts2 json_portlet json_spring
- 用struts1.X实现liferay portlet插件(HelloWorld)
- liferay_使用struts2开发portlet
- Liferay-Portlet-SDK5.2.3.rar_liferay_liferay sdk_portlet
- 使用dumpel定期导出windows系统日志
- Windows系统日志的查询与自动备份---dumpel