Forums

Home » Liferay IDE » English

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Kailas Lokhande
Multiple Service.xml in Single Plugin
February 13, 2013 7:16 PM
Answer

Kailas Lokhande

Rank: New Member

Posts: 10

Join Date: November 6, 2012

Recent Posts

Hello Experts,

I have one plugin, which requires 5 entities. I want these 5 entities to be belongs to 5 different packages, for that I added 5 service.xml with different package path specified in it. And ran the service builder.
But I observed that service jar that gets created is not getting properly build.
I always get ClassCastException like com.model.impl.ClassAImpl cannot be cast to com.model.ClassA

Can anyone tell me what could be the solution?
And is there a way to run these 5 service.xml at single time?

I would really appreciate any word on this

Thanks,
Kailas Lokhande
David H Nebinger
RE: Multiple Service.xml in Single Plugin
February 13, 2013 7:37 PM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7512

Join Date: September 1, 2006

Recent Posts

You might be able to use the import for the 4 additional files, but I don't know that SB will honor your package declarations.

According to the liferay-service-builder_6_1_0.dtd:

 1 <!--
 2 The service-builder-import allows you to split up a large Service Builder file
 3 into smaller files by aggregrating the smaller Service Builder into one file.
 4 Note that there can be at most one author element among all the files. There can
 5 also only be one and only one namespace element among all the files.
 6
 7 The attribute file is interpreted as relative to the file that is importing it.
 8 -->
 9 <!ELEMENT service-builder-import (#PCDATA)>
10
11 <!--
12 Set the comments in the service-builder-import element.
13 -->
14 <!ATTLIST service-builder-import
15    file CDATA #REQUIRED
16 >
Meera Prince
RE: Multiple Service.xml in Single Plugin
February 13, 2013 8:29 PM
Answer

Meera Prince

Rank: Liferay Master

Posts: 841

Join Date: February 8, 2011

Recent Posts

HI
<service-builder-import file="service1.xml" />
<service-builder-import file="service2.xml" />

https://www.liferay.com/community/forums/-/message_boards/message/14653303
http://www.liferay.com/community/forums/-/message_boards/message/13314225


Regards,
Meera Prince
http://www.liferaysavvy.com/
Kailas Lokhande
RE: Multiple Service.xml in Single Plugin
February 13, 2013 10:39 PM
Answer

Kailas Lokhande

Rank: New Member

Posts: 10

Join Date: November 6, 2012

Recent Posts

Yes David, SB does not honor package declarations. But atleast I can have separate service.xml for entities .
Thanks for great help.
D. U.
RE: Multiple Service.xml in Single Plugin
January 6, 2014 4:38 AM
Answer

D. U.

Rank: New Member

Posts: 14

Join Date: November 25, 2013

Recent Posts

This doesn't work for me.
I have a service.xml with the 'regular' stuff which is generated perfectly from ServiceBuilder. As suggested, I created another service.xml called service-importer.xml in which I defined two entities with no columns (because they don't need database access) to create these services into their own package-path:

 1<?xml version="1.0" encoding="UTF-8"?>
 2<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.1.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_1_0.dtd">
 3<service-builder package-path="com.foo.bar.importer">
 4    <author>D.U.</author>
 5    <namespace>My_Project</namespace>
 6   
 7    <entity name="FooBarImporter" local-service="true" remote-service="true" human-name="Foo Bar Importer" />
 8    <entity name="XmlConverter" local-service="true" remote-service="false" human-name="XmlConverter" />
 9
10</service-builder>


When right-clicking on it chosing Liferay --> Build services in Eclipse the original service.xml is used from ServiceBuilder instead of service-importer.xml. Where do I go wrong?

My intention is to separate my services in distinct packages because I have more than one portlet in my project.
Furthermore, I want to use @Autowired for the XmlConverter entity to be used in a service. Is there something I have to consider?
David H Nebinger
RE: Multiple Service.xml in Single Plugin
January 6, 2014 7:09 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7512

Join Date: September 1, 2006

Recent Posts

service.xml is always used. you use the import tag in service.xml to include the service-importer.xml.

you break service.xml into smaller files for management purposes. at the end of the day you're still building a single service layer so it always starts with service.xml and imports the additional files.
D. U.
RE: Multiple Service.xml in Single Plugin
January 9, 2014 11:52 PM
Answer

D. U.

Rank: New Member

Posts: 14

Join Date: November 25, 2013

Recent Posts

Well, but it seems as if I have no chance to generate into different packages!? My intention was to let ServiceBuilder generate the classes into the distinct packages of the portlets. For instance, for portlet 1 into com.foo.bar.portlet1.* and for portlet 2 into com.foo.bar.portlet2.*.
David H Nebinger
RE: Multiple Service.xml in Single Plugin
January 10, 2014 6:02 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7512

Join Date: September 1, 2006

Recent Posts

That's right, you cannot generate into different packages. If you want different packages, you need separate plugins.