RE: Not possible to call external webservice from scheduled task

Bernd S, modified 5 Years ago. Junior Member Posts: 59 Join Date: 3/31/15 Recent Posts
I implemented a scheduled task following this blog entry :  https://liferay.dev/blogs/-/blogs/liferay-7-ce-liferay-dxp-scheduled-tasks

Additionally I have an external webservice which I access using generated code from wsimport.

On their own both of those work without a hitch. The task gets executed in the defined intervall and calls to the webservice receive the expected response. 

But as soon as I call the webservice from inside my scheduled task I get the following exception:

java.lang.IllegalStateException: The JAX-WS API bridge is not properly initialized. Please configure it in System Settings.
    at com.liferay.jaxws.osgi.bridge.Provider.getProvider(Provider.java:172)
    at com.liferay.jaxws.osgi.bridge.Provider.createServiceDelegate(Provider.java:106)
    at javax.xml.ws.Service.<init>(Service.java:77)
    at at.company.form.service.connector.apf.model.PortalServiceImplService.<init>(PortalServiceImplService.java:37)
    at at.company.form.service.connector.apf.WSClient.getProxy(WSClient.java:182)
    at at.company.form.service.connector.apf.WSClient.getFormInfo(WSClient.java:76)
    at at.company.form.job.notification.NotificationProcessor.minSubmissionReached(NotificationProcessor.java:175)
    at at.company.form.job.notification.NotificationProcessor.getDataToBeNotified(NotificationProcessor.java:155)
    at at.company.form.job.notification.NotificationProcessor.getNotificationData(NotificationProcessor.java:113)
    at at.company.form.job.notification.NotificationProcessor.process(NotificationProcessor.java:50)
    at at.company.form.job.notification.NotificationJob.doReceive(NotificationJob.java:44)
    at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:26)
    at com.liferay.portal.kernel.scheduler.messaging.SchedulerEventMessageListenerWrapper.receive(SchedulerEventMessageListenerWrapper.java:66)
    at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:74)
    at com.liferay.portal.kernel.messaging.ParallelDestination$1.run(ParallelDestination.java:52)
    at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask._runTask(ThreadPoolExecutor.java:756)
    at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:667)
    at java.lang.Thread.run(Thread.java:748)

This makes no sense to me and my search didn't result in anything useable.

Any ideas?
thumbnail
Christoph Rabel, modified 5 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
Try to add an cxf endpoint to the configuration. Just some dummy entry.
Which Liferay version are you using. Also, the java version is relevant, for Java 11 you need to do some extra stuff to make it find the ProviderImpl class.
Bernd S, modified 5 Years ago. Junior Member Posts: 59 Join Date: 3/31/15 Recent Posts
Added one SOAP Extender with a random context path, if that is what you mean. Still getting the same exception.
I am using Liferay DXP 7.0 and Java 8.
thumbnail
Christoph Rabel, modified 5 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
No, I meant a CXF endpoint.
I am not a 100% sure, but I think, the service is only registered when a cxf endpoint is configured.
Bernd S, modified 5 Years ago. Junior Member Posts: 59 Join Date: 3/31/15 Recent Posts
Thanks for the hint but unfortunately it had no effect.
Bernd S, modified 5 Years ago. Junior Member Posts: 59 Join Date: 3/31/15 Recent Posts
Figured it out thanks to Chrisoph Rabel and a comment in this bug report:

The issue you are finding might be caused by a missing configuration. Please make sure that:
  • You have Portal Remote Soap Extender bundle installed and active
  • You have at least one CXF Endpoint created in Control Panel > Configuration > System Settings > Foundation > CXF Endpoints. You only need to provide a Context Path
  • You have configured JAX-WS API in Control Panel > Configuration > System Settings > Foundation > JAX-WS API making it point to the CXF instance you want it to use by passing the same context path.
Checked it with the Gogo shell and now it works indeed!

g! services "(objectClass=javax.xml.ws.spi.Provider)"                                                                  
{javax.xml.ws.spi.Provider}={osgi.http.whiteboard.context.path=/test, service.id=8086, service.bundleid=374, service.scope=singleton}                                                                                                  
   "Registered by bundle:" com.liferay.portal.remote.soap.extender.impl_1.0.7 [374]                                       
  "Bundles using service"                                                                                                  
     org.eclipse.osgi_3.10.200.v20150831-0856 [0]