Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Alvaro San Millan
Hot and auto deploy.listeners do not run during first deployment
February 14, 2013 3:45 AM
Answer

Alvaro San Millan

Rank: New Member

Posts: 16

Join Date: September 5, 2012

Recent Posts

Dear all,

I have a portlet app and I have been implemented a auto.deploy.listener to add async supported to Invoker Filters. In the deploy method I access to web.xml and add this element <async-supported>true</async-supported> to the four Invoker Filters injected by liferay during the deployment. I have not found another better way to do this. And it works. But only when I make a hot deploy twice.

I think the first time I deploy the app, the listener is registered (or something like that) and then, second deployment, run the listener code.

Is there any way to run the listener code during the first deployment?

I have tried using hot.deploy.listeners, but I've found the same issue.

Thanks in advanced,

Alvaro
Siby Mathew
RE: Hot and auto deploy.listeners do not run during first deployment
February 14, 2013 4:50 AM
Answer

Siby Mathew

Rank: Expert

Posts: 267

Join Date: March 4, 2011

Recent Posts

Hi Alvaro,
You can try to create a separate hook which listens to hot deployments.
This hook should be deployed in the first place so that it can listen to all hot deployments.
In the overridden invokeDeploy() method you can get the classloader of the deployed portlet.

1
2@Override
3public void invokeDeploy(final HotDeployEvent event) throws HotDeployException {
4   final ClassLoader portletClassLoader = event.getContextClassLoader(); //classLoader of the deploying portlet
5   final String portletName = event.getServletContextName(); //Name of the portlet
6}


Hope this helps in some way.

Thanks,
Siby
Alvaro San Millan
RE: Hot and auto deploy.listeners do not run during first deployment
February 14, 2013 6:52 AM
Answer

Alvaro San Millan

Rank: New Member

Posts: 16

Join Date: September 5, 2012

Recent Posts

Ok, let me try that.

Thanks for your quick response Mathew.
Alvaro San Millan
RE: Hot and auto deploy.listeners do not run during first deployment
February 15, 2013 7:49 AM
Answer

Alvaro San Millan

Rank: New Member

Posts: 16

Join Date: September 5, 2012

Recent Posts

Hi,

I have been trying your approach. I have created a new hook that extends the class BaseHotDeployListener and override invokeDeploy and invokeUndeploy (just log some text in console). I deploy this hook first and no problems here. But when I deploy the portlet application, the hook cannot listen the hot deployment (I cannot see any message).

Any idea?

Regards,

Alvaro San Millan
Alvaro San Millan
RE: Hot and auto deploy.listeners do not run during first deployment
February 15, 2013 7:50 AM
Answer

Alvaro San Millan

Rank: New Member

Posts: 16

Join Date: September 5, 2012

Recent Posts

This is the code:

 1public class CustomizedHotDeployListener extends BaseHotDeployListener {
 2
 3    private static final Logger LOGGER = Logger.getLogger(CustomizedHotDeployListener.class);
 4
 5    @Override
 6    public void invokeDeploy(HotDeployEvent event) throws HotDeployException {
 7        // Get ClassLoader of the deploying portlet
 8        final ClassLoader portletClassLoader = event.getContextClassLoader();
 9        final String portletName = event.getServletContextName();       
10        LOGGER.info("******** Portlet " + portletName + " is being deploy");
11    }
12
13    @Override
14    public void invokeUndeploy(HotDeployEvent event) throws HotDeployException {
15        // Get ClassLoader of the deploying portlet
16        final ClassLoader portletClassLoader = event.getContextClassLoader();
17        final String portletName = event.getServletContextName();       
18        LOGGER.info("******** Portlet " + portletName + " is being UNdeploy");
19    }
Siby Mathew
RE: Hot and auto deploy.listeners do not run during first deployment
February 15, 2013 8:24 AM
Answer

Siby Mathew

Rank: Expert

Posts: 267

Join Date: March 4, 2011

Recent Posts

Hi Alvaro,
One question. Initially you had the listener configured in the portlet itself rt ?
Have you removed this entry ? (Maybe you can delete and redeploy the old portlet after removing the hook)
Also hope your log is also configured correctly. Put a sysout just in case (start and end)

Thanks,
Siby
Alvaro San Millan
RE: Hot and auto deploy.listeners do not run during first deployment
February 15, 2013 8:39 AM
Answer

Alvaro San Millan

Rank: New Member

Posts: 16

Join Date: September 5, 2012

Recent Posts

Yes, I had the listener in the portlet, but I removed it from there, clean my server directories, etc...

Now, I've just printed to the standard out (sysout) and still I cannot see those messages emoticon

The point is that when I had the hot listener in the portlet application itself, I could see those messages, but not when I deploy the listener as a separate application.

No idea what is happening emoticon
Siby Mathew
RE: Hot and auto deploy.listeners do not run during first deployment
February 15, 2013 8:42 AM
Answer

Siby Mathew

Rank: Expert

Posts: 267

Join Date: March 4, 2011

Recent Posts

Ok.
Not sure if its a bug, maybe you can try to create the new hook as a portlet-hook and see if its getting invoked.

Thanks,
Siby