GDL Utilities & F.A.Q. (2.0)

From Gcube Wiki
(Redirected from GDL Utilities (2.0))
Jump to: navigation, search

Utilities

The GCube Document Library offers utility classes to manage the collections and the views in the system.

The Collections class is an utility to manage the Content Manager collections. Currently the class provide a set of methods for collection finding.

The Views class is an utility for find the Views on the system.

The GCubeCollections class is an utility to manage the gcube collections, the ones hosted on Storage Management Service. The class provide methods for create and delete the GCUBE collections.

F.A.Q.

GDL dependencies

The GDL library requires, other than the obvious CML (aka CM stubs) and GML library, two more libraries:

  • mime-util 2.1.2: you can find it on Etics
  • slf4j: required by mime-util, you can find it on Etics.

Running the examples I get the exception GHNClientContext: gHN could not complete initialisation

Running the examples I get the following exception:

[main] FATAL contexts.GHNClientContext  - [0.0s] GHNClientContext: gHN could not complete initialisation
java.io.FileNotFoundException: null/config/GHNConfig.xml (No such file or directory)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(FileInputStream.java:106)
	at org.gcube.common.core.contexts.GHNContext.configureGHN(GHNContext.java:314)
	at org.gcube.common.core.contexts.GHNClientContext.configureGHN(GHNClientContext.java:35)
	at org.gcube.common.core.contexts.GHNClientContext.initialise(GHNClientContext.java:27)
	at org.gcube.common.core.contexts.GHNContext.<clinit>(GHNContext.java:252)
	at org.gcube.common.core.utils.calls.WSCall.getInitQuery(WSCall.java:55)
	at org.gcube.common.core.utils.calls.WSCall.getInitQuery(WSCall.java:25)
	at org.gcube.common.core.utils.calls.GCUBECall.<init>(GCUBECall.java:72)
	at org.gcube.common.core.utils.calls.GCUBECall.<init>(GCUBECall.java:84)
	at org.gcube.common.core.utils.calls.WSCall.<init>(WSCall.java:43)
	at org.gcube.contentmanagement.contentmanager.stubs.calls.BaseCall.<init>(BaseCall.java:25)
	at org.gcube.contentmanagement.contentmanager.stubs.calls.ManagerCall.<init>(ManagerCall.java:24)
	at org.gcube.contentmanagement.contentmanager.stubs.calls.ManagerCall.<init>(ManagerCall.java:35)
	at org.gcube.contentmanagement.contentmanager.stubs.calls.ReadManagerCall.<init>(ReadManagerCall.java:97)
	at org.gcube.contentmanagement.contentmanagerlibrary.CMReader.<init>(CMReader.java:62)
	at org.gcube.contentmanager.contentmanagerlibrary.GetDocumentsWithProjections.main(GetDocumentsWithProjections.java:34)
Exception in thread "main" java.lang.NullPointerException
	at org.gcube.common.core.utils.calls.WSCall.getInitQuery(WSCall.java:55)
	at org.gcube.common.core.utils.calls.WSCall.getInitQuery(WSCall.java:25)
	at org.gcube.common.core.utils.calls.GCUBECall.<init>(GCUBECall.java:72)
	at org.gcube.common.core.utils.calls.GCUBECall.<init>(GCUBECall.java:84)
	at org.gcube.common.core.utils.calls.WSCall.<init>(WSCall.java:43)
	at org.gcube.contentmanagement.contentmanager.stubs.calls.BaseCall.<init>(BaseCall.java:25)
	at org.gcube.contentmanagement.contentmanager.stubs.calls.ManagerCall.<init>(ManagerCall.java:24)
	at org.gcube.contentmanagement.contentmanager.stubs.calls.ManagerCall.<init>(ManagerCall.java:35)
	at org.gcube.contentmanagement.contentmanager.stubs.calls.ReadManagerCall.<init>(ReadManagerCall.java:97)
	at org.gcube.contentmanagement.contentmanagerlibrary.CMReader.<init>(CMReader.java:62)
	...

In this case you have to configure your eclipse running configuration properly (the variable GLOBUS_LOCATION is missing on environment) [1].

Running the examples I get the exception an AxisFault with nested exception org.globus.wsrf.ResourceException: resource identifier is missing

Running the examples I get the following exception:

[main] ERROR calls.ReadManagerCall  - ReadManagerCall: failed @ instance http://node23.d.d4science.research-infrastructures.eu:8080/wsrf/services/gcube/contentmanagement/contentmanager/readmanager
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
 faultSubcode: 
 faultString: 
 faultActor: 
 faultNode: 
 faultDetail: 
	{http://gcube-system.org/namespaces/common/core/faults}GCUBEFault:<ns2:Timestamp xmlns:ns2="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-BaseFaults-1.2-draft-01.xsd">2011-01-14T18:07:38.603Z</ns2:Timestamp><ns1:FaultMessage>; nested exception is: 
	org.globus.wsrf.ResourceException: ; nested exception is: 
	org.globus.wsrf.ResourceException: resource identifier is missing</ns1:FaultMessage><ns1:FaultType>RETRY_EQUIVALENT</ns1:FaultType>
	{http://xml.apache.org/axis/}exceptionName:org.gcube.common.core.faults.GCUBERetryEquivalentFault
	{http://xml.apache.org/axis/}hostname:node23.d.d4science.research-infrastructures.eu
	{}string:org.gcube.common.core.faults.GCUBERetryEquivalentException: ; nested exception is: 
	org.globus.wsrf.ResourceException: ; nested exception is: 
	org.globus.wsrf.ResourceException: resource identifier is missing
	at org.gcube.common.core.contexts.GCUBEServiceContext.getDefaultException(GCUBEServiceContext.java:288)
	at org.gcube.contentmanagement.contentmanager.porttypes.ReadManagerPT.get(ReadManagerPT.java:101)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:384)
	at org.globus.axis.providers.RPCProvider.invokeMethodSub(RPCProvider.java:107)
	at org.globus.axis.providers.RPCProvider.invokeMethod(RPCProvider.java:90)
	at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:281)
	at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:319)
	at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
	at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
	at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
	at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:450)
	at org.apache.axis.server.AxisServer.invoke(AxisServer.java:285)
	at org.globus.wsrf.container.ServiceThread.doPost(ServiceThread.java:664)
	at org.globus.wsrf.container.ServiceThread.process(ServiceThread.java:382)
	at org.globus.wsrf.container.ServiceThread.run(ServiceThread.java:291)
Caused by: org.globus.wsrf.ResourceException: ; nested exception is: 
	org.globus.wsrf.ResourceException: resource identifier is missing
	at org.gcube.common.core.state.GCUBEWSHome.find(GCUBEWSHome.java:263)
	at org.gcube.contentmanagement.contentmanager.porttypes.ReadManagerPT.getManager(ReadManagerPT.java:41)
	at org.gcube.contentmanagement.contentmanager.porttypes.ReadManagerPT.get(ReadManagerPT.java:95)
	... 17 more
Caused by: org.globus.wsrf.ResourceException: resource identifier is missing
	at org.gcube.common.core.state.GCUBEResourceHome.find(GCUBEResourceHome.java:506)
	at org.gcube.common.core.state.GCUBEWSHome.find(GCUBEWSHome.java:269)
	at org.gcube.common.core.state.GCUBEWSHome.find(GCUBEWSHome.java:55)
	at org.globus.wsrf.impl.ResourceContextImpl.getResource(ResourceContextImpl.java:164)
	at org.gcube.common.core.state.GCUBEWSHome.find(GCUBEWSHome.java:262)
	... 19 more
 
 
 
	at org.gcube.common.core.contexts.GCUBERemotePortTypeContext$GCUBEMethodInterceptor.intercept(GCUBERemotePortTypeContext.java:401)
	at org.gcube.contentmanagement.contentmanager.stubs.bindings.ReadManagerPortTypeSOAPBindingStub$$EnhancerByCGLIB$$3b40c9a0.get(<generated>)
	at org.gcube.contentmanagement.contentmanager.stubs.calls.ReadManagerCall$3.call(ReadManagerCall.java:247)
	at org.gcube.contentmanagement.contentmanager.stubs.calls.BaseCall$CallHandler.interact(BaseCall.java:72)
	at org.gcube.contentmanagement.contentmanager.stubs.calls.BaseCall$CallHandler._interact(BaseCall.java:86)
	at org.gcube.common.core.utils.handlers.GCUBEServiceHandler.tryInstances(GCUBEServiceHandler.java:195)
	at org.gcube.common.core.utils.handlers.GCUBEServiceHandler.run(GCUBEServiceHandler.java:111)
	at org.gcube.contentmanagement.contentmanager.stubs.calls.BaseCall$CallHandler.run(BaseCall.java:95)
	at org.gcube.contentmanagement.contentmanager.stubs.calls.ReadManagerCall.get(ReadManagerCall.java:252)
	at org.gcube.contentmanagement.gcubedocumentlibrary.CMReader.getDocuments(CMReader.java:98)
	...

In this case you have to configure your eclipse running configuration properly (the variable GLOBUS_LOCATION is missing on classpath) [2].

Trying to get the document content I get this exception: java.net.MalformedURLException: unknown protocol: sms

Exception in thread "main" java.net.MalformedURLException: unknown protocol: sms
	at java.net.URL.<init>(URL.java:574)
	at java.net.URL.<init>(URL.java:464)
	at java.net.URL.<init>(URL.java:413)
	at org.gcube.contentmanagement.contentmanagerlibrary.model.GCubeDocument.getContent(GCubeDocument.java:227)
        ...

The Storage Management Service introduces a new protocol, called sms, with an handler implementation.

To let know the JVM about the existence of a new protocol handler you can use one of this solutions:

  • Specify a new java property at JVM startup: -Djava.protocol.handler.pkgs=org.gcube.contentmanagement.storagelayer.storagemanagementservice.stubs.protocol
    • if you are developing a service and are you using the last distribution you don't have to change anything because the new GHN distribution already do it.
    • if you are developing a portlet or a portal library check if your portal instance have the option specified in the environment variable CATALINA_OPTS.
    • if you are running your client locally on Eclipse you can specify the options on run configuration, Arguments tab, VM arguments section.
  • Use this sentence in your client testing program:
System.setProperty("java.protocol.handler.pkgs", "org.gcube.contentmanagement.storagelayer.storagemanagementservice.stubs.protocol");

Eclipse don't find some functions in the examples

Eclipse don't find some functions in the example code (like is, matches, all, either, not, more, less, after, before).

Those are helper function from the CM and are defined on Constraints class. You can statically import it with this statement:

 import static org.gcube.contentmanagement.contentmanager.stubs.model.constraints.Constraints.*;

Trying to interact with the CM I get this exception: org.apache.commons.discovery.DiscoveryException: org.gcube.common.core.utils.handlers.GCUBEServiceHandler$NoQueryResultException

org.apache.commons.discovery.DiscoveryException: org.gcube.common.core.utils.handlers.GCUBEServiceHandler$NoQueryResultException
*****
  org.gcube.common.core.utils.handlers.GCUBEServiceHandler$NoQueryResultException
	at org.gcube.common.core.utils.handlers.GCUBEStatefulServiceHandler.findInstances(GCUBEStatefulServiceHandler.java:38)
	at org.gcube.common.core.utils.handlers.GCUBEServiceHandler.getInstances(GCUBEServiceHandler.java:140)
	at org.gcube.common.core.utils.handlers.GCUBEServiceHandler.run(GCUBEServiceHandler.java:110)
	at org.gcube.contentmanagement.contentmanager.stubs.calls.BaseCall$CallHandler.run(BaseCall.java:93)
	at org.gcube.contentmanagement.contentmanager.stubs.calls.WriteManagerCall.add(WriteManagerCall.java:98)
	at org.gcube.contentmanagement.contentmanager.stubs.calls.WriteManagerCall.add(WriteManagerCall.java:75)
	at org.gcube.contentmanagement.gcubedocumentlibrary.CMWriter.add(CMWriter.java:84)
	at org.gcube.personalization.userprofileaccess.impl.CMSUtils.createDocument(CMSUtils.java:67)
	at org.gcube.personalization.userprofileaccess.impl.UserProfileAccessFactoryService.createResource(UserProfileAccessFactoryService.java:331)

The exception means that there is not plugin instantiated for the specified collection. Check if the collection id is correct. Otherwise contact the support team.

Using the GDL I got this exception: java.lang.IllegalArgumentException: prefix xsd is not bound to a namespace

java.lang.IllegalArgumentException: prefix xsd is not bound to a namespace
	at com.sun.xml.internal.bind.DatatypeConverterImpl._parseQName(DatatypeConverterImpl.java:324)
	at com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiTypeLoader.parseXsiType(XsiTypeLoader.java:53)
	at com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiTypeLoader.startElement(XsiTypeLoader.java:31)
	at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:402)
	at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:380)
	at com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:101)
	at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:195)
	at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:168)
	at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137)
	at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:194)
	at org.gcube.contentmanagement.gcubedocumentlibrary.views.Views.unmarshalView(Views.java:244)
	at org.gcube.contentmanagement.gcubedocumentlibrary.views.Views.findLike(Views.java:153)
	at org.gcube.contentmanagement.gcubedocumentlibrary.views.MetadataView.findSimilar(MetadataView.java:83)
	at org.gcube.portlets.admin.fulltextindexportlet.gwt.server.ManagementServiceImpl.getCollections(ManagementServiceImpl.java:200)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562)
	at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:188)
	at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:224)
	at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
	at java.lang.Thread.run(Thread.java:619)

Check your Java version. You need to use a version equals or upper than 1.6.0_22.