Ahmed Hasan Il y a 9 années Very good blog and very useful. Ahamed Hasan,Author of Liferay Cookbook Veuillez vous identifier pour voter. Répondre en tant que ... Annuler
Peter Mesotten Il y a 9 années For those interested, a small update was applied to the code making it fully compatible with Liferay 6.2. In Liferay 6.2, the getNames() method of the bean locator is also called, so it should not throw an UnsupportedOperationException. Instead, it can return an empty String array. Both the code in this article was updated, as well as the code in the Github repo.Thanks to https://github.com/tmetten for noticing this. Veuillez vous identifier pour voter. Répondre en tant que ... Annuler
Graham Heath Il y a 9 années Thanks oodles for this. Took me a while to wrap my head around that "velocity-hook" was just the name of your hook project, if your hook project is called something else, you'll need to update that. (Liferay 6.2 GA2) Veuillez vous identifier pour voter. Répondre en tant que ... Annuler
Peter Mesotten Il y a 9 années Hi Alessandro,Unfortunately the approach only works for Web Content templates.There however already exists a solution for injecting custom beans/services/tools in Liferay themes. See [1] for more information. You could use this approach to instantiate and then inject the Velocity tool into your theme's template variables.Best regards and good luck[1] https://www.liferay.com/community/wiki/-/wiki/Main/Custom+Velocity+Variables Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Alessandro Aglietti Peter Mesotten Il y a 9 années Hi Peter we do a workaround that works for themes without EXT plugin!With a fresh Liferay 6.2 CE GA2 installation the context (ctx variable in SpringBeanLocator) is null both in theme and web content template Instead of use the ctx.getBean(clazz) we use classic reflection clazz.newIstance().In this case the util locator works fine both in themes and web content templates!We hope this is useful for the communityCheers Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Peter Mesotten Alessandro Aglietti Il y a 9 années Thanks for sharing your experiences Allessandro.Class reflection is indeed possible but in that case your service beans will no longer be singletons. If you can live with that, your solution is fine :-) Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Alessandro Aglietti Peter Mesotten Il y a 9 années No singleton no party We need implement singleton too! Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Alessandro Aglietti Alessandro Aglietti Il y a 9 années We have published code and instructions!PS: singleton aren't yet implemented https://github.com/Noovle/newrelic-rum-liferay Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Alessandro Aglietti Alessandro Aglietti Il y a 9 années Singleton added!https://github.com/Noovle/newrelic-rum-liferay/commit/91497f91bbe4181f58bf43a6475453c5f79ee6e2 Veuillez vous identifier pour voter. Répondre en tant que ... Annuler
Alessandro Aglietti Peter Mesotten Il y a 9 années Hi Peter we do a workaround that works for themes without EXT plugin!With a fresh Liferay 6.2 CE GA2 installation the context (ctx variable in SpringBeanLocator) is null both in theme and web content template Instead of use the ctx.getBean(clazz) we use classic reflection clazz.newIstance().In this case the util locator works fine both in themes and web content templates!We hope this is useful for the communityCheers Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Peter Mesotten Alessandro Aglietti Il y a 9 années Thanks for sharing your experiences Allessandro.Class reflection is indeed possible but in that case your service beans will no longer be singletons. If you can live with that, your solution is fine :-) Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Alessandro Aglietti Peter Mesotten Il y a 9 années No singleton no party We need implement singleton too! Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Alessandro Aglietti Alessandro Aglietti Il y a 9 années We have published code and instructions!PS: singleton aren't yet implemented https://github.com/Noovle/newrelic-rum-liferay Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Alessandro Aglietti Alessandro Aglietti Il y a 9 années Singleton added!https://github.com/Noovle/newrelic-rum-liferay/commit/91497f91bbe4181f58bf43a6475453c5f79ee6e2 Veuillez vous identifier pour voter. Répondre en tant que ... Annuler
Peter Mesotten Alessandro Aglietti Il y a 9 années Thanks for sharing your experiences Allessandro.Class reflection is indeed possible but in that case your service beans will no longer be singletons. If you can live with that, your solution is fine :-) Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Alessandro Aglietti Peter Mesotten Il y a 9 années No singleton no party We need implement singleton too! Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Alessandro Aglietti Alessandro Aglietti Il y a 9 années We have published code and instructions!PS: singleton aren't yet implemented https://github.com/Noovle/newrelic-rum-liferay Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Alessandro Aglietti Alessandro Aglietti Il y a 9 années Singleton added!https://github.com/Noovle/newrelic-rum-liferay/commit/91497f91bbe4181f58bf43a6475453c5f79ee6e2 Veuillez vous identifier pour voter. Répondre en tant que ... Annuler
Alessandro Aglietti Peter Mesotten Il y a 9 années No singleton no party We need implement singleton too! Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Alessandro Aglietti Alessandro Aglietti Il y a 9 années We have published code and instructions!PS: singleton aren't yet implemented https://github.com/Noovle/newrelic-rum-liferay Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Alessandro Aglietti Alessandro Aglietti Il y a 9 années Singleton added!https://github.com/Noovle/newrelic-rum-liferay/commit/91497f91bbe4181f58bf43a6475453c5f79ee6e2 Veuillez vous identifier pour voter. Répondre en tant que ... Annuler
Alessandro Aglietti Alessandro Aglietti Il y a 9 années We have published code and instructions!PS: singleton aren't yet implemented https://github.com/Noovle/newrelic-rum-liferay Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Alessandro Aglietti Alessandro Aglietti Il y a 9 années Singleton added!https://github.com/Noovle/newrelic-rum-liferay/commit/91497f91bbe4181f58bf43a6475453c5f79ee6e2 Veuillez vous identifier pour voter. Répondre en tant que ... Annuler
Alessandro Aglietti Alessandro Aglietti Il y a 9 années Singleton added!https://github.com/Noovle/newrelic-rum-liferay/commit/91497f91bbe4181f58bf43a6475453c5f79ee6e2 Veuillez vous identifier pour voter. Répondre en tant que ... Annuler
Jouni Latvatalo Il y a 9 années This seems a great way to bridge liferay web contents to our (remote EJ service layer. However I'm having some troubles when returning POJOs from the service layer.Lets say that I have a Products interface annotated with @Remote. The actual implementation is running on a separate TomEE instance.The interfaces has two methods:String getProductName(Long productId);Product getProduct(Long productId);Both the interface and the Product POJO are in a service-common maven module which is packaged as a jar archive, and it is a dependency in the hook project.The getProductName works just nicely, and if used in the web content, I can see something like "Hello, peter! I found a product named TestProduct for you!".However if I use the method that returns the whole product POJO, it only works during the first time I load the web content. When I refresh the page I get ClassNotFoundException for the product POJO. So clearly(?) the JAR dependency is not in the right place.. or.. something? Any ideas what might be going on here?Running LR 6.2 GA2 Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Peter Mesotten Jouni Latvatalo Il y a 9 années Hi Jouni,Thanks for your feedback. This evening I'll perform a similar test on my code and let you know my findings. Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Jouni Latvatalo Peter Mesotten Il y a 9 années Seems to work if I put the dependency jar to Tomcat's lib, and set it as provided in the pom. Naturally this is not ideal as it would require manually updating the jar everytime it changes. Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Peter Mesotten Peter Mesotten Il y a 9 années - Edité @JouniI just tried this by defining a separate JAR module containing the service returning a POJO object that is defined within that JAR module as well. Finally, the JAR module was depended on by the velocity hook WAR project.See my branch on https://github.com/limburgie/velocity-bean-locator/tree/external-library for the full layout.This way, I could do the following:#set ($otherHelloTool = $utilLocator.findUtil("velocity-hook", "be.aca.liferay.OtherSayHelloService"))$otherHelloTool.getPojo().sayHi()This worked for me every time, even after reloading the page multiple times. My template is not cached, maybe that makes a difference? I tested this in Liferay 6.1 EE GA3 but I don't think the version matters here. Veuillez vous identifier pour voter. Répondre en tant que ... Annuler
Peter Mesotten Jouni Latvatalo Il y a 9 années Hi Jouni,Thanks for your feedback. This evening I'll perform a similar test on my code and let you know my findings. Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Jouni Latvatalo Peter Mesotten Il y a 9 années Seems to work if I put the dependency jar to Tomcat's lib, and set it as provided in the pom. Naturally this is not ideal as it would require manually updating the jar everytime it changes. Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Peter Mesotten Peter Mesotten Il y a 9 années - Edité @JouniI just tried this by defining a separate JAR module containing the service returning a POJO object that is defined within that JAR module as well. Finally, the JAR module was depended on by the velocity hook WAR project.See my branch on https://github.com/limburgie/velocity-bean-locator/tree/external-library for the full layout.This way, I could do the following:#set ($otherHelloTool = $utilLocator.findUtil("velocity-hook", "be.aca.liferay.OtherSayHelloService"))$otherHelloTool.getPojo().sayHi()This worked for me every time, even after reloading the page multiple times. My template is not cached, maybe that makes a difference? I tested this in Liferay 6.1 EE GA3 but I don't think the version matters here. Veuillez vous identifier pour voter. Répondre en tant que ... Annuler
Jouni Latvatalo Peter Mesotten Il y a 9 années Seems to work if I put the dependency jar to Tomcat's lib, and set it as provided in the pom. Naturally this is not ideal as it would require manually updating the jar everytime it changes. Veuillez vous identifier pour voter. Répondre en tant que ... Annuler
Peter Mesotten Peter Mesotten Il y a 9 années - Edité @JouniI just tried this by defining a separate JAR module containing the service returning a POJO object that is defined within that JAR module as well. Finally, the JAR module was depended on by the velocity hook WAR project.See my branch on https://github.com/limburgie/velocity-bean-locator/tree/external-library for the full layout.This way, I could do the following:#set ($otherHelloTool = $utilLocator.findUtil("velocity-hook", "be.aca.liferay.OtherSayHelloService"))$otherHelloTool.getPojo().sayHi()This worked for me every time, even after reloading the page multiple times. My template is not cached, maybe that makes a difference? I tested this in Liferay 6.1 EE GA3 but I don't think the version matters here. Veuillez vous identifier pour voter. Répondre en tant que ... Annuler
Sebastien Bervoets Il y a 9 années Hi Peter,I tried to implement the code but using FreeMarker as template. I get an error telling me the utilLocator.FindUtil(...) is undefined. Would I change something in the code to make it running with Freemarker?Thank you Veuillez vous identifier pour voter. Répondre en tant que ... Annuler Sebastien Bervoets Sebastien Bervoets Il y a 9 années Forget it, I found my mistake Veuillez vous identifier pour voter. Répondre en tant que ... Annuler
Sebastien Bervoets Sebastien Bervoets Il y a 9 années Forget it, I found my mistake Veuillez vous identifier pour voter. Répondre en tant que ... Annuler
Mohammad Hejazi Il y a 9 années #set ($sayHelloTool = $utilLocator.findUtil("velocity-hook", "be.aca.literay.tool.SayHelloTool"))change by #set ($sayHelloTool = $serviceLocator.findService("velocity-hook", "be.aca.literay.tool.SayHelloTool")) Veuillez vous identifier pour voter. Répondre en tant que ... Annuler
S H Il y a 7 années Hi Peter,I created a hook project and put your code in the hook project. When I tried to deploy it to my liferay 6.2, I got below error message in the log file. Do you know what happen? My local JDK is 1.7 and I do see XmlWebApplicationContext in string-web.jar under\liferay-portal-6.2-ce-ga6\tomcat-7.0.62\webapps\ROOT\WEB-INF\lib\spring-web.jar02:31:09,481 ERROR [localhost-startStop-8][HotDeployImpl:233] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering servlet context listeners for content-hookcontent-hookcom.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering servlet context listeners for content-hookcontent-hook at com.liferay.portal.kernel.deploy.hot.BaseHotDeployListener.throwHotDeployException(BaseHotDeployListener.java:46) at com.liferay.portal.deploy.hot.ServletContextListenerHotDeployListener.invokeDeploy(ServletContextListenerHotDeployListener.java:40) at com.liferay.portal.deploy.hot.HotDeployImpl.doFireDeployEvent(HotDeployImpl.java:230) at com.liferay.portal.deploy.hot.HotDeployImpl.fireDeployEvent(HotDeployImpl.java:96) at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:28) at com.liferay.portal.kernel.servlet.PluginContextListener.fireDeployEvent(PluginContextListener.java:164) at com.liferay.portal.kernel.servlet.PluginContextListener.doPortalInit(PluginContextListener.java:154) at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:44) at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:74) at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:58) at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:54) at com.liferay.portal.kernel.servlet.PluginContextListener.contextInitialized(PluginContextListener.java:116) at com.liferay.portal.kernel.servlet.SecurePluginContextListener.contextInitialized(SecurePluginContextListener.java:151) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5016) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5528) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1263) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1948) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745)Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.liferay.portal.deploy.hot.ServletContextListenerHotDeployListener.doInvokeDeploy(ServletContextListenerHotDeployListener.java:77) at com.liferay.portal.deploy.hot.ServletContextListenerHotDeployListener.invokeDeploy(ServletContextListenerHotDeployListener.java:37) ... 24 moreCaused by: java.lang.NoClassDefFoundError: org/springframework/web/context/support/XmlWebApplicationContext at be.aca.literay.spring.VelocityBeanLocatorContextListener.<init>(VelocityBeanLocatorContextListener.java:37) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at java.lang.Class.newInstance(Class.java:379) at com.liferay.portal.kernel.util.InstanceFactory.newInstance(InstanceFactory.java:63) at com.liferay.portal.kernel.util.InstanceFactory.newInstance(InstanceFactory.java:27) at com.liferay.portal.kernel.servlet.SecurePluginContextListener.instantiatingListener(SecurePluginContextListener.java:304) at com.liferay.portal.kernel.servlet.SecurePluginContextListener.instantiatingListeners(SecurePluginContextListener.java:163) ... 30 moreCaused by: java.lang.ClassNotFoundException: org.springframework.web.context.support.XmlWebApplicationContext at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) ... 40 more Veuillez vous identifier pour voter. Répondre en tant que ... Annuler S H S H Il y a 7 années OK. After adding below attribute in liferay-plugin-package.properties, the missing class is resolved.portal-dependency-jars=spring-aop.jar,\spring-asm.jar,\spring-aspects.jar,\spring-beans.jar,\spring-context-support.jar,\spring-context.jar,\spring-core.jar,\spring-expression.jar,\spring-jdbc.jar,\spring-jms.jar,\spring-orm.jar,\spring-oxm.jar,\spring-transaction.jar,\spring-web-portlet.jar,\spring-web-servlet.jar,\spring-web-struts.jar,\spring-web.jar Veuillez vous identifier pour voter. Répondre en tant que ... Annuler
S H S H Il y a 7 années OK. After adding below attribute in liferay-plugin-package.properties, the missing class is resolved.portal-dependency-jars=spring-aop.jar,\spring-asm.jar,\spring-aspects.jar,\spring-beans.jar,\spring-context-support.jar,\spring-context.jar,\spring-core.jar,\spring-expression.jar,\spring-jdbc.jar,\spring-jms.jar,\spring-orm.jar,\spring-oxm.jar,\spring-transaction.jar,\spring-web-portlet.jar,\spring-web-servlet.jar,\spring-web-struts.jar,\spring-web.jar Veuillez vous identifier pour voter. Répondre en tant que ... Annuler