Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Abhed Dekavadiya
Problem accessing properties in an entity created through service builder
September 5, 2011 12:44 AM
Answer

Abhed Dekavadiya

Rank: Junior Member

Posts: 74

Join Date: October 5, 2010

Recent Posts

Hi,

I have created a spring MVC portlet in Liferay-6-EE-SP1.
I am connecting to an external database, and I have created services for that through liferay's service-builder.
I needed some additional properties to an entity without adding it in database table. So I have added those properties in <entity>Impl.java file. I re-build service and it is working fine in my portlet (A).
But when I placed the service.jar in tomcat/lib/ext/ and try to use those additional properties from another portlet ( B ), it fails.
I am able to access services using <entity>localsertiviceUtil.java.
But when i try to access <entity>.getAdditionalProperty(), it gives me UnsupportedOperationException. [same is working from my portlet (A)]

After the analysis I found that the problem is with <entity>Clp.java file. It is simply throwing UnsupportedOperationException() exception for setter/getter of those additional properties.

The code in <entity>Clp.java is simply like below.
1
2public <entity> get<entity>() {
3        throw new UnsupportedOperationException();
4}


Now I don't know, why service builder does that?
Can anyone return "I KNOW SOMETHING ABOUT THIS", than throwing "IDONOTKNOWEXCEPTION".

Help please ! Thanks in advance!

regards,
Abhed
Jaime L. López Carratalá
RE: Problem accessing properties in an entity created through service build
November 17, 2011 5:19 AM
Answer

Jaime L. López Carratalá

Rank: New Member

Posts: 4

Join Date: June 2, 2008

Recent Posts

Hi Abhed,

I am having the same problem than you, have you found any solution?

Thanks.
Abhed Dekavadiya
RE: Problem accessing properties in an entity created through service build
November 17, 2011 7:08 AM
Answer

Abhed Dekavadiya

Rank: Junior Member

Posts: 74

Join Date: October 5, 2010

Recent Posts

Hi Jaime,

No I didn't found any solution for this. This issue should be reported with Liferay's JIRA, but I don't know how to do that.
If you don't have to build service multiple times, then you can try a workaround by changing the Clp.java file and returning that property rather than exception.
Ravi Kumar Gupta
RE: Problem accessing properties in an entity created through service build
November 17, 2011 7:24 AM
Answer

Ravi Kumar Gupta

Rank: Liferay Legend

Posts: 1303

Join Date: June 23, 2009

Recent Posts

Is that so, because that method should be implemented by user so that it doesn't report any exception.. For all other basic properties it returns values properly and doesn't throw any exception.. Correct me if I am wrong..
Abhed Dekavadiya
RE: Problem accessing properties in an entity created through service build
November 17, 2011 8:12 AM
Answer

Abhed Dekavadiya

Rank: Junior Member

Posts: 74

Join Date: October 5, 2010

Recent Posts

I am talking about Clp.java file, which is auto generated by service builder.
Ravi Kumar Gupta
RE: Problem accessing properties in an entity created through service build
November 17, 2011 8:45 AM
Answer

Ravi Kumar Gupta

Rank: Liferay Legend

Posts: 1303

Join Date: June 23, 2009

Recent Posts

Yep.. I know that.. And I just wanted to know if that is to be implemented.. Do you see any instance variable which holds that entity in clp?? If no, then it is to be derived/calculated and returned.. that's what I thought.. emoticon
Jan Geißler
RE: Problem accessing properties in an entity created through service build
February 28, 2012 10:55 AM
Answer

Jan Geißler

Community Moderator

Rank: Liferay Master

Posts: 735

Join Date: July 5, 2011

Recent Posts

Same Problem here.
ClassLoaderProxy Class of Entity gets overwritten every Time, when I regenerate my service-Classes. Calls to ServiceUtils in EntityIImpl class gets the same result. CLP throws UnsupportedOpperationException.

ProjectCLP Snippet:
1
2       public java.util.List<de.osc.projectadministration.model.ProjectDay> getProjectDays() {
3        throw new UnsupportedOperationException();
4    }
5
6    public int getDaysCount() {
7        throw new UnsupportedOperationException();
8    }


And here the corresponding ProjectImplSnippet:
 1
 2    private List<ProjectDay> projectDays;   
 3    public ProjectImpl() {
 4    }
 5   
 6    public List<ProjectDay> getProjectDays() throws SystemException{
 7        if(this.projectDays == null) {
 8            this.projectDays = ProjectDayUtil.findByProjectId(this.getProjectId()); //Also tried calls to LocalserviceUtil and ServiceUtil
 9        }
10        return this.projectDays;
11    }
12   
13    public int getDaysCount(){
14        try {
15            return getProjectDays().size();
16        } catch (SystemException e) {            
17            e.printStackTrace();
18            return 0;
19        }
20    }


Any Help would really be appreciated....

So long
Jan
Bin Zhu
RE: Problem accessing properties in an entity created through service build
October 16, 2012 3:44 PM
Answer

Bin Zhu

Rank: New Member

Posts: 3

Join Date: May 17, 2010

Recent Posts

I believe it's a unsolved Liferay issue: http://issues.liferay.com/browse/LPS-11925
Giuseppe Pantaleo
RE: Problem accessing properties in an entity created through service build
November 9, 2012 1:47 AM
Answer

Giuseppe Pantaleo

Rank: New Member

Posts: 15

Join Date: June 18, 2012

Recent Posts

Bin Zhu:
I believe it's a unsolved Liferay issue: http://issues.liferay.com/browse/LPS-11925



I'm experiencing the same problem using Liferay 6.1.1 CE GA2.
In the issue LPS-11925 the "Affetcs version" are LR 6.0.x; how can I modify, if possible, the mentioned LPS-11925 in JIRA to add LR 6.1.1 CE GA2 to the affetcs version?