Foros de discusión
Where to put custom Facet Implementation?
Tim Myerscough, modificado hace 10 años.
Where to put custom Facet Implementation?
New Member Mensajes: 8 Fecha de incorporación: 1/03/13 Mensajes recientes
Hi.
I am using Liferay 6.2.
I would like to create a custom search facet: com.example.MySearchFacet, to filter search results based on categories for a particular vocabulary.
I have created a hook containing my custom code and JSPs.
I have added the search portlet with the advanced configuration:
However, when I perform the search, I get a ClassNotFoundException thrown:
So where do I need to add my custom code?
Is it possible to add it as a hook, or does it have to be an EXT plugin?
I am using Liferay 6.2.
I would like to create a custom search facet: com.example.MySearchFacet, to filter search results based on categories for a particular vocabulary.
I have created a hook containing my custom code and JSPs.
I have added the search portlet with the advanced configuration:
{"facets": [
{
"displayStyle": "filtered_asset_categories",
"static": false,
"weight": 1.1,
"order": "OrderHitsDesc",
"data": {
"displayStyle": "list",
"maxTerms": 10,
"frequencyThreshold": 1,
"showAssetCount": true,
"includes": [
"v1"
]
},
"className": "com.example.MySearchFacet",
"label": "category",
"fieldName": "assetCategoryTitles"
}
]}
However, when I perform the search, I get a ClassNotFoundException thrown:
16:41:28,921 ERROR [http-bio-8080-exec-9][IncludeTag:129] Current URL /web/guest/search?_3_formDate=1394440884427&p_p_id=3&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view&_3_struts_action=%2Fsearch%2Fsearch&_3_cur=1&_3_format=&_3_keywords=test&_3_clearSearch.x=8&_3_clearSearch.y=14 generates exception: javax.servlet.ServletException: java.lang.ClassNotFoundException: com.example.MySearchFacet
java.lang.ClassNotFoundException: com.example.MySearchFacet
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName(Class.java:190)
at com.liferay.portal.kernel.search.facet.util.FacetFactoryUtil.create(FacetFactoryUtil.java:40)
at org.apache.jsp.html.portlet.search.search_jsp._jspService(search_jsp.java:1079)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet._serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
So where do I need to add my custom code?
Is it possible to add it as a hook, or does it have to be an EXT plugin?
David H Nebinger, modificado hace 10 años.
RE: Where to put custom Facet Implementation? (Respuesta)
Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
The code has to run within the Liferay webapp, so you can either deploy the jar as a global jar (i.e. lib/ext in tomcat) or as an EXT plugin.
Tim Myerscough, modificado hace 10 años.
RE: Where to put custom Facet Implementation?
New Member Mensajes: 8 Fecha de incorporación: 1/03/13 Mensajes recientes
Hi David.
I was coming to that conclusion that was the case. I was just hoping to avoid it.
Regards
Tim
I was coming to that conclusion that was the case. I was just hoping to avoid it.
Regards
Tim
David H Nebinger, modificado hace 10 años.
RE: Where to put custom Facet Implementation?
Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
EXTs are nothing to be afraid of. Limit your EXT to those things you cannot do with a normal plugin and it won't get unwieldy and unmanageable.
Tim Myerscough, modificado hace 10 años.
RE: Where to put custom Facet Implementation?
New Member Mensajes: 8 Fecha de incorporación: 1/03/13 Mensajes recientes
Indeed, but EXTs add a number of complications which make them undesirable:
* Development is slower due to the need for restarts
* Deployment/redeployment of an EXT is non-trivial
* Development is slower due to the need for restarts
* Deployment/redeployment of an EXT is non-trivial
Tim Myerscough, modificado hace 10 años.
RE: Where to put custom Facet Implementation?
New Member Mensajes: 8 Fecha de incorporación: 1/03/13 Mensajes recientes
Considering the Search portlet configuration allows for the specification of custom classes, it would be great if the feature was refactored to allow for the packaging of a hook for custom search implementations.
Tim Myerscough, modificado hace 10 años.
RE: Where to put custom Facet Implementation?
New Member Mensajes: 8 Fecha de incorporación: 1/03/13 Mensajes recientes
I have raised https://issues.liferay.com/browse/LPS-44990 to cover the feature request to manage Facet implementations as a hook.
Vote if you wanna go faster!
Vote if you wanna go faster!
Ray Augé, modificado hace 10 años.
RE: Where to put custom Facet Implementation?
Liferay Legend Mensajes: 1197 Fecha de incorporación: 8/02/05 Mensajes recientes
Hey guys,
You sort of need EXT for this as it stands.
However, here is the first issue (not related to the error, but will cause an issue even if your code above worked)
1) your Facet impl has to extend one of these classes (rather than just implementing the interface):
- com.liferay.portal.kernel.search.facet.MultiValueFacet
- com.liferay.portal.kernel.search.facet.RangeFacet
- com.liferay.portal.kernel.search.facet.SimpleFacet
Otherwise it won't pass the necessary info into the search engine impl. We'll have to make a note of that in the Javadocs.
2) the JSP of the search portlet is executing in the core and knows nothing about the classes in your plugin
If there was a ticket for the classLoading issue we might be able to address it.
I could see us adding a JSON field which declares the name of the plugin context of a Facet class. If the field exists, and is not null, then load an instance of the class from the registered classLoader for that plugin context.
You sort of need EXT for this as it stands.
However, here is the first issue (not related to the error, but will cause an issue even if your code above worked)
1) your Facet impl has to extend one of these classes (rather than just implementing the interface):
- com.liferay.portal.kernel.search.facet.MultiValueFacet
- com.liferay.portal.kernel.search.facet.RangeFacet
- com.liferay.portal.kernel.search.facet.SimpleFacet
Otherwise it won't pass the necessary info into the search engine impl. We'll have to make a note of that in the Javadocs.
2) the JSP of the search portlet is executing in the core and knows nothing about the classes in your plugin
If there was a ticket for the classLoading issue we might be able to address it.
I could see us adding a JSON field which declares the name of the plugin context of a Facet class. If the field exists, and is not null, then load an instance of the class from the registered classLoader for that plugin context.
Tim Myerscough, modificado hace 10 años.
RE: Where to put custom Facet Implementation?
New Member Mensajes: 8 Fecha de incorporación: 1/03/13 Mensajes recientes
Thanks for the insight Ray.
My custom Facet extends com.liferay.portal.kernel.search.facet.MultiValueFacet, so that should be ok.
Something that would enable me to specify context used for class loading would be great.
I'll update the ticket I raised to cover the points you raised.
My custom Facet extends com.liferay.portal.kernel.search.facet.MultiValueFacet, so that should be ok.
Something that would enable me to specify context used for class loading would be great.
I'll update the ticket I raised to cover the points you raised.
Venkat N, modificado hace 7 años.
RE: Where to put custom Facet Implementation?
New Member Mensajes: 11 Fecha de incorporación: 14/02/12 Mensajes recientes
Hi Tim Myerscough,
Did you get chance to implement the above scenario please provide the snippet of code for me. I have to implement similar kind of Custom fecest search in my assignment.
Please help me .....
-----
Best Regards,
Venkat N.
Did you get chance to implement the above scenario please provide the snippet of code for me. I have to implement similar kind of Custom fecest search in my assignment.
Please help me .....
-----
Best Regards,
Venkat N.
David H Nebinger, modificado hace 7 años.
RE: Where to put custom Facet Implementation?
Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientesVenkat N:
I have to implement similar kind of Custom fecest search in my assignment.
Homework assignment or work assignment? Either way it should probably be your work you're submitting and not Tim's...