I'm trying to execute a protocol through R's console and everytime I get this error:
Error in .jnew("gr.demokritos.iit.radio.home.orchestration.Controller") :
java.lang.ExceptionInInitializerError
I tried to google the error and I only understand that there's something wrong with the static block. Although it seems normal to me.
The two static blocks that exist in the mentioned class:
static ComputationService service;
static {
String conf_path = System.getProperty("config.file", "/root/application.conf");
Config my = ConfigFactory.parseFile(new File(conf_path));
Config config = my.withFallback(ConfigFactory.load());
service = ComputationService$.MODULE$.apply(ActorSystem.apply("benaloh", config));
}
The full source files that are referenced:
ttest.r (jnew at line 55)
controller.java
Related
I am trying to connect to my s3 bucket ( already created and I am able to test by listing using s3cmd ) and list the contest of it.
Not seeing any error message when trying to create the connection. However, when trying to list the the content of my bucket, I am getting the exception :
java.lang.BootstrapMethodError: bootstrap method initialization exception
I am using the dependency ( in gradle) :
implementation "software.amazon.awssdk:s3:2.7.10"
Here the code snippet (I am getting the above error from : adapterSmsS3Client.listBuckets())
import software.amazon.awssdk.services.s3.S3Client;
....
private static final String BASE_URL = "https://s3.us-west-2.amazonaws.com";
private static final String BUCKET_NAME = "adapter-stream/dev";
....
S3Client adapterSmsS3Client = S3Client.builder()
.region(Region.US_WEST_2)
.credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("access-key","secret-key")))
.endpointOverride(URI.create(BASE_URL))
.build();
System.out.println("====Checking connection: " +adapterSmsS3Client.listBuckets());
Any insight on what I am missing ?
I'm trying to access a simple java code from inside my C# webapp using jni4net, but it is throwing some errors.
Generated all proxies and dlls to access the java class.
I wrote the code for connecting with JVM inside the 'Program.cs' file.
Later on the custom java function ie. display_msg() is called from the testfunc() which can be called from anywhere inside the bot using Program.testfunc().
I'm attaching the Program.cs file and the exception occurring.
Also I've named my java file as Test.java and it's inside package mypack.
Program.cs
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using net.sf.jni4net;
using System;
using mypack;
namespace ValidationBot
{
public class Program
{
public static void Main(string[] args)
{
var setup = new BridgeSetup();
setup.Verbose = true;
setup.AddAllJarsClassPath("./");
Bridge.CreateJVM(setup);
Bridge.RegisterAssembly(typeof(Test).Assembly);
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging((logging) =>
{
logging.AddDebug();
logging.AddConsole();
}).UseStartup<Startup>();
public static void testfunc()
{
Test test = new Test();
test.display_msg();
Console.WriteLine("\nPress any key to quit.");
Console.ReadKey();
}
}
}
Test.java
package mypack;
import java.io.*;
public class Test
{
public static void main(String args[])
{
int s =10;
System.out.println(s);
}
public void display_msg()
{
System.out.println("Hello, I'm inside a java program");
}
}
Exception
Exception thrown: 'System.MissingMethodException' in jni4net.n-0.8.8.0.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in System.Private.CoreLib.dll
Exception thrown: 'System.TypeInitializationException' in jni4net.n-0.8.8.0.dll
An unhandled exception of type 'System.TypeInitializationException' occurred in jni4net.n-0.8.8.0.dll
The type initializer for 'net.sf.jni4net.utils.Registry' threw an exception.
I'm a beginner to C# so please help me out with this.
From the comments we deduced that .NET core 2.1 does not support this method: (and maybe others)
System.Reflection.Emit.AssemblyBuilder System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, System.Reflection.Emit.AssemblyBuilderAccess)
I have the following class which I want to unit test:
class PropsProvider {
String propsfileLocation;
void init() {
Path path = getPropsPath();
loadPropertiesFromPath(path);
}
private Path getPropsPath() throws URISyntaxException {
URI fileUri = new URI(propsfileLocation);
return Paths.get(fileUri); // << failure here
}
// ...
}
I am unit testing the above class and I keep getting a failure on the line Paths.get(fileUri). I get an IllegalArgumentException. I am passing in a relative path from my unit test, which is src/test/resources/app.properties. I believe this is happening because I haven't included the prefix file:. The unit test resides in the same package as the above class albeit in the /src/test/java folder. How can I fix this?
You can get the path of any resource using Google's Guava library.
URL myFileLocation=Resources.getResource("myFile.txt");
For more look here.
http://google.github.io/guava/releases/22.0/api/docs/com/google/common/io/Resources.html#getResource-java.lang.Class-java.lang.String-
I am using KafkaSpout. Please find the test program below.
I am using Storm 0.8.1. Multischeme class is there in Storm 0.8.2. I will be using that. I just want to know how were the earlier versions working just by instantiating the StringScheme() class? Where can I download earlier versions of Kafka Spout? But I doubt that would be a correct alternative than to work on Storm 0.8.2. ??? (Confused)
When I run the code (given below) on storm cluster (i.e. when I push my topology) I get the following error (This happens when the Scheme part is commented else of course I will get compiler error as the class is not there in 0.8.1):
java.lang.NoClassDefFoundError: backtype/storm/spout/MultiScheme
at storm.kafka.TestTopology.main(TestTopology.java:37)
Caused by: java.lang.ClassNotFoundException: backtype.storm.spout.MultiScheme
In the code given below you may find the spoutConfig.scheme=new StringScheme(); part commented. I was getting compiler error if I don't comment that line which is but natural as there are no constructors in there. Also when I instantiate MultiScheme I get error as I dont have that class in 0.8.1.
public class TestTopology {
public static class PrinterBolt extends BaseBasicBolt {
public void declareOutputFields(OutputFieldsDeclarer declarer) {
}
public void execute(Tuple tuple, BasicOutputCollector collector) {
System.out.println(tuple.toString());
}
}
public static void main(String [] args) throws Exception {
List<HostPort> hosts = new ArrayList<HostPort>();
hosts.add(new HostPort("127.0.0.1",9092));
LocalCluster cluster = new LocalCluster();
TopologyBuilder builder = new TopologyBuilder();
SpoutConfig spoutConfig = new SpoutConfig(new KafkaConfig.StaticHosts(hosts, 1), "test", "/zkRootStorm", "STORM-ID");
spoutConfig.zkServers=ImmutableList.of("localhost");
spoutConfig.zkPort=2181;
//spoutConfig.scheme=new StringScheme();
spoutConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
builder.setSpout("spout",new KafkaSpout(spoutConfig));
builder.setBolt("printer", new PrinterBolt())
.shuffleGrouping("spout");
Config config = new Config();
cluster.submitTopology("kafka-test", config, builder.createTopology());
Thread.sleep(600000);
}
I had the same problem. Finally resolved it, and I put the complete running example up on github.
You are welcome to check it out here >
https://github.com/buildlackey/cep
(click on the storm+kafka directory for a sample program that should get you up and running).
We had a similar issue.
Our solution:
Open pom.xml
Change scope from provided to <scope>compile</scope>
If you want to know more about dependency scopes check the maven docu:
Maven docu - dependency scopes
I have a class that is having some dependency problems referencing external library files. Every time I try to run this on the server I get errors saying class not found, such as this:
SEVERE: Class [ org/json/JSONException ] not found. Error while loading [ class com.myproj.logic.Driver ]
this is preventing the class from executing. I tried taking out the specific throws execption by just saying "throws exception" and got the following error:
WARNING: A system exception occurred during an invocation on EJB Driver method public void com..logic.Driver.initURL() throws java.lang.Exception
javax.ejb.EJBException: javax.ejb.CreateException: Initialization failed for Singleton Driver
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.IOUtils
#Singleton
public class Driver {
#EJB RSSbean rssbean;
#PostConstruct
#Schedule(hour ="*/1", minute ="*/1", second ="*/1", persistent = false)
public void initURL() throws IOException, JSONException{
URL twitterSource = new URL("http://search.twitter.com/search.json?q=news");
ByteArrayOutputStream urlOutputStream = new ByteArrayOutputStream();
IOUtils.copy(twitterSource.openStream(), urlOutputStream);
String urlContents = urlOutputStream.toString();
JSONObject thisobject = new JSONObject(urlContents);
JSONArray names = thisobject.names();
JSONArray asArray = thisobject.toJSONArray(names);
JSONArray resultsArray = thisobject.getJSONArray("results");
JSONObject jsonObject = resultsArray.getJSONObject(0);
String twitterText = jsonObject.getString("text");
//System.out.println(twitterText);
System.out.println("Calling rssbean from Driver");
rssbean.updateDatabase("twitterText");
}
}
I have edited the Java classpath and added a user library for each of these as well as editing the Build Path of the project. The libraries are displayed in the list and I don't get compiler errors so at least Eclipse has recognized them. The problem comes during execution so I think something is wrong there.
Should I edit the classpath in Windows>Preferences>Java>Classpath> and add the Jars there? I have not had to do this for any other libraries before.
I found out you have to add any library files in the Glassfish/domain/lib directory before they're recognized by glassfish on the server.