How to fix custom function class not registered in apache jena fuseki error? - jena

I need a custom filter function in apache-jena-fuseki. I tried adding custom function class name to config.ttl. I added function class files to class path. But it's always throwing error that function is not registered.
Can anyone please share a detailed approach I can try or some documentation? Desperately need it.
Added following line To Configuration File
[] ja:loadClass "org.apache.jena.sparql.function.library.function" .
Class file is in folder /home/user/custom_functions/
Class file package name = org.apache.jena.sparql.function.library.
Java command to launch fuseki server is
java -cp /home/user/custom_functions/function.class:/home/user/apache-jena-4.5.0/lib-src/*:/home/user/apache-jena-4.5.0/lib/* -jar fuseki-server.jar
Function takes one argument.
When I run query, it gives me error log that function has not registered FunctionFactory.
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX java: <http://www.w3.org/2007/uwa/context/java.owl#>
PREFIX f: <java:org.apache.jena.sparql.function.library.>
SELECT ?s ?o {
?s rdfs:label ?o .
FILTER (f:function(?o) ) .
}

Related

ModuleNameMismatch mystery

Using rascal from the command line, when I type:
import demo::hello
I receive a ModuleNameMismatch error, although the current directory (the one in which I type java -jar rascal-shell-stable.jar) contains a subdirectory named demo containing a file hello.rsc :
module hello
import IO;
void hello(){
println("Hello word");
}
It however works when I type
import hello
and the hello.rsc is in the current directory.
For your info: I am on Windows 10.
The module name must be the full relative path to the module.rsc file.
In this case, the hello.rsc file should be :
module demo::hello
import IO;
void hello(){
println("Hello word");
}
That the reason why it does work when the hello.rsc in the current directory.

Perform an INSERT in Jena Fuseki with SPARQL gem (Ruby)

So I'm developing an API in Rails and using Jena Fuseki to store triples, and right now I'm trying to perform an INSERT in a named graph. The query is correct, since I ran it on Jena and worked perfectly. However, no matter what I do when using the Rails CLI, I keep getting the same error message:
SPARQL::Client::MalformedQuery: Error 400: SPARQL Update: No 'update=' parameter
I've created a method that takes the parameters of the object I'm trying to insert, and specified the graph where I want them.
def self.insert_taxon(uri, label, comment, subclass_of)
endpoint = SPARQL::Client.new("http://app.talkiu.com:8030/talkiutest/update")
query =
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix gpc:<http://www.ebusiness-unibw.org/ontologies/pcs2owl/gpc/>
prefix tk: <www.web-experto.com.ar/ontology#>
INSERT DATA {
GRAPH <http://app.talkiu.com:8030/talkiutest/data/talkiu> {
<#{uri}> a owl:Class.
<#{uri}> rdfs:label '#{label}'#es .
<#{uri}> rdfs:comment '#{comment}' .
<#{uri}> rdfs:subClassOf <#{subclass_of}> .
}
}"
resultset = endpoint.query(query)
end
As you can see, I'm using the UPDATE endpoint. Any ideas? Thanks in advance
Well... Instead of endpoint.query, I tried
resultset = endpoint.update(query)
and worked. Method returned
<SPARQL::Client:0x2b0158a050e4(http://app.talkiu.com:8030/talkiutest/update)>
and the data is showing up in my database and graph. Hope this helps anyone with the same problem.

excel xlwings_udfs module is empty

Using xlwings 0.7.1 UDF on Windows in 64-bit virtual env python 2.7.6.
I see now that instead of requiring full path to module, it takes module names. However it fails silently to import any UDFs when the module name has package name prefixed. Eg:
PYTHONPATH = ThisWorkbook.Path & ";C:\pathTo\Pydev\myproj\src"
UDF_MODULES = "pkg.myudfs"
If I move the package name 'pkg' from UDF_MODULES to PYTHONPATH, then it fails at imports inside myudfs.py (like 'import pkg.module2').
After hit & trial, I fixed it by adding multiple source folders:
PYTHONPATH = ThisWorkbook.Path & ";C:\pathTo\Pydev\myproj\src\pkg;C:\pathTo\Pydev\myproj\src"
Am I expected to do this? Can't I just point UDF_MODULES to base src folder and provide qualified module name like 'pgk.myudfs'?
You're actually doing it right for right now (v0.7.1). I have, however, opened an issue on GitHub so we might make this easier in a future release.

Failed to open - Zend Framework

Warning: require_once(Zend/Application.php) [function.require-once]:
failed to open stream: No such file or directory in
D:\xampp\htdocs\obsessa\public\index.php on line 17
Fatal error: require_once() [function.require]: Failed opening
required 'Zend/Application.php'
(include_path='D:\xampp\htdocs\obsessa\library;.;D:/xampp/php/PEAR;D:/xampp/php/ZendFramework')
in D:\xampp\htdocs\obsessa\public\index.php on line 17
Hi Anyone help me on this ?
D:/xampp/php/PEAR;D:/xampp/php/ZendFramework
Should probably be:
D:/xampp/php/PEAR;D:/xampp/php/ZendFramework/library
The immediate problem is that your php include_path configuration is wrong. The reason is the way PSR-0 autoloading works. Your include path has two paths. If you want to load Zend\Application, then you need an include path that has a subdirectory called 'Zend'. In your case, D:/xampp/php/ZendFramework does not have that, you need D:/xampp/php/ZendFramework/library (which has a subdirectory named Zend, which has a file named Application.php)
But really, if you're doing ZF2, grab the skeleton application and use composer, just like the docs say, especially if you're new. composer is fantastic, and it's the preferred way to go. With composer, each application you write has its own installation of zf2. There are very few situations where you want your apps to rely on some globally-installed framework, which is the setup you're trying to do.
Please follow this step :
Please donwload the zend libray from zend official site
http://framework.zend.com/
Then paste donwloaded library in zend libray folder
Index.php file settings
//Ensure library/ is on include_path
set_include_path(
implode(PATH_SEPARATOR,
array(realpath(APPLICATION_PATH . '/../library'),
get_include_path(),)));
/** Zend_Application */
require_once 'Zend/Application.php';
please set index.php file as:
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(FILE) . '/../application'));
defined('LIBRARY_PATH')
|| define('LIBRARY_PATH', realpath(dirname(FILE) . '/../library'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
define('PUBLIC_PATH','http://'.$_SERVER['HTTP_HOST'].'/demo/public');
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
set_include_path(implode(PATH_SEPARATOR, array(
realpath(DOCTRINE_PATH),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();

escapeshellarg() has been disabled for security reasons

When I want to upload anything in any form I see the Warning: escapeshellarg() has been disabled for security reasons message on my site. What can I do to fix this?
My framework is codeigniter final version.
Here is the full warning:
A PHP Error was encountered
Severity: Warning
Message: escapeshellarg() has been disabled for security reasons
Filename: libraries/Upload.php
The # operator will silence any PHP errors the function could raise. You should never use it!
Solutions:
Remove the escapeshellarg string from the disable_functions in php.ini file
Ask your host provider to remove Remove the escapeshellarg string from the disable_functions in php.ini file if you don't have an access to the php.ini file
make your own escapeshellarg. The function only escapes any single quotes in the given string and then adds single quotes around it.
function my_escapeshellarg($input)
{
$input = str_replace('\'', '\\\'', $input);
return '\''.$input.'\'';
}
and do something like this:
// $cmd = 'file --brief --mime ' . escapeshellarg($file['tmp_name']) . ' 2>&1';
$cmd = 'file --brief --mime ' . my_escapeshellarg($file['tmp_name']) . ' 2>&1';
But what is best is to extend the Upload.php library and override the _file_mime_type function instead of changing on the core of CodeIgniter so that you will not lose it if you ever want to update CodeIgniter.
Helpful links: https://www.codeigniter.com/user_guide/general/core_classes.html
Try
$cmd = 'file --brief --mime ' . #escapeshellarg($file['tmp_name']) . ' 2>&1';
Open Upload.php file from system/libraries folder and put # in front of escapeshellarg($file['tmp_name']) at line 1066
and second thing upload this file under application/libraries folder that will be better, other wise no problem, you can replace system's Upload.php file.
Remove the escapeshellarg string from the disable_functions at php.ini* file
Ask your hosting provider to remove the string above if you don't have an access to the php.ini* file
Change hosting provider which allows the running of the escapeshellarg function.
from this website: http://www.2by2host.com/articles/php-errors-faq/disabled_escapeshellarg/
Another simple way to solve this issue is just move your application from development to production:
Open index.php in your application root and change
define('ENVIRONMENT', 'development');
to
define('ENVIRONMENT', 'production');

Resources