Laliwala IT Services

Laliwala IT Services
Website Development

Monday, February 21, 2011

Error "Only a type can be imported...resolves to a package"





Victor AMORIM : Error "Only a type can be imported...resolves to a package"
Hi,
I develope an struts portlet to interact with an MySql database.
I use the plugin SDK and the service builder.
I began to create my service.xml, i have used the service-buider, I have added the methods to create a new entry in the database in "com.portlet.annuaire.service.impl.EntreeAnnuaireLocalServiceImpl.java". And I have used a second time the service-builder.
I have deployed with Ant, when i have started the Tomcat server I have this error:
To resolve this problem I try to import alls classes like:

<%@ page import="com.portlet.annuaire.service.*" %>

<%@ page import="com.portlet.annuaire.model.*" %>

But it did not work.
My Configuration:

Eclipse Europa

Liferay-portal-5.2.3 with Tomcat 6.0.18

jdk1.5.0_13
Thanks in advance.
A Gupta :
Instead of using "com.liferay.annuaire.*", try to use specific files(like com.liferay.annuaire.classname) you want to use. There might be some files in that directory that can't be imported.
Victor AMORIM : Thanks for your reply.
When I have the error I importe juste the classes that I need:
<%@ page import="com.portlet.annuaire.model.EntreeAnnuaire" %>
<%@ page import="com.portlet.annuaire.service.EntreeAnnuaireLocalServiceUtil" %>
This code produce the error that is describe above.
Thanks
Mazhar Anwar :
Can you make sure YOUR_PORTLET/WEB-INF/lib folder contains YOUR-PORTLET-NAME-service.jar file?
Victor AMORIM : No, when I deploy with ant the PORTLET-NAME-service.jar is gone. I don't know when it disapears. I thing its when I use the service-builder.
How can I produce the jar?
Thanks
`Mazhar Anwar :
When you do ANT BUILD_SERVICE, On successful build, it will generate the YOUR-PORTLET-NAME-service.jar inside PORTLET-FOLDER/docroot/WEB-INF/lib folder which contains all model and service classes for the portlet and you can use them in your jsp as in previous posts.
Victor AMORIM : You're right, the ant product the jar, but when I deploy it disappears and should not be imported into the server. That why I have the error in my first post, I think.
Victor AMORIM : That's good, thanks a lot.
To resume the MY-PORTLET-NAME-portlet-service.jar was create when I use the service-builder but when I deploy with ANT the jar are deleted.
I do a copy of this jar, and I past it directly in the tomcat directory ("...\ext\servers\tomcat\liferay-portal-5.2.3\tomcat-6.0.18\webapps\PORTLET_FOLDER\docroot\WEB-INF\lib\".
That's resolves the problem "Only a type can be imported..."
Now I have another problem:
I'll do some research on this problem.
Regards

5 comments:

  1. I am not ѕurе ωhere уou are getting your infοrmation, but good
    topic. I needs to spеnd somе time learning much more or undегѕtanding mоre.

    Thаnks for wonderful information I was lοoking
    fοг this info for my missiοn.

    Feel free to ѕurf to my web blοg ... Engagement Rings

    ReplyDelete
  2. Thіѕ pieсе οf writіng оfferѕ сlear idea foг the new νіѕitors οf blogging, that genuinely hoω to ԁo runnіng a blog.


    Also ѵіѕit my sitе :: Eternity rings

    ReplyDelete
  3. Eveгу wеekend i usеԁ to pаy
    a quick viѕit this web sіte, аs i wіsh
    for enjoyment, for the reason thаt thіѕ this sіte conatiοnѕ really faѕtidious funny ԁata toο.


    Heгe іs my blog :: payday loans

    ReplyDelete
  4. It's really a nice and helpful piece of info. I am happy that you simply shared this useful info with us. Please keep us informed like this. Thank you for sharing.

    Also visit my blog post: payday loans

    ReplyDelete
  5. Apprеciate the reсommеnԁation.

    Lеt me try іt out.

    my site ... personal loans

    ReplyDelete