Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Tim Cardwell
Using service builder to return a list
July 26, 2012 12:18 PM
Answer

Tim Cardwell

Rank: Junior Member

Posts: 27

Join Date: July 19, 2012

Recent Posts

I am creating a service that when called upon, will return a list of items that is refreshed with every call to the service.

Basically, I want to get a list of every AssetEntry in a portal, but the only users accessing this service are ones that can only 'get' AssetEntrys in the portal. (No adding or removing)

To give you a better understanding of what I'm trying to do, here is my XXXLocalServiceImpl class:

 1
 2public class AssetLocalServiceImpl extends AssetLocalServiceBaseImpl{
 3    public Asset addAsset(String classId) throws SystemException{
 4        long assetId = CounterLocalServiceUtil.increment(Asset.class.getName());
 5        Asset asset = assetPersistence.create(assetId);
 6        asset.setClassId(classId);
 7        assetPersistence.update(asset, true);
 8        return asset;
 9    }
10   
11
12    public List<Asset> getAssets() throws SystemException, PortalException{
13        assetPersistence.removeAll(); //Since the list needs to be updated with every call, we empty the current database.
14       
15        }
16
17                                       ................
18
19
20                                       In here is some custom code that I made that will return a list of every AssetEntry in the portal.
21                                       Lets call this list AssetEntryCollection
22
23                                       ................
24        Iterator<AssetEntry> entryItr = AssetEntryCollection.iterator();
25        AssetEntry temp;
26        while(entryItr.hasNext()){
27            temp = entryItr.next();
28            addAsset(temp.getClassName()); //Add every AssetEntry to our new database
29        }
30        return assetPersistence.findAll(); //Now that the database has been updated, return the whole thing.
31    }
32
33}



My first question is if this is legal. Most services I've seen don't work like this at all.

My second question has to do with an error I've been getting all day now. This service builds without errors, but when I try to build the wsdd, I get the following:

 1
 2Buildfile: C:\Program Files (x86)\liferay-portal-6.1.0-ce-ga1\portlets\AssetPublisherTest-portlet\build.xml
 3compile:
 4merge:
 5     [copy] Copying 5 files to C:\Program Files (x86)\liferay-portal-6.1.0-ce-ga1\portlets\AssetPublisherTest-portlet\docroot\WEB-INF\lib
 6compile-java:
 7     [copy] Copying 2 files to C:\Program Files (x86)\liferay-portal-6.1.0-ce-ga1\portlets\AssetPublisherTest-portlet\docroot\WEB-INF\classes
 8merge:
 9build-wsdd:
10     [java] Loading jar:file:/C:/Program%20Files%20(x86)/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/system.properties
11     [java] Jul 26, 2012 6:58:50 PM com.liferay.portal.kernel.log.Jdk14LogImpl info
12     [java] INFO: Global lib directory /C:/Program Files (x86)/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/lib/ext/
13     [java] Jul 26, 2012 6:58:50 PM com.liferay.portal.kernel.log.Jdk14LogImpl info
14     [java] INFO: Portal lib directory /C:/Program Files (x86)/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/
15     [java] 18:58:50,235 INFO  [EasyConf:122] Refreshed the configuration of all components
16     [java] 18:58:50,516 INFO  [ConfigurationLoader:56] Properties for jar:file:/C:/Program%20Files%20(x86)/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal loaded from [jar:file:/C:/Program%20Files%20(x86)/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/com/liferay/portal/tools/dependencies/portal-tools.properties, jar:file:/C:/Program%20Files%20(x86)/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal.properties]
17     [java] Loading jar:file:/C:/Program%20Files%20(x86)/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal.properties
18     [java] Loading jar:file:/C:/Program%20Files%20(x86)/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/com/liferay/portal/tools/dependencies/portal-tools.properties
19     [java] SLF4J: Class path contains multiple SLF4J bindings.
20     [java] SLF4J: Found binding in [jar:file:/C:/Program%20Files%20(x86)/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/util-java.jar!/org/slf4j/impl/StaticLoggerBinder.class]
21     [java] SLF4J: Found binding in [jar:file:/C:/Program%20Files%20(x86)/liferay-portal-6.1.0-ce-ga1/portlets/AssetPublisherTest-portlet/docroot/WEB-INF/lib/util-java.jar!/org/slf4j/impl/StaticLoggerBinder.class]
22     [java] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
23     [java]   Java2WSDL tec.echelonllc.liferay.test.service.http.AssetServiceSoap
24     [java] 18:58:53,583 WARN  [Types:1704] The class tec.echelonllc.liferay.test.model.Asset does not contain a default constructor, which is a requirement for a bean class.  The class cannot be converted into an xml schema type.  An xml schema anyType will be used to define this class in the wsdl file.
25     [java]   WSDL2Java C:\Program Files (x86)\liferay-portal-6.1.0-ce-ga1\portlets\AssetPublisherTest-portlet\20120726185852961\service.wsdl
26     [java]   Running Wsdl2javaAntTask with parameters:
27     [java]       verbose:false
28     [java]       debug:false
29     [java]       quiet:false
30     [java]       server-side:true
31     [java]       skeletonDeploy:false
32     [java]       helperGen:false
33     [java]       factory:null
34     [java]       nsIncludes:[]
35     [java]       nsExcludes:[]
36     [java]       factoryProps:[]
37     [java]       testCase:false
38     [java]       noImports:false
39     [java]       NStoPkg:{}
40     [java]       output:C:\Program Files (x86)\liferay-portal-6.1.0-ce-ga1\portlets\AssetPublisherTest-portlet\20120726185852961
41     [java] java.io.IOException: Type {http://model.test.liferay.echelonllc.tec}Asset is referenced but not defined.
42     [java]     at org.apache.axis.wsdl.symbolTable.SymbolTable.checkForUndefined(SymbolTable.java:665)
43     [java]       protocolHandlerPkgs:
44     [java]       deployScope:
45     [java]       URL:C:\Program Files (x86)\liferay-portal-6.1.0-ce-ga1\portlets\AssetPublisherTest-portlet\20120726185852961\service.wsdl
46     [java]       all:false
47     [java]       typeMappingVersion:1.2
48     [java]       timeout:45000
49     [java]       failOnNetworkErrors:false
50     [java]       printStackTraceOnFailure:true
51     [java]     at org.apache.axis.wsdl.symbolTable.SymbolTable.add(SymbolTable.java:545)
52     [java]       namespaceMappingFile:null
53     [java]       username:null
54     [java]     at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:518)
55     [java]       :passwordnull
56     [java]       :noWrappedfalse
57     [java]       :allowInvalidURLfalse
58     [java]       :implementationClassNamenull
59     [java]     at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:495)
60     [java]     at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:361)
61     [java]     at java.lang.Thread.run(Thread.java:619)
62     [java] Exception in thread "main" WSDL processing error for C:\Program Files (x86)\liferay-portal-6.1.0-ce-ga1\portlets\AssetPublisherTest-portlet\20120726185852961\service.wsdl :
63     [java]  Type {http://model.test.liferay.echelonllc.tec}Asset is referenced but not defined.
64     [java]     at org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask.execute(Wsdl2javaAntTask.java:304)
65     [java]     at com.liferay.util.ant.Java2WsddTask.generateWsdd(Java2WsddTask.java:108)
66     [java]     at com.liferay.portal.tools.WSDDBuilder._createServiceWSDD(WSDDBuilder.java:130)
67     [java]     at com.liferay.portal.tools.WSDDBuilder.build(WSDDBuilder.java:93)
68     [java]     at com.liferay.portal.tools.WSDDBuilder.main(WSDDBuilder.java:49)
69     [java] Caused by: java.io.IOException: Type {http://model.test.liferay.echelonllc.tec}Asset is referenced but not defined.
70     [java]     at org.apache.axis.wsdl.symbolTable.SymbolTable.checkForUndefined(SymbolTable.java:665)
71     [java]     at org.apache.axis.wsdl.symbolTable.SymbolTable.add(SymbolTable.java:545)
72     [java]     at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:518)
73     [java]     at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:495)
74     [java]     at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:361)
75     [java]     at java.lang.Thread.run(Thread.java:619)
76     [java]       :classpathnull
77     [java]       http.proxyHost=null
78     [java]       http.proxyPort=null
79     [java]       http.proxyUser=null
80     [java]       http.proxyPassword=null
81     [java]       socks.proxyHost=null
82     [java]       socks.proxyPort=null
83     [java] Java Result: 1
84BUILD SUCCESSFUL
85Total time: 6 seconds


I've read this error all over the internet. I've read that it was a liferay bug that is now fixed, I've read that people have fixed it tampering with the XXXServiceSoap class (This actually worked for me, but the WSDL is deleted after the end of the build), and I've read that it sucks.

Let me know what you guys think,
-Tim
Tim Cardwell
RE: Using service builder to return a list
July 27, 2012 8:34 AM
Answer

Tim Cardwell

Rank: Junior Member

Posts: 27

Join Date: July 19, 2012

Recent Posts

Turns out everything worked fine, my service is up and running.

I ended up ignoring the build-wsdd error I was getting (I tried before but realized I was using the wrong URI to hit my service) and everything worked as expected.

Yet if anyone comes across a solution to that error let me know.

-Tim