Error reading file using JENA api - java

For the following code:
Model m2=ModelFactory.createDefaultModel();
m2.read("Untitled.xml");
I get the error: Exception in thread "main" com.hp.hpl.jena.shared.JenaException: java.net.MalformedURLException: no protocol: Untitled.xml
Could anyone please help me out?

it expect an url, try m2.read(new File("Untitled.xml").toURL().toString());

Related

Gatling: while script execution getting error, "could not prepare: Boon failed to parse into a valid AST: -1"

please consider the scenario...
I am creating script of CreateNewFolder of my web application.
.exec(http("request_")
.post("/url/home")
.formParam("action_id", "9")
.formParam("projectId", "${projectId}")
.formParam("isForEdit", "false")
.check(jsonPath("$.distData.roleList[25].roleId").saveAs("roleId"))
.check(jsonPath("$.distData.userList[10].userID").saveAs("userID")))
.exec(http("Create_New_Folder")
.post("/url/home")
.formParam("action_id", "7")
.formParam("projectId", "${projectId}")
.formParam("folderId", "0")
.formParam("AdminRoleId", "${roleId}")
.formParam("isWorkspace", "1")
.formParam("extra", """{"folderName":"+dateTime+","security":{"defaults":[{"name":"defalt","acessId":1}],"users":[{"hashedUserId":"${userID}","userName":"User112"}],"roles":[{"roleId":"${roleId}","roleName":"Administrator"}]}}"""))
.pause(3)
Can anyone guide me, why is this happening???
full error message: "jsonPath($.distData.roleList[25].roleId).find(0).exists failed, could not prepare: Boon failed to parse into a valid AST: -1"
Your help would be much appreciated.
thanks,
Praveen Mourya
Your HTTP response payload is not JSON.

I'm getting java.lang.NoSuchMethodError while initializing ConcurrentUpdateSolrClient object

I'm getting java.lang.NoSuchMethodError while initializing ConcurrentUpdateSolrClient object by calling
ConcurrentUpdateSolrClient _server = new ConcurrentUpdateSolrClient(url, 10, 4);
Jar files which I'm using are
httpcore-4.4.1.jar
httpclient-4.4.1.jar
The following error logged in console
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.http.util.VersionInfo.getUserAgent(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/String;
at org.apache.http.impl.client.DefaultHttpClient.setDefaultHttpParams(DefaultHttpClient.java:184)
at org.apache.http.impl.client.DefaultHttpClient.createHttpParams(DefaultHttpClient.java:159)
at org.apache.http.impl.client.AbstractHttpClient.getParams(AbstractHttpClient.java:466)
at org.apache.solr.client.solrj.impl.HttpClientUtil.setFollowRedirects(HttpClientUtil.java:290)
at org.apache.solr.client.solrj.impl.HttpClientConfigurer.configure(HttpClientConfigurer.java:58)
at org.apache.solr.client.solrj.impl.HttpClientUtil.configureClient(HttpClientUtil.java:149)
at org.apache.solr.client.solrj.impl.HttpClientUtil.createClient(HttpClientUtil.java:125)
at org.apache.solr.client.solrj.impl.HttpSolrClient.<init>(HttpSolrClient.java:188)
at org.apache.solr.client.solrj.impl.HttpSolrClient.<init>(HttpSolrClient.java:165)
at org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient.<init>(ConcurrentUpdateSolrClient.java:127)
at org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient.<init>(ConcurrentUpdateSolrClient.java:119)
at org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient.<init>(ConcurrentUpdateSolrClient.java:109)
at org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient.<init>(ConcurrentUpdateSolrClient.java:102)
at com.etl.extract.ExtractData.<init>(ExtractData.java:34)
at com.etl.base.LaunchExtract.main(LaunchExtract.java:11)
Please let me know if anyone already faced this issue and resolved!
Thanks.

Scribe Java Twitter Posting Error

I am writing a posting engine to run on Glassfish which posts to Twitter from a database queue.
I am using the Scribe Java API for doing this. I am having an issue with performing a signRequest from the OAuthService. I have a valid access token and have the tweet to send out - Below is my code for where the error is occuring.
String urlTweet = "https://api.twitter.com/1.1/statuses/update.json?status=Tweet To Post";
OAuthRequest tmpRequest = new OAuthRequest(Verb.POST, urlTweet);
oAuthService.signRequest(accessToken, tmpRequest); // THIS LINE THERE IS AN ERROR
response = tmpRequest.send();
However I am getting an error on the line shown above. Here is the stack trace for what I am getting - parts have been redacted for anonymity purposes.
org.scribe.exceptions.OAuthSignatureException: Error while signing string: POST&https%3A%2F%2Fapi.twitter.com%2F1.1%2Fstatuses%2Fupdate.json&[redacted]
at org.scribe.services.HMACSha1SignatureService.getSignature(HMACSha1SignatureService.java:36)
at org.scribe.oauth.OAuth10aServiceImpl.getSignature(OAuth10aServiceImpl.java:151)
at org.scribe.oauth.OAuth10aServiceImpl.addOAuthParams(OAuth10aServiceImpl.java:75)
at org.scribe.oauth.OAuth10aServiceImpl.signRequest(OAuth10aServiceImpl.java:126)
at [redacted].TWScribePost.postTwitter(TWScribePost.java:141)
at [redacted].Post.TWScribePost.post(TWScribePost.java:42)
at [redacted].Post.PostingEng$TWReadQueue.run(PostingEng.java:137)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)
Caused by: java.security.NoSuchAlgorithmException: Algorithm HmacSHA1 not available
at javax.crypto.Mac.getInstance(DashoA13*..)
at org.scribe.services.HMACSha1SignatureService.doSign(HMACSha1SignatureService.java:43)
at org.scribe.services.HMACSha1SignatureService.getSignature(HMACSha1SignatureService.java:32)
... 8 more
Try to use response = oAuthService.execute(tmpRequest); instead of response = tmpRequest.send();

Google App add contact error?

In my GAE app there is the following line :
ContactsService myService=new ContactsService("app-name");
It compiled fine, but when run, it cause the following error :
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.collect.Iterators.forArray([Ljava/lang/Object;)Lcom/google/common/collect/UnmodifiableIterator;
at com.google.common.collect.ImmutableSet$ArrayImmutableSet.iterator(ImmutableSet.java:415)
at com.google.common.collect.ImmutableSet$ArrayImmutableSet.iterator(ImmutableSet.java:392)
at com.google.common.collect.ImmutableCollection$Builder.addAll(ImmutableCollection.java:317)
at com.google.common.collect.ImmutableList$Builder.addAll(ImmutableList.java:601)
at com.google.gdata.wireformats.AltFormat.<init>(AltFormat.java:183)
at com.google.gdata.wireformats.AltFormat.<init>(AltFormat.java:42)
at com.google.gdata.wireformats.AltFormat$Builder.build(AltFormat.java:457)
at com.google.gdata.wireformats.AltFormat.<clinit>(AltFormat.java:49)
at com.google.gdata.client.Service.<clinit>(Service.java:558)
at Test.ContactsExample.<init>(ContactsExample.java:102)
I've included guava-r09.jar, so it has the "ImmutableSet", if I don't included guava-r09.jar, it will say :
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableSet
What should I do ?
I found out why : don't need to include google-collect-*.jar, source of error.

Getting error while checking if a url is alive or not

I want to constantly monitor whether a site is active or not using the following code in Java:
URL url1 = new URL ("http://www.google.com");
HttpURLConnection code = (HttpURLConnection)url1.openConnection();
System.out.println(code.getResponseCode());
but I keep getting an error:
Exception in thread "main" java.net.UnknownHostException: www.google.com
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:158)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
at java.net.Socket.connect(Socket.java:546)
at java.net.Socket.connect(Socket.java:495)
at sun.net.NetworkClient.doConnect(NetworkClient.java:178)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:409)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:530)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:240)
at sun.net.www.http.HttpClient.New(HttpClient.java:321)
at sun.net.www.http.HttpClient.New(HttpClient.java:338)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:935)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:876)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:801)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1139)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:397)
at java.net.HttpURLConnection.getResponseMessage(HttpURLConnection.java:463)
Am I doing something wrong? Please advice.
Thanks.
Are you behind a proxy? It may require your proxy settings to work correctly..
Your server is not able to resolve google.com . Check for your DNS settings (resolv.conf and similar files).

Categories