Vista combinada Visión Plana Vista de árbol
Discusiones [ Anterior | Siguiente ]
toggle
Brian Russell
Servlet Filter via Hook in 6.0.6?
21 de febrero de 2012 14:35
Respuesta

Brian Russell

Ranking: Junior Member

Mensajes: 41

Fecha de incorporación: 31 de octubre de 2011

Mensajes recientes

I have read that the ability to create a custom servlet filter is available via hooks in version 6.1, however, I also see that the DTD for the liferay-hook.xml file (http://www.liferay.com/dtd/liferay-hook_6_0_0.dtd) contains the elements for servlet-filter & servlet-filter-mapping. Has anyone had success in creating a custom servlet filter using a hook plugin (rather than via ext plugin) in version 6.0.x?

I'm currently running on v. 6.0.6 of the Community Edition.

My liferay-hook.xml looks like this:
 1<?xml version="1.0"?>
 2<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.0.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_0_0.dtd">
 3
 4<hook>
 5    <portal-properties>portal.properties</portal-properties>
 6    <servlet-filter>
 7        <servlet-filter-name>CW SSO CAS Filter</servlet-filter-name>
 8        <servlet-filter-impl>com.my.custom.sso.cas.CWCASFilter</servlet-filter-impl>
 9    </servlet-filter>
10    <servlet-filter-mapping>
11        <servlet-filter-name>CW SSO CAS Filter</servlet-filter-name>
12        <after-filter>Session Id Filter</after-filter>
13        <url-pattern>/c/portal/login</url-pattern>
14        <url-pattern>/c/portal/logout</url-pattern>
15        <dispatcher>REQUEST</dispatcher>
16        <dispatcher>FORWARD</dispatcher>
17    </servlet-filter-mapping>
18</hook>


And the error I'm receiving when trying to deploy the hook is:
 122:19:42,955 INFO  [HookHotDeployListener:394] Registering hook for cwcassso-hook
 222:19:42,958 ERROR [HotDeployUtil:112] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering hook for cwcassso-hook
 3com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering hook for cwcassso-hook
 4    at com.liferay.portal.kernel.deploy.hot.BaseHotDeployListener.throwHotDeployException(BaseHotDeployListener.java:45)
 5    at com.liferay.portal.deploy.hot.HookHotDeployListener.invokeDeploy(HookHotDeployListener.java:221)
 6    at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:109)
 7    at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:182)
 8    at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:38)
 9    at com.liferay.portal.kernel.servlet.HookContextListener.contextInitialized(HookContextListener.java:36)
10    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
11    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
12    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
13    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
14    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
15    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
16    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
17    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
18    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1345)
19    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)
20    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
21    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
22    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
23    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
24    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
25    at java.lang.Thread.run(Thread.java:680)
26Caused by: com.liferay.portal.kernel.xml.DocumentException: Error on line 6 of document  : Element type "servlet-filter" must be declared. Nested exception: Element type "servlet-filter" must be declared.
27    at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:372)
28    at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:383)
29    at com.liferay.portal.kernel.xml.SAXReaderUtil.read(SAXReaderUtil.java:145)
30    at com.liferay.portal.deploy.hot.HookHotDeployListener.doInvokeDeploy(HookHotDeployListener.java:403)
31    at com.liferay.portal.deploy.hot.HookHotDeployListener.invokeDeploy(HookHotDeployListener.java:218)
32    ... 20 more
33Caused by: org.dom4j.DocumentException: Error on line 6 of document  : Element type "servlet-filter" must be declared. Nested exception: Element type "servlet-filter" must be declared.
34    at org.dom4j.io.SAXReader.read(SAXReader.java:482)
35    at org.dom4j.io.SAXReader.read(SAXReader.java:365)
36    at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:369)
37    ... 24 more


Seems pretty obvious to me that even though the DTD declares the elements for filters, it is not working yet in 6.0.6, but just wanted to confirm that and find out if anybody else has had success? I'd really like to accomplish this via a hook rather than ext, and I can't yet upgrade to 6.1

Thank you!
Brian Russell
RE: Servlet Filter via Hook in 6.0.6?
21 de febrero de 2012 14:45
Respuesta

Brian Russell

Ranking: Junior Member

Mensajes: 41

Fecha de incorporación: 31 de octubre de 2011

Mensajes recientes

Well, I just took a look at the DTD that is actually bundled with my version and it does not contain the servlet-filter or servlet-filter-mapping elements despite what I thought! That explains it!
 1<!--
 2This is the DTD for the Hook parameters for Liferay Portal.
 3
 4<!DOCTYPE hook PUBLIC
 5    "-//Liferay//DTD Hook 6.0.0//EN"
 6    "http://www.liferay.com/dtd/liferay-hook_6_0_0.dtd">
 7-->
 8
 9<!ELEMENT hook (portal-properties?, language-properties*, custom-jsp-dir?,
10service*)>
11
12<!ELEMENT portal-properties (#PCDATA)>
13
14<!ELEMENT language-properties (#PCDATA)>
15
16<!ELEMENT custom-jsp-dir (#PCDATA)>
17
18<!ELEMENT service (service-type, service-impl)>
19
20<!ELEMENT service-type (#PCDATA)>
21
22<!ELEMENT service-impl (#PCDATA)>


Wondering if I just update the DTD if it'll work?
Hitoshi Ozawa
RE: Servlet Filter via Hook in 6.0.6?
21 de febrero de 2012 15:11
Respuesta

Hitoshi Ozawa

Ranking: Liferay Legend

Mensajes: 7949

Fecha de incorporación: 23 de marzo de 2010

Mensajes recientes

As you've stated in your first post, it seems like it's supported from 6.1.0.

http://www.liferay.com/ja/community/forums/-/message_boards/message/8878943
Brian Russell
RE: Servlet Filter via Hook in 6.0.6?
21 de febrero de 2012 15:06
Respuesta

Brian Russell

Ranking: Junior Member

Mensajes: 41

Fecha de incorporación: 31 de octubre de 2011

Mensajes recientes

Ya, that's what I was thinking too, but this message board post gave me some hope that it was available in 6.0:

http://www.liferay.com/community/forums/-/message_boards/view_message/12495269#_19_message_12495269

But his response seems to refer to the Enterprise Edition, so I'm not sure.
David H Nebinger
RE: Servlet Filter via Hook in 6.0.6?
21 de febrero de 2012 17:48
Respuesta

David H Nebinger

Community Moderator

Ranking: Liferay Legend

Mensajes: 11478

Fecha de incorporación: 1 de septiembre de 2006

Mensajes recientes

I think you can use Jelmer's suggestion about deploying via the EXT plugin in 6.0.6 CE...
Mika Koivisto
RE: Servlet Filter via Hook in 6.0.6?
22 de febrero de 2012 15:12
Respuesta

Mika Koivisto

LIFERAY STAFF

Ranking: Liferay Legend

Mensajes: 1513

Fecha de incorporación: 7 de agosto de 2006

Mensajes recientes

This feature is available starting from 6.1 CE and 6.0 EE SP2.
David H Nebinger
RE: Servlet Filter via Hook in 6.0.6?
22 de febrero de 2012 16:03
Respuesta

David H Nebinger

Community Moderator

Ranking: Liferay Legend

Mensajes: 11478

Fecha de incorporación: 1 de septiembre de 2006

Mensajes recientes

Right, but won't the EXT plugin option work even under 6.0.6? That's one of the things the EXT plugin is good for...
Mika Koivisto
RE: Servlet Filter via Hook in 6.0.6?
22 de febrero de 2012 16:14
Respuesta

Mika Koivisto

LIFERAY STAFF

Ranking: Liferay Legend

Mensajes: 1513

Fecha de incorporación: 7 de agosto de 2006

Mensajes recientes

Yes, you can still use the Ext way in 6.0.6.
Brian Russell
RE: Servlet Filter via Hook in 6.0.6?
23 de febrero de 2012 6:12
Respuesta

Brian Russell

Ranking: Junior Member

Mensajes: 41

Fecha de incorporación: 31 de octubre de 2011

Mensajes recientes

Thanks guys! Just wanted to verify that I still had to go the EXT route, which I did, and everything is working fine. Once we eventually upgrade to 6.1, I'll change it over to a hook.
Kris k Krishna
RE: Servlet Filter via Hook in 6.0.6?
27 de junio de 2013 10:49
Respuesta

Kris k Krishna

Ranking: New Member

Mensajes: 2

Fecha de incorporación: 3 de agosto de 2006

Mensajes recientes

Brian, How did you implement this using EXT. I am running into same issue of : Element type "struts-action" must be declared.