I have installed fuseki version 1.0.2 and I can successfully run it using -->
./fuseki-server --update --loc=/home/mytdbs/tdb /ds
and query it on http://localhost:3030/sparql.tpl. I have a tdb and I want to update it using java. To do so I am trying to get the model using:
public static void main(String args[]){
DatasetAccessor dataAccessor = datasetAccessorFactory.createHTTP("http://localhost:3030/ds/data");
Model model = dataAccessor.getModel();
}
However when I am running this command I will get the following exception:
java.lang.NoSuchFieldError: serviceContext at
org.apache.jena.atlas.web.auth.ServiceAuthenticator.getServiceContextMap(ServiceAuthenticator.java:95)
at
org.apache.jena.atlas.web.auth.ServiceAuthenticator.getCredentials(ServiceAuthenticator.java:101)
at
org.apache.jena.atlas.web.auth.ServiceAuthenticator.getCredentials(ServiceAuthenticator.java:38)
at
org.apache.jena.atlas.web.auth.AbstractScopedAuthenticator.findCredentials(AbstractScopedAuthenticator.java:107)
at
org.apache.jena.atlas.web.auth.AbstractScopedAuthenticator.getUserName(AbstractScopedAuthenticator.java:50)
at
org.apache.jena.atlas.web.auth.AbstractScopedAuthenticator.hasUserName(AbstractScopedAuthenticator.java:60)
at
org.apache.jena.atlas.web.auth.AbstractCredentialsAuthenticator.apply(AbstractCredentialsAuthenticator.java:41)
at
org.apache.jena.riot.web.HttpOp.applyAuthentication(HttpOp.java:1226)
at org.apache.jena.riot.web.HttpOp.exec(HttpOp.java:1108) at
org.apache.jena.riot.web.HttpOp.execHttpGet(HttpOp.java:384) at
org.apache.jena.riot.web.HttpOp.execHttpGet(HttpOp.java:353) at
org.apache.jena.web.DatasetGraphAccessorHTTP.doGet(DatasetGraphAccessorHTTP.java:134)
at
org.apache.jena.web.DatasetGraphAccessorHTTP.httpGet(DatasetGraphAccessorHTTP.java:123)
at
org.apache.jena.web.DatasetAdapter.getModel(DatasetAdapter.java:39)
I am using java 1.6 and Jena 2.11.2. I am very new to jena so I am not sure what other information might be useful. Any help/hint is much appreciated.
Related
As a user, writing a processor as a cloud function,
scdf 1.7.3, spring boot 1.5.9, spring-cloud-function-dependencies 1.0.2,
public class MyFunctionBootApp {
public static void main(String[] args) {
SpringApplication.run(MyFunctionBootApp.class,
"--spring.cloud.stream.function.definition=toUpperCase");
}
#Bean
public Function<String, String> toUpperCase() {
return s -> {
log.info("received:=" + s);
return ( (s+"jsa").toUpperCase());
};
}
}
i've create a simple stream => time | function-runner | log
function-runner-0.0.6.jar at nexus is ok
docker created ok,
Container entrypoint set to [java, -cp, /app/resources:/app/classes:/app/libs/*, function.runner.MyFunctionBootApp]
No time message from time pod arrived to function-runner processor executing toUpperCase function
No logs
I am checking deploying using , app.function-runner.spring.cloud.stream.function.definition=toUpperCase, #FunctionalScan
any clues?
We discussed function-runner being deprecated in favor of native support of Spring Cloud Function in Spring Cloud Stream. See: scdf-1-7-3-docker-k8s-function-runner-not-start. Please don't duplicate post it.
Also, you're on a very old Spring Boot version (v1.5.9 - at least 1.5yrs old). More importantly, Spring Boot 1.x is in maintenance-only mode, and it will be EOL by August 2019. See: spring-boot-1-x-eol-aug-1st-2019. It'd be good that you upgrade to 2.1.x latest.
I'm trying to run a "Hello, world" Spring Cloud Data Flow stream based on the very simple example explained at http://cloud.spring.io/spring-cloud-dataflow/. I'm able to create a simple source and sink and run it on my local SCDF server using Kafka, so until here everything is correct and messages are produced and consumed in the topic specified by SCDF.
Now, I'm trying to deploy it in my private cloud based on the instructions listed at http://docs.spring.io/spring-cloud-dataflow-server-kubernetes/docs/current-SNAPSHOT/reference/htmlsingle/#_getting_started. Using this deployment I'm able to deploy a simple "time | log" out-of-the-box stream with no problems, but my example fails since the producer is not writing in the topic specified when the pod is created (for instance, spring.cloud.stream.bindings.output.destination=ntest33.nites-source9) but in the topic "output". I have a similar problem with the sink component, which creates and expect messages in the topic "input".
I created the stream definition using the dashboard:
nsource1 | log
And container args for the source are:
--spring.cloud.stream.bindings.output.producer.requiredGroups=ntest34
--spring.cloud.stream.bindings.output.destination=ntest34.nsource1
Code snippet for source component is
package xxxx;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.context.annotation.Bean;
import org.springframework.integration.annotation.InboundChannelAdapter;
import org.springframework.integration.core.MessageSource;
import org.springframework.messaging.support.GenericMessage;
#SpringBootApplication
#EnableBinding(Source.class)
public class HelloNitesApplication
{
public static void main(String[] args)
{
SpringApplication.run(HelloNitesApplication.class, args);
}
#Bean
#InboundChannelAdapter(value = Source.OUTPUT)
public MessageSource<String> timerMessageSource()
{
return () -> new GenericMessage<>("Hello " + new SimpleDateFormat().format(new Date()));
}
And in the logs I can see clearly
2017-04-07T09:44:34.596842965Z 2017-04-07 09:44:34,593 INFO main o.s.i.c.DirectChannel:81 - Channel 'application.output' has 1 subscriber(s).
Question is, how to override properly the topic where messages must be produced/consumed or what attribute and values to use to make this work on k8s?
UPDATE: I have the similar problem using RabbitMQ
2017-04-07T12:56:40.435405177Z 2017-04-07 12:56:40.435 INFO 7 --- [ main] o.s.integration.channel.DirectChannel : Channel 'application.output' has 1 subscriber(s).
The problem was with my docker image. I still don't know the details but using the Dockerfile indicated at https://spring.io/guides/gs/spring-boot-docker/ instantiated 2 processes in the docker container, one with the parameters, and other without, which was the one with uptime and therefore being used.
The solution was to replace
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
With
ENTRYPOINT [ "java", "-jar", "/app.jar" ]
And it started working. There must be a good reason why the example indicated the first entrypoint and why 2 processes were created, but the reason is still beyond my understanding.
Can you provide more details on how you set that configuration property? That feature is pretty basic, so this should work. If you are using a stream definition to set it, please update your question with the stream definition.
The channel name remains 'output' because that's what the application uses internally.
It's the first time for me using twitter4j i got project from github trying to run it to see the result of how using twitter4j and when i run the Crawler class i got this
0 [Twitter Stream consumer-1[initializing]] INFO twitter4j.TwitterStreamImpl - Establishing
connection. 5617 [Twitter Stream consumer-1[Establishing connection]] INFO
twitter4j.TwitterStreamImpl - 401:Authentication credentials (https://dev.twitter.com/pages
/auth) were missing or incorrect. Ensure that you have set valid consumer key/secret, access
token/secret, and the system clock is in sync.
i guess from Ensure that you have set valid consumer key/secret that i should change the proprieties of twitter4j.proprieties !!? am i right or false ? and how can i change the proprieties of it ?
Can someone help ?
I got the similar error with using twitter4j 3.0.x version. I solved it by updating twitter4j to the 4.0.0 version
Try the following options given in this link to set the Keys:
via twitter4j.properties: Save a standard properties file named "twitter4j.properties". Place it to either the current directory, root of the classpath directory.
debug=true
oauth.consumerKey=*********************
oauth.consumerSecret=******************************************
oauth.accessToken=**************************************************
oauth.accessTokenSecret=******************************************
via ConfigurationBuilder: You can use ConfigurationBuilder class to configure Twitter4J programatically as follows:
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey("*********************")
.setOAuthConsumerSecret("******************************************")
.setOAuthAccessToken("**************************************************")
.setOAuthAccessTokenSecret("******************************************");
TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter =
tf.getInstance();
via System Properties: You can configure Twitter4J via System properties. Note that you need "twitter4j." prefix.
$ java -Dtwitter4j.debug=true
-Dtwitter4j.oauth.consumerKey=*********************
-Dtwitter4j.oauth.consumerSecret=******************************************
-Dtwitter4j.oauth.accessToken=**************************************************
-Dtwitter4j.oauth.accessTokenSecret=******************************************
-cp twitter4j-core-4.0.2.jar:yourApp.jar yourpackage.Main
via environment variables: Note that you need "twitter4j." prefix.
$ export twitter4j.debug=true $ export
twitter4j.oauth.consumerKey=********************* $ export
twitter4j.oauth.consumerSecret=******************************************
$ export
twitter4j.oauth.accessToken=**************************************************
$ export
twitter4j.oauth.accessTokenSecret=******************************************
$ java -cp twitter4j-core-4.0.2.jar:yourApp.jar yourpackage.Main
I am a complete newbie to Neo4j. I am trying to write a simple Neo4j server that would listen on a port of my choice. The code I am using is exactly the same as in the file server.java at the following tutorial
http://hmkcode.com/first-time-neo4j/
The code compiles fine but when I try to run it I get an error (pasted below)
Any help would be appreciated. I am using jre7 and jdk1.8.0_11
For your convenience I have also cut and pasted the code below (exactly the same as in the above link)
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.graphdb.factory.GraphDatabaseSetting;
import org.neo4j.kernel.GraphDatabaseAPI;
import org.neo4j.server.WrappingNeoServerBootstrapper;
import org.neo4j.server.configuration.Configurator;
import org.neo4j.server.configuration.ServerConfigurator;
import org.neo4j.shell.ShellSettings;
public class neoserver {
public static void main(String args[]){
{
GraphDatabaseAPI graphdb = (GraphDatabaseAPI) new GraphDatabaseFactory()
.newEmbeddedDatabaseBuilder( "db/graphDB" )
.setConfig( ShellSettings.remote_shell_enabled, GraphDatabaseSetting.TRUE )
.newGraphDatabase();
ServerConfigurator config;
config = new ServerConfigurator( graphdb );
// let the server endpoint be on a custom port
config.configuration().setProperty(Configurator.WEBSERVER_PORT_PROPERTY_KEY, 7575 );
WrappingNeoServerBootstrapper srv;
srv = new WrappingNeoServerBootstrapper( graphdb, config );
srv.start();
}
}
}
ERROR that I get
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/text/StrLookup
at org.neo4j.server.configuration.ServerConfigurator.<init>(ServerConfigurator.java:52)
at jungpagerankserver.neoserver.main(neoserver.java:80)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.text.StrLookup
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
The tutorial you're referencing seems to use Eclipse and not a dedicated build system. Every serious project should not rely on and IDE for building, instead a tool like Maven or Gradle are a good choice.
Make sure you have all transitive dependencies of neo4j-server on your classpath. When using maven, add to your pom.xml with the dependencies section:
<dependency>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
<version>2.1.3</version>
</dependency>
In case of gradle, use inside dependencies:
compile 'org.neo4j.app:neo4j-server:2.1.3'
This Code is working fine with simple application so the drivers are fine.
so why the connection object is not able to initialise with drivers.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import com.opensymphony.xwork2.ActionSupport;
public class Insert extends ActionSupport {
public String execute() throws Exception, SQLException {
String sql = "";
String url = "jdbc:mysql://localhost:3306/test";
//String dbName = "test";
String driverName = "org.gjt.mm.mysql.Driver";
String userName = "root";
String password = "root";
Connection con=null;
Statement stmt=null;
try {
Class.forName(driverName).newInstance();
con = DriverManager.getConnection(url, userName, password);
stmt = con.createStatement();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
What does the exception say? A NullPointerException on createStatement?
In any case, has the class been loaded; is the class on the classpath (i.e. the MySQL jar on the classpath?)
Check the object returned from Class.forName() to check whether the class has been found.
After your comment it is clear that you have a classpath problem. The mysql jar is not on the classpath. I assume you are talking about a web app deliverable (war file), as changing the build path in eclipse is trivial.
In a web application deployed in, for example, tomcat you can look into <webapp-name>/WEB-INF/lib. The file WEB-INF/lib/mysql-connector-java-5.0.5.jar, or something similar, should be there.
If you have a war file (not yet deployed) you can extract it using the command line tool "jar", or get a file listing from it. If you do (on a command line) jar tf | grep mysql the jarfile should be visible. If you use windows; WinRAR (and probably WinZip) can also open warfiles. In WEB-INF/lib a MySQL jar should be visible.
If you use maven to build your web app; don't forget to add a dependency to the mysql jar. If you use ant to build; don't forget to copy the mysql jar file into WEB-INF/lib before creating the war file.
Please note that currently the recommended driver to ask for is 'com.mysql.driver.Driver', and not 'org.gjt.mm.mysql.Driver'. You can try to load that Driver class in stead of the older driver; further; check whether this driver is actually in the mysql jar (jar tf mysq.jar | grep Driver or so). If the Driver is in the mysql jar and the mysql jar is on the classpath of the webapp (in WEB-INF/lib) and there is only one mysql jar there (version conflicts are no fun), and it still does not work I really don't know what could be wrong. I think I'd download the driver jar again from MySQL and try again.