Reputation: 215
When I use PortalUtil.getPortalPort(secure)
in a scheduler it always returns -1 instead of the right port number 8080.
boolean secure = "https".equalsIgnoreCase( PropsUtil.get( PropsKeys.WEB_SERVER_PROTOCOL ) );
Company company = CompanyLocalServiceUtil.getCompanies().get(0);
String portalURL = PortalUtil.getPortalURL(company.getVirtualHostname(), PortalUtil.getPortalPort(secure), secure);
If I run the code from a managed bean, it works fine.
Is there any other way to get the server port from a scheduler?
Upvotes: 1
Views: 478
Reputation: 3660
Since you are executing the code from scheduler, and you don't have reference to request object, you cant get the server port using PortalUtil.
You can try the hack mentioned here. Java EE getting servlet container port
Upvotes: 1