Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Friendly URL Mapper
Hello,
I recently stumbled upon the Friendly URL Mapper. I tried to set it up but I have a few problems with it.
I only found this wiki/blog entry as information source for liferay 6: http://www.liferay.com/de/community/wiki/-/wiki/Main/FriendlyURLMapper
I want to map my URL like this: http://localhost:8080/someUrl/{parameter1}/{parameter2}/{parameter3}
So I added this to my liferay-portlet.xml:
and then wrote my friendly-url-routes.xml like this:
After adding the friendly-url stuff to the liferay-portlet.xml and start up my server I get following exception:
My Primary intention for the Friendly URL Mapper is to disguise all the generated Parameters like p_p_id or p_p_lifecycle, so that the user can get his Data by just adding the (custom) parameters.
Can anyone tell me what I am doing wrong or provide some Links with more detailed info on that topic?
I recently stumbled upon the Friendly URL Mapper. I tried to set it up but I have a few problems with it.
I only found this wiki/blog entry as information source for liferay 6: http://www.liferay.com/de/community/wiki/-/wiki/Main/FriendlyURLMapper
I want to map my URL like this: http://localhost:8080/someUrl/{parameter1}/{parameter2}/{parameter3}
So I added this to my liferay-portlet.xml:
<portlet>
<portlet-name>somePortlet</portlet-name>
<friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
<friendly-url-mapping>somePortlet</friendly-url-mapping>
<friendly-url-routes>com/liferay/test/someportlet/someportlet-friendly-url-routes.xml</friendly-url-routes>
<instanceable>true</instanceable>
</portlet>and then wrote my friendly-url-routes.xml like this:
<!--?xml version="1.0" encoding="UTF-8"?-->
<routes>
<route>
<pattern>/someUrl/{parameter1}/{parameter2}/{parameter3}</pattern>
</route>
</routes>After adding the friendly-url stuff to the liferay-portlet.xml and start up my server I get following exception:
com.liferay.portal.kernel.xml.DocumentException: Error on line 116 of document : Element type "friendly-url-mapping" must be declared. Nested exception: Element type "friendly-url-mapping" must be declared.
at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:372)
at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:383)
at com.liferay.portal.kernel.xml.SAXReaderUtil.read(SAXReaderUtil.java:145)
at com.liferay.portal.service.impl.PortletLocalServiceImpl._readLiferayPortletXML(PortletLocalServiceImpl.java:1405)
at com.liferay.portal.service.impl.PortletLocalServiceImpl.initWAR(PortletLocalServiceImpl.java:609)
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 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:82)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy57.initWAR(Unknown Source)
at com.liferay.portal.service.PortletLocalServiceUtil.initWAR(PortletLocalServiceUtil.java:340)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:223)
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.PortletContextListener.doPortalInit(PortletContextListener.java:99)
at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:42)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:52)
at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:50)
at com.liferay.portal.kernel.servlet.PortletContextListener.contextInitialized(PortletContextListener.java:55)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1244)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1342)
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)
My Primary intention for the Friendly URL Mapper is to disguise all the generated Parameters like p_p_id or p_p_lifecycle, so that the user can get his Data by just adding the (custom) parameters.
Can anyone tell me what I am doing wrong or provide some Links with more detailed info on that topic?
Hi Flo,
it's problem while parsing your liferay-portlet.xml. Make sure you have correct DTD specification. For Liferay 6.0.x your liferay-portlet.xml should start with:
-- tom
it's problem while parsing your liferay-portlet.xml. Make sure you have correct DTD specification. For Liferay 6.0.x your liferay-portlet.xml should start with:
<!--?xml version="1.0"?-->
<liferay-portlet-app></liferay-portlet-app>-- tom
Hey, thanks again Thomas!
You are a great help!
I took a look and noticed that my Netbeans generates the config files with the 5.2 dtd. After I edited my files and changed it to the 6.0.0 dtd I seem to stay unfortunate.
Now I get the Exception that my Portlets have a null portlet bag. Google tells me that it may be because my portlet configuration can't relate the configuration entries to the portlet sources (as I understood it).
Well, I found the explanation of the error, but I got no solution for that.
You are a great help!
I took a look and noticed that my Netbeans generates the config files with the 5.2 dtd. After I edited my files and changed it to the 6.0.0 dtd I seem to stay unfortunate.
Now I get the Exception that my Portlets have a null portlet bag. Google tells me that it may be because my portlet configuration can't relate the configuration entries to the portlet sources (as I understood it).
Well, I found the explanation of the error, but I got no solution for that.
YW.
Please create new thread for your exception and attack stack trace, please.
-- tom
Please create new thread for your exception and attack stack trace, please.
-- tom
Yeah, better that since it is another Topic.
For all that suffer the same way, new Topic can be found here: http://www.liferay.com/de/community/forums/-/message_boards/message/10126977
And to stay on Topic:
I have a question regarding the Patterns, in the Wiki they look like
so, the {instanceId} will be mapped as the value of instanceId und the {folderId:\d+} will only consist of numeric values.
So when you put a ":" after the Parameter Name you can write your own Regex that will evaluate the Parameter?
When you provide a Parameter that can't be evaluated with this Regex, will it simply be ignored?
Also: is that pattern matched from behind the "-" in the Url (like the one in http://www.liferay.com/de/community/forums/-/message_boards/message/10126977)?
For all that suffer the same way, new Topic can be found here: http://www.liferay.com/de/community/forums/-/message_boards/message/10126977
And to stay on Topic:
I have a question regarding the Patterns, in the Wiki they look like
<pattern>/{instanceId}/view/{folderId:\d+}</pattern>so, the {instanceId} will be mapped as the value of instanceId und the {folderId:\d+} will only consist of numeric values.
So when you put a ":" after the Parameter Name you can write your own Regex that will evaluate the Parameter?
When you provide a Parameter that can't be evaluated with this Regex, will it simply be ignored?
Also: is that pattern matched from behind the "-" in the Url (like the one in http://www.liferay.com/de/community/forums/-/message_boards/message/10126977)?
Okay,
with Netbeans 7 and the Portal Pack 3.0.5 the DTD Problem is solved and I can go on working with the FriendlyURLMapper.
Given the Pattern
it should work on an URL like
if I am not mistaken.
When I am trying that out my Portlets aren't displayed.
a) With a WebContentDisplay (and I guess with other Standard-Portlets) the Content just turns Blank
b) When one of my own Portlets is displayed on the Page I get the message that the Portlet is currently not deployed.
When I remove the -/someUrl/parametervalue1/parametervalue2/parametervalue3 -Part, everything is fine again.
with Netbeans 7 and the Portal Pack 3.0.5 the DTD Problem is solved and I can go on working with the FriendlyURLMapper.
Given the Pattern
<pattern>/someUrl/{parameter1}/{parameter2}/{parameter3}</pattern>it should work on an URL like
www.liferay.com/somePath/-/someUrl/parametervalue1/parametervalue2/parametervalue3if I am not mistaken.
When I am trying that out my Portlets aren't displayed.
a) With a WebContentDisplay (and I guess with other Standard-Portlets) the Content just turns Blank
b) When one of my own Portlets is displayed on the Page I get the message that the Portlet is currently not deployed.
When I remove the -/someUrl/parametervalue1/parametervalue2/parametervalue3 -Part, everything is fine again.
Community
Company
Feedback