Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Inability to share exported package (api module) in portlet (web module
Dear All,
in my Service Builder module portlet (split into 'api', 'service' and 'web' parts) I have some util classes in 'api' portlet, but also one in the 'web' portlet. If the same package is used, that 'web' class becomes invisible:
If that 'web' portlet package name is altered 'util' -> 'utilx', it works fine.
I find it is related to my 'api' portlet bnd.bnd exports settings:
Now if that 'utilx' is also added into bnd.bnd, I am getting exactly same error as above:
The fix is apparent, not to share exported packages in the web part, but 'util' package is ideal in my case.
Is this behaviour documented somewhere?
in my Service Builder module portlet (split into 'api', 'service' and 'web' parts) I have some util classes in 'api' portlet, but also one in the 'web' portlet. If the same package is used, that 'web' class becomes invisible:
2019-02-13 13:08:25.860 ERROR [http-nio-8080-exec-10][render_portlet_jsp:131] null
org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP__PWC6199: Generated servlet error:_cannot find symbol_ symbol: class MyUtilClass_ location: package com.mycompany.myportlet.util__PWC6199: Generated servlet error:_view_jsp.java uses or overrides a deprecated API.__PWC6199: Generated servlet error:_Recompile with -Xlint:deprecation for details.__PWC6199: Generated servlet error:_view_jsp.java uses unchecked or unsafe operations.__PWC6199: Generated servlet error:_Recompile with -Xlint:unchecked for details.__ [Sanitized]
If that 'web' portlet package name is altered 'util' -> 'utilx', it works fine.
I find it is related to my 'api' portlet bnd.bnd exports settings:
Export-Package:\
com.mycompany.myportlet.util
Now if that 'utilx' is also added into bnd.bnd, I am getting exactly same error as above:
Export-Package:\
com.mycompany.myportlet.util, \
com.mycompany.myportlet.utilx
The fix is apparent, not to share exported packages in the web part, but 'util' package is ideal in my case.
Is this behaviour documented somewhere?
Jan TošovskýDear All,
in my Service Builder module portlet (split into 'api', 'service' and 'web' parts) I have some util classes in 'api' portlet, but also one in the 'web' portlet. If the same package is used, that 'web' class becomes invisible:2019-02-13 13:08:25.860 ERROR [http-nio-8080-exec-10][render_portlet_jsp:131] null org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP__PWC6199: Generated servlet error:_cannot find symbol_ symbol: class MyUtilClass_ location: package com.mycompany.myportlet.util__PWC6199: Generated servlet error:_view_jsp.java uses or overrides a deprecated API.__PWC6199: Generated servlet error:_Recompile with -Xlint:deprecation for details.__PWC6199: Generated servlet error:_view_jsp.java uses unchecked or unsafe operations.__PWC6199: Generated servlet error:_Recompile with -Xlint:unchecked for details.__ [Sanitized]
If that 'web' portlet package name is altered 'util' -> 'utilx', it works fine.
I find it is related to my 'api' portlet bnd.bnd exports settings:Export-Package:\ com.mycompany.myportlet.util
Now if that 'utilx' is also added into bnd.bnd, I am getting exactly same error as above:Export-Package:\ com.mycompany.myportlet.util, \ com.mycompany.myportlet.utilx
The fix is apparent, not to share exported packages in the web part, but 'util' package is ideal in my case.
Is this behaviour documented somewhere?
It works best if you have a unique association of a package with a bundle: Don't add more classes to packages from other bundles.
Also, IMHO, a -web project should not really export functionality. If you need some functionality there that other bundles need as well, create a separate bundle. Alternatively add an interface to the api, the implementation to the service bundle. You can even make Util-classes proper services and depend only on their interfaces. Rarely if ever is there a necessity to import a concrete class from another bundle. The more you rely on interfaces for your dependencies, the better maintainable your system will be.
Olaf KockI'd like to clarify I am only exporting from api module. In the 'api' module there are several classes with public constants in util package. In the web module I had a custom SearchContainer class in the util package. To workaround this issue I've just moved it into 'search' package.
a -web project should not really export functionality.
I remember I was curious why web parts have its own package name in LR apps, e.g. com.liferay.calendar.web.internal.portlet.CalendarPortlet. It seems it is not only cosmetic, but there is a good reason for it as it avoids problems I had. I'll follow the same approach.
Jan
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™