I need to upload and use a xquery module to marklogic 6 like check-docAvailable.xqy. I tried using the dictionary.xqy sample given by ML6, it works well. But when I try to import my own xquery I'm getting below error.
ERROR :
Exception in thread "main" com.marklogic.client.FailedRequestException: Local message: config/resources write failed: Internal Server Error. Server Message: XDMP-IMPORTMOD: Cannot import Main Module /marklogic.rest.resource/dictionary/lib/resource.xqy. See the MarkLogic server error log for further detail.
at com.marklogic.client.impl.JerseyServices.putPostValueImpl(JerseyServices.java:2033)
at com.marklogic.client.impl.JerseyServices.putValue(JerseyServices.java:1918)
at com.marklogic.client.impl.ResourceExtensionsImpl.writeServices(ResourceExtensionsImpl.java:114)
at com.mobius.ln.ml.util.MLUtil$DictionaryManager.installResourceExtensionShortcut(MLUtil.java:279)
at com.mobius.ln.ml.util.MLUtil.main(MLUtil.java:202)
My Xquery Module:
xquery version "1.0-ml";
declare namespace xs = "http://www.w3.org/2001/XMLSchema";
declare variable $uri as xs:string external;
let $uri := $uri
return (
fn:doc-available($uri)
)
Please suggest me how to achieve this. Is there any mistake in Xquery?
I would suggest a read through Extending the REST API. Your XQuery module doesn't look like a REST extension. When I attempt to install your module via curl
curl --anyauth --user admin:admin -i \
-H "Content-type: application/xquery" \
--data-binary #/c/temp/a.xqy \
-X PUT http://localhost:8000/LATEST/config/resources/a
I get the following error:
{"errorResponse":{"statusCode":400, "status":"Bad Request", "messageCode":"RESTAPI-INVALIDCONTENT", "message":"RESTAPI-INVALIDCONTENT: (err:FOER0000) Invalid content: invalid a extension: could not parse XQuery extension a; please see the server error log for detail XDMP-IMPORTMOD: Cannot import Main Module /marklogic.rest.resource/a/assets/resource.xqy; a either is not a valid module or does not provide extension functions (delete, get, put, post) in the http://marklogic.com/rest-api/resource/a namespace"}}
This part of the error message looks significant:
XDMP-IMPORTMOD: Cannot import Main Module /marklogic.rest.resource/dictionary/lib/resource.xqy.
That looks like you deployed dictionary.xqy as a service extension, using the REST API, then tried to import that module into another. dictionary.xqy is apparently a main module, but only library modules can be imported. See XQuery Library Modules and Main Modules in the Application Developer's Guide for more info about that.
I think what's happening is that you're deploying a main module as a service extension, but such extensions are required to be library modules. Take a look at Guidelines for Writing XQuery Resource Service Extensions in the REST Application Developer's Guide, taking note of the Resource Extension Interface section.
Solution: rewrite your extension as a library module, using the required interface.
Related
After starting a Python Table API Job that involves user defined functions (UDF) by submitting it to a local cluster, it crashes with a
py4j.protocol.Py4JJavaError caused by
java.util.ServiceConfigurationError: org.apache.beam.sdk.options.PipelineOptionsRegistrar: org.apache.beam.sdk.options.DefaultPipelineOptionsRegistrar not a subtype.
I am aware that this is a bug concerning the dependencies on the lib path/classloading. I have already tried to follow all instructions at the following link: https://ci.apache.org/projects/flink/flink-docs-release-1.10/monitoring/debugging_classloading.html
I have tried extensively different configurations with the classloader.parent-first-patterns-additional config option. Different entries with org.apache.beam.sdk.[...] have led to different, additional error messages.
The following dependencies, which refer to apache beam, are on the lib path:
beam-model-fn-execution-2.20.jar
beam-model-job-management-2.20.jar
beam-model-pipeline-2.20.jar
beam-runners-core-construction-java-2.20.jar
beam-runners-java-fn-execution-2.20.jar
beam-sdks-java-core-2.20.jar
beam-sdks-java-fn-execution-2.20.jar
beam-vendor-grpc-1_21_0-0.1.jar
beam-vendor-grpc-1_26_0.0.3.jar
beam-vendor-guava-26_0-jre-0.1.jar
beam-vendor-sdks-java-extensions-protobuf-2.20.jar
I can also rule out that it is due to my code, as I have tested the following sample code of the project website: https://flink.apache.org/2020/04/09/pyflink-udf-support-flink.html
from pyflink.datastream import StreamExecutionEnvironment
from pyflink.table import StreamTableEnvironment, DataTypes
from pyflink.table.descriptors import Schema, OldCsv, FileSystem
from pyflink.table.udf import udf
env = StreamExecutionEnvironment.get_execution_environment()
env.set_parallelism(1)
t_env = StreamTableEnvironment.create(env)
add = udf(lambda i, j: i + j, [DataTypes.BIGINT(), DataTypes.BIGINT()], DataTypes.BIGINT())
t_env.register_function("add", add)
t_env.connect(FileSystem().path('/tmp/input')) \
.with_format(OldCsv()
.field('a', DataTypes.BIGINT())
.field('b', DataTypes.BIGINT())) \
.with_schema(Schema()
.field('a', DataTypes.BIGINT())
.field('b', DataTypes.BIGINT())) \
.create_temporary_table('mySource')
t_env.connect(FileSystem().path('/tmp/output')) \
.with_format(OldCsv()
.field('sum', DataTypes.BIGINT())) \
.with_schema(Schema()
.field('sum', DataTypes.BIGINT())) \
.create_temporary_table('mySink')
t_env.from_path('mySource')\
.select("add(a, b)") \
.insert_into('mySink')
t_env.execute("tutorial_job")
When executing this code, the same error message appears.
Does anyone have a description of a configuration of a Flink cluster that can run Python Table API jobs with UDF? Many thanks for all tips in advance!
The problem is solved by the new version 1.10.1 of Apache Flink. Executing the sample script shown in the question is now possible via the binaries with the command run -py path/to/script without any problems.
As for the dependencies, they are already included in the already delivered flink_table_x.xx-1.10.1.jar. So no further dependencies need to be added to the lib-path, which was done in the question by the debugging/configuration attempt.
I use JNA to load a c++ library (.so) in a java project. I package my library inside the jar, and load it from the jar when instantiating the java class that uses it. I do all this like so:
mvn install compiles the c++ code and packages the outcome dynamic library inside the jar.
I call in a static context when instantiating the LibraryWrapperClass the following
System.load( temp.getAbsolutePath() );
where temp is a temporary file containing the library which was found in the jar. This code is based on the work found here adamheinrich
- I call Native.loadLibrary(LIBRARYPATH) to wrap the library into a java class.
private interface Wrapper extends Library {
Wrapper INSTANCE = Native.loadLibrary( C_LIBRARY_PATH, Wrapper.class );
Pointer Constructor();
...
}
I run tests and validate that the library was found and up and running.
I use a java web project that depends on this project. It uses tomcat and runs fine in local.
My issue is that when I deploy on the server, the LibraryWrapperClass cannot instantiate. Error on server is:
java.lang.NoClassDefFoundError: Could not initialize class pacakgeName.LibraryWrapperClass
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:375)
at org.hibernate.annotations.common.util.StandardClassLoaderDelegateImpl.classForName(StandardClassLoaderDelegateImpl.java:57)
at org.hibernate.boot.internal.MetadataBuilderImpl$MetadataBuildingOptionsImpl$4.classForName(MetadataBuilderImpl.java:758)
at org.hibernate.annotations.common.reflection.java.JavaReflectionManager.classForName(JavaReflectionManager.java:144)
at...
This error seems that the library is found, since there is not the UnsatisfiedLinkError exception thrown. But something else is failing. Do someone know what could happen? How could I debug?
I recall that everything works perfectly in local.
How could I debug?
1. with strace
strace will give you what files Tomcat is trying to open : strace -f -e trace=file -o log.txt bin/startup.sh
After this, look for packageName in log.txt, or other files not found with :
egrep ' open.*No such file' log.txt
2. with JConsole
Enable JMX, launch a JConsole, go to VM summary tab, and check/compare very carefully VM arguments/classpath/library path/boot class path
3. dependency listing with ldd
If a dependency issue is likely to be the problem, the ldd sharedLibraryFile.so command lists all the dependencies and allows to track which one might be missing.
I tried to create stubs for sample swagger specification as mentioned in Swagger CodeGen Documentation, but it does not work as intended to.
Exception in thread "main"
io.airlift.airline.ParseArgumentsUnexpectedException:
Found unexpected parameters: [-i, http://petstore.swagger.io/v2/swagger.json, -l, java] at io.airlift.airline.Cli.validate(Cli.java:148)
at io.airlift.airline.Cli.parse(Cli.java:116)
at io.airlift.airline.Cli.parse(Cli.java:97)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:36)
The solution of this issue on Swagger Documentation for creating server stub
documentation page.
Below is the command in case the link is obsolete or does not work :
java -jar swagger-codegen-cli-2.2.1.jar generate -i http://petstore.swagger.io/v2/swagger.json -l java
Trying to learn the Java interface to Xively. The following simple test fails with a 401 status code:
Feed myFeed = XivelyService.instance().feed().get(2126903832);
The exception statement is
com.xively.client.http.exception.HttpException: Http response status
indicates unsuccessful operation[Status code: 401.; Reason:
{"title":"Unauthorized","errors":"You do not have permission to access
this resource"} ]
The following console line leads me to believe that I'm not setting up the API key correctly:
2013-10-21 18:58:17,925 506 DEBUG [DefaultClientConnection.java:
276] (main:) >> X-ApiKey:
The Developer docs says replace <your api key> in config.properties with my API key. I did that, but it doesn't seem to make any difference.
I installed the library with Maven to my default Maven repo and point to it in Referenced Libraries. I am trying to build the whole thing in Eclipse.
My specific question is where is the config.properties the ApiConfig is reading?
I had this problem too. The problem was that I had double quotes in the config.properties file. The line should read:
api.key=yWYxyi3HpdqFCBtKHueTvOGoGROSAKxGRFAyQWk5d3JNdz0g
I am trying to generate the java help classes that I need for a client (a.k.a consumer) for a SSL-protected web service (on Microsoft Biztalk) that is external to our company network. We can access it only over a proxy and we cannot change anything about the Webservice itself.
This is my command provided to the wsimport tool:
wsimport -keep -httpproxy:theProxy.net:8080 -s c:\generatedWebService_wsImport\ -p the.java.package.I.want.to.call.it -Xauthfile c:\generatedWebService_wsImport\auth https://meldeservice-test.oekb.at/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL
and this is the content of my auth file:
https://user:pwd#meldeservice-test.oekb.at:8080/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL
And this is the error I get:
[ERROR] Server returned HTTP response code: 401 for URL: https:
//meldeservice-test.oekb.at/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL,
"https:
//meldeservice-test.oekb.at/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL"
needs authorization, please provide authorization file with read
access at C:\Documents and Settings\s6424.metro\auth or use
-Xauthfile to give the authorization file and on each line provide authorization information using this format :
http[s]://user:password#host:port//
Of course the proxy and credentials are different as in this post. The password contains a special character ! (exclamation mark).
Can someone help me with a working example under similar conditions. I had already searched a lot but couldn't find anything that would have helped me.
Is there somewhere a downloadable source code of the wsimport tool? This would be as the last resort to use.
Try to open https://user:pwd#meldeservice-test.oekb.at:8080/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL
with your browser and save to local folder. Later you can use a wsimport like this:
wsimport -keep -s c:\generatedWebService_wsImport\ -p the.java.package.I.want.to.call.it /home/user/Download/example?WSDL
Regards,
in your request, you used
https://meldeservice-test.oekb.at/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL
in your auth file, it is
meldeservice-test.oekb.at:8080/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL
try removing the port number, change it to
https://user:pwd#meldeservice-test.oekb.at/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL