Fórumok
Only a type can be imported
Maxim Kovalev, módosítva 12 év-val korábban
Only a type can be imported
New Member Bejegyzések: 23 Csatlakozás dátuma: 2012.02.15. Legújabb bejegyzések
Hi, All
I created liferay project portlet. It added the liferay hook, which overrides user_action.jsp
In the jsp I need to access your class Test.java which I added in src portlet. But when you call I get an error:
An error occurred at line: 15 in the generated java file
Only a type can be imported. test.Test resolves to a package
I really need your help
I created liferay project portlet. It added the liferay hook, which overrides user_action.jsp
In the jsp I need to access your class Test.java which I added in src portlet. But when you call I get an error:
An error occurred at line: 15 in the generated java file
Only a type can be imported. test.Test resolves to a package
I really need your help
Jitendra Rajput, módosítva 12 év-val korábban
RE: Only a type can be imported
Liferay Master Bejegyzések: 875 Csatlakozás dátuma: 2011.01.07. Legújabb bejegyzések
I think this Test.java is not present in your class path.
Jitendra Rajput, módosítva 12 év-val korábban
RE: Only a type can be imported
Liferay Master Bejegyzések: 875 Csatlakozás dátuma: 2011.01.07. Legújabb bejegyzések
look at this link for more information abt this errror.
http://stackoverflow.com/questions/1858463/java-error-only-a-type-can-be-imported-xyz-resolves-to-a-package
http://stackoverflow.com/questions/1858463/java-error-only-a-type-can-be-imported-xyz-resolves-to-a-package
Maxim Kovalev, módosítva 12 év-val korábban
RE: Only a type can be imported
New Member Bejegyzések: 23 Csatlakozás dátuma: 2012.02.15. Legújabb bejegyzések
My problem is probably not the case.
custom_jsps \ html \ portlet \ users_admin \ edit_user.jsp I override the deploy when copied to the tomcat\webapps\ROOT\html\portlet \ users_admin, and the classes it needs are in the portlet. How do I make them visible?
custom_jsps \ html \ portlet \ users_admin \ edit_user.jsp I override the deploy when copied to the tomcat\webapps\ROOT\html\portlet \ users_admin, and the classes it needs are in the portlet. How do I make them visible?
Maxim Kovalev, módosítva 12 év-val korábban
RE: Only a type can be imported
New Member Bejegyzések: 23 Csatlakozás dátuma: 2012.02.15. Legújabb bejegyzések
I saw on the forum that this problem can be solved by renderURL
in custom_jsps \ html \ portlet \ users_admin \ edit_user.jsp I added:
That is, when you call the portlet should work its ClassLoader, but the problem persists
maybe I'm wrong?
in custom_jsps \ html \ portlet \ users_admin \ edit_user.jsp I added:
<liferay-portlet:renderurl plid="10163" portletname="user-reg_WAR_user-reg-portlet" var="userRegisterPortlet">
<!-- liferay-portlet: renderURL--></liferay-portlet:renderurl>
That is, when you call the portlet should work its ClassLoader, but the problem persists
maybe I'm wrong?
Maxim Kovalev, módosítva 12 év-val korábban
RE: Only a type can be imported
New Member Bejegyzések: 23 Csatlakozás dátuma: 2012.02.15. Legújabb bejegyzések
Please, help me!
Natalie D, módosítva 11 év-val korábban
RE: Only a type can be imported
Junior Member Bejegyzések: 55 Csatlakozás dátuma: 2012.02.06. Legújabb bejegyzésekMaxim Kovalev:
Please, help me!
I know that almost three months have passed, but for other folks who will find this question in the future:
It is not possible to access classes from one portlet inside other portlets, due to different ClassLoaders. Think of it as every portlet/hook is inside its own sandbox.
When you want to access classes from other portlets it is just poor design. So change your strategy.
FYI: to access classes defined by yourself from any other portlet the only thing you can do (as far as I know) is prepare EXT plugin and add new classes to it.
Regards
Natalie
Thomas Cozien, módosítva 11 év-val korábban
RE: Only a type can be imported
New Member Bejegyzések: 11 Csatlakozás dátuma: 2012.01.25. Legújabb bejegyzések
Hi, even if your statement is true, I got the error :
Only a type can be imported. x.y.service.XServiceUtil resolves to a package
When accessing to my service in my override jsp.
As Maxim Kovalev, I created Iiferay hook to override some struts action : /blogs/edit-entry
(I follow this page : http://www.liferay.com/web/mika.koivisto/blog/-/blogs/7132115 )
My liferay-hook.xml :
I override /html/portlet/blogs/edit_entry.jsp and added the import :
There is a single portlet;
Any suggestions?
Regards
Tom
Only a type can be imported. x.y.service.XServiceUtil resolves to a package
When accessing to my service in my override jsp.
As Maxim Kovalev, I created Iiferay hook to override some struts action : /blogs/edit-entry
(I follow this page : http://www.liferay.com/web/mika.koivisto/blog/-/blogs/7132115 )
My liferay-hook.xml :
<hook>
<custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>
<struts-action>
<struts-action-path>/blogs/edit_entry</struts-action-path>
<struts-action-impl>x.y.EditBlogEntryAction</struts-action-impl>
</struts-action>
</hook>
I override /html/portlet/blogs/edit_entry.jsp and added the import :
<%@ include file="x.y.service.XServiceUtil" %>
Natalie D:
It is not possible to access classes from one portlet inside other portlets, due to different ClassLoaders. Think of it as every portlet/hook is inside its own sandbox.
When you want to access classes from other portlets it is just poor design.
There is a single portlet;
Any suggestions?
Regards
Tom
Sandeep Nair, módosítva 11 év-val korábban
RE: Only a type can be imported
Liferay Legend Bejegyzések: 1744 Csatlakozás dátuma: 2008.11.06. Legújabb bejegyzések
Hi Tom,
You are overriding portal's jsp, which will run in portal's classloader. So it cannot access the services in hook(hook's classloader is different). You have to move your custom-service.jar in global classpath for the issue to get resolved.
Regards,
Sandeep
You are overriding portal's jsp, which will run in portal's classloader. So it cannot access the services in hook(hook's classloader is different). You have to move your custom-service.jar in global classpath for the issue to get resolved.
Regards,
Sandeep
Thomas C, módosítva 11 év-val korábban
RE: Only a type can be imported
New Member Bejegyzések: 11 Csatlakozás dátuma: 2012.01.25. Legújabb bejegyzések
Hi Sandeep,
Thanks for the precision.
Indeed, I move my custom-service.jar in tomcat's ext lib and it works.
Regards,
Tom
Thanks for the precision.
Indeed, I move my custom-service.jar in tomcat's ext lib and it works.
Regards,
Tom