RE: How to add a dependency in core jsp fragment?

thumbnail
Abhishek Jain, modified 7 Years ago. Regular Member Posts: 226 Join Date: 8/20/16 Recent Posts
I need to make a core jsp fragment to override portal-web's jsp file. In that I want to use JournalArticle class. I added dependency of journal api to resolve this but I got an exception that JournalArticle cannot be resolved to a type. I want to ask how to add a dependency to the portal-web fragment module. Any help would be appreciated.
Rayappa Hattarwat, modified 7 Years ago. Junior Member Posts: 89 Join Date: 8/11/15 Recent Posts
Hello Abhishek ,

Check this
https://web.liferay.com/web/user.26526/blog/-/blogs/adding-dependencies-to-jsp-fragment-bundles
thumbnail
Abhishek Jain, modified 7 Years ago. Regular Member Posts: 226 Join Date: 8/20/16 Recent Posts
Thanks Rayappa for your reply,

I have already checked this link but could not get the answer...
Milind Jain, modified 7 Years ago. Junior Member Posts: 28 Join Date: 12/29/17 Recent Posts

Hello,

I am also facing same issue. Please help.

Thanks

 

thumbnail
Olaf Kock, modified 7 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
Milind Jain:

I am also facing same issue. Please help.

Please give us some hints. David's Blog article answers the question well. And if you can't make it work, just stating that it doesn't work won't give anyone the opportunity to "check line 42" in your code, where you missed a declaration.

Provide a minimal working (well, non-working in this case) implementation, that can be inspected and used to figure out what you did. Just with this statement, I'd just point you back to David's article. If there's something that you don't understand, just ask about a specific item. Or, better, post code. Simple, minimal, inspectable code.

 

 

thumbnail
Tomas Polesovsky, modified 7 Years ago. Liferay Master Posts: 677 Join Date: 2/13/09 Recent Posts

Hi,

portal-web is not OSGi bundle, it's not possible to use OSGi fragments. If you need to modify Core JSP you should write a new module with a DynamicInclude. The use is limited but at least it allows referencing classes from other OSGi bundles. Dynamic Includes use RequestDispatcher so the JSP is loaded with your module's class loader that can see what's imported by your module.

Another way is to use old JSP Hooks but it's not possible to reference JournalArticle that is inside OSGi bundle. Core JSPs are loaded using Tomcat's webapp class loader that doesn't inherit from OSGi framework class loaders. The same is with the EXT.

 

HTH.

 

-- tom +

thumbnail
Olaf Kock, modified 7 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
Tomas Polesovsky:

portal-web is not OSGi bundle, it's not possible to use OSGi fragments. If you need to modify Core JSP you should write a new module with a DynamicInclude

Amazing how persistently I've read over the "core" part of the question. Thanks, Tom, for paying close attention.

If nothing else, you could deploy a core jsp change through an old hook, but limit the introduced difference to a new dynamic include, then provide a module to implement this DI.