Calling web services from simple java client - java

In Eclipse I am writing this code on the client side, generated from a wsdl file...
TravelAssistServicesStub t = new TravelAssistServicesStub();
ConversionRateByCountry c = new ConversionRateByCountry();
c.setCountry("India");
c.setUser_Id("satya");
ConversionRateByCountryResponse ccy = t.conversionRateByCountry(c);
System.out.println("Conversion: " + ccy.get_return());
...and I get the following exception:
java.lang.NoClassDefFoundError: org/apache/http/HttpResponseFactory
at org.apache.axis2.transport.http.SimpleHTTPServer.init(SimpleHTTPServer.java:113)
at org.apache.axis2.engine.ListenerManager.init(ListenerManager.java:74)
at org.apache.axis2.context.ConfigurationContext.getListenerManager(ConfigurationContext.java:692)
at org.apache.axis2.client.ServiceClient.configureServiceClient(ServiceClient.java:163)
at org.apache.axis2.client.ServiceClient.<init>(ServiceClient.java:143)
at com.travelassist.services.TravelAssistServicesStub.<init>(TravelAssistServicesStub.java:159)
at com.travelassist.services.TravelAssistServicesStub.<init>(TravelAssistServicesStub.java:145)
at com.travelassist.services.TravelAssistServicesStub.<init>(TravelAssistServicesStub.java:196)
at com.travelassist.services.TravelAssistServicesStub.<init>(TravelAssistServicesStub.java:188)
at com.tcs.client.login.LoginClient.main(LoginClient.java:37)
Caused by: java.lang.ClassNotFoundException: org.apache.http.HttpResponseFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

You are missing the apache httpcomponents jar. Make sure it is in your classpath at runtime.

Add jar file axis2-transport-http-1.5.jar on your class path

Related

java.lang.NoSuchMethodError in netty-socketio server

I'm trying to start netty-socketio server, and I can't trace origins of this exception. I have marked in stacktrace place where it may lead to the answer, so if anyone could provide explanation on this it will be much appreciated.
public class SocketIoServer {
private Configuration cnf = new Configuration();
private SocketIOServer server;
public SocketIoServer() {
Configuration config = new Configuration();
config.setHostname("localhost");
config.setPort(8081);
server = new SocketIOServer(config);
server.start();
}
}
When I initialize socket an Exception gets thrown. Here's context:
Exception in thread "main" java.lang.IllegalArgumentException:
java.lang.reflect.InvocationTargetException
at com.corundumstudio.socketio.Configuration.<init>(Configuration.java:112)
at com.corundumstudio.socketio.SocketIOServer.<init>(SocketIOServer.java:66)
at SocketIoServer.<init>(SocketIoServer.java:17)
at Server.main(Server.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.corundumstudio.socketio.Configuration.<init>(Configuration.java:109)
... 8 more
This line in particular
Caused by: java.lang.NoSuchMethodError:
com.fasterxml.jackson.databind.module.SimpleModule.setSerializerModifier(Lcom/fasterxml/jackson/databind/ser/BeanSerializerModifier;)Lcom/fasterxml/jackson/databind/module/SimpleModule;
at com.corundumstudio.socketio.protocol.JacksonJsonSupport.init(JacksonJsonSupport.java:316)
at com.corundumstudio.socketio.protocol.JacksonJsonSupport.<init>(JacksonJsonSupport.java:311)
at com.corundumstudio.socketio.protocol.JacksonJsonSupport.<init>(JacksonJsonSupport.java:304)
... 13 more
You have obviously a conflict of version of jackson-databind in your project, indeed the class com.corundumstudio.socketio.protocol.JacksonJsonSupport relies on the method SimpleModule#setSerializerModifier(BeanSerializerModifier mod) which has been added since the version 2.2 so as it cannot find this method, it means that you have a version of jackson-databind older than 2.2 in your classpath such that the method cannot be found.
Check all the jars that you have in your classpath and make sure that you have only one version of jackson-databind corresponding to the version expected by netty-socketio. For example assuming that you use the version 1.7.12 of netty-socketio, the expected version of jackson-databind is 2.7.4 as you can see here.

Neo4j Error: Error starting org.neo4j.kernel.impl.factory.CommunityFacadeFactory

I am trying to build and consume a neo4j DB. Below, is the code which Im using to create a DB.
String graphDbPath = "C:/Users/abcd/parseJSON2GraphDB";
GraphDatabaseFactory dbFactory = new GraphDatabaseFactory();
GraphDatabaseService graphDb = dbFactory.newEmbeddedDatabase(graphDbPath);
try (Transaction tx = graphDb.beginTx()) {
// Perform DB operations
Node javaNode = graphDb.createNode();
javaNode.setProperty( "name", "Duane" );
Node scalaNode = graphDb.createNode();
scalaNode.setProperty( "name", "Nickull" );
tx.success();
}
graphDb.shutdown();
System.out.println("Created Successfully");
The error which I get when running it is :
Exception in thread "main" java.lang.RuntimeException: Error starting org.neo4j.kernel.impl.factory.CommunityFacadeFactory, C:/Users/abcd/parseJSON2GraphDB
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:144)
at org.neo4j.kernel.impl.factory.CommunityFacadeFactory.newFacade(CommunityFacadeFactory.java:40)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:108)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase(GraphDatabaseFactory.java:100)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.lambda$createDatabaseCreator$0(GraphDatabaseFactory.java:89)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:183)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:65)
at com.idml.synquesgen.Test.createDb(Test.java:48)
at com.idml.synquesgen.Test.main(Test.java:38)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.extension.KernelExtensions#4a622941' failed to initialize. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.init(LifeSupport.java:416)
at org.neo4j.kernel.lifecycle.LifeSupport.init(LifeSupport.java:62)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:98)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:140)
... 8 more
Caused by: java.lang.BootstrapMethodError: java.lang.IllegalAccessError: no such method: org.neo4j.kernel.api.impl.index.IndexWriterConfigs.standard()IndexWriterConfig/invokeStatic
at org.neo4j.kernel.api.impl.labelscan.WritableDatabaseLabelScanIndex.<init>(WritableDatabaseLabelScanIndex.java:40)
at org.neo4j.kernel.api.impl.labelscan.LuceneLabelScanIndexBuilder.build(LuceneLabelScanIndexBuilder.java:72)
at org.neo4j.kernel.api.impl.labelscan.LuceneLabelScanStoreExtension.getLuceneIndex(LuceneLabelScanStoreExtension.java:94)
at org.neo4j.kernel.api.impl.labelscan.LuceneLabelScanStoreExtension.newInstance(LuceneLabelScanStoreExtension.java:79)
at org.neo4j.kernel.api.impl.labelscan.LuceneLabelScanStoreExtension.newInstance(LuceneLabelScanStoreExtension.java:40)
at org.neo4j.kernel.extension.KernelExtensions.init(KernelExtensions.java:69)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.init(LifeSupport.java:406)
... 11 more
Caused by: java.lang.IllegalAccessError: no such method: org.neo4j.kernel.api.impl.index.IndexWriterConfigs.standard()IndexWriterConfig/invokeStatic
at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:483)
... 18 more
Caused by: java.lang.NoClassDefFoundError: org/apache/lucene/codecs/lucene54/Lucene54Codec
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.invoke.MethodHandleNatives.resolve(Native Method)
at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:962)
at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:987)
at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1390)
at java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(MethodHandles.java:1746)
at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:477)
... 18 more
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.codecs.lucene54.Lucene54Codec
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
Any pointers as to what is causing it?
From quick searches, I tried few solutions:
1) Check if any instances of Neo4J already running.
2) Changed the neo4j version (via maven)
Nothing has worked until now.
The stacktrace clearly mentions
java.lang.ClassNotFoundException: org.apache.lucene.codecs.lucene54.Lucene54Codec
So be sure to have lucene-analyzers-common-5.5.0.jar, lucene-codecs-5.5.0.jar and lucene-core-5.5.0.jar on your classpath. (assuming you're on Neo4j 3.0.x)
Or, as a more easy one use http://mvnrepository.com/artifact/org.neo4j/neo4j/3.0.6 as your single dependency which should pull in all other required dependencies transitively.

Dynamic loading java classes in terminal

The application is modular plug-in architecture. That is, while the work is done dynamically load classes. For this purpose a custom class loader extends ClassLoader.
The essence of the problem is that in Eclipse application runs, while in terminal (ubuntu) using the following line of code (where the Catalog "m /" indicates the location of the modules * .class):
java -jar ModularApp.jar m/
I get the following message:
10:07:24,085 DEBUG main CModuleLoader:findClass:39 - Run of the System Classloader.
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) at
org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.NoClassDefFoundError: ru/intetech/module/CModule
at java.lang.ClassLoader.defineClass1(Native Method) at
java.lang.ClassLoader.defineClass(ClassLoader.java:800) at
java.lang.ClassLoader.defineClass(ClassLoader.java:643) at
ru.intetech.moduleloader.CModuleLoader.findClass(CModuleLoader.java:35)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at
java.lang.ClassLoader.loadClass(ClassLoader.java:358) at
ru.intetech.modularApp.Main.main(Main.java:42) ... 5 more Caused by:
java.lang.ClassNotFoundException: ru.intetech.module.CModule at
java.lang.ClassLoader.findClass(ClassLoader.java:531) at
ru.intetech.moduleloader.CModuleLoader.findClass(CModuleLoader.java:40)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at
java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 12 more
Here's a snippet of code, the user class loader (extending ClassLoader), where there is an error:
protected Class<?> findClass(String className) throws ClassNotFoundException
{
try
{
byte b[]=getClassAsBytes(m_pathToBin+className+".class");
return (defineClass(className, b, 0, b.length));
}
catch(FileNotFoundException ex)
{
m_log.debug("Run of the System Classloader.");
return (super.findClass(className));
}
catch(IOException ex)
{
m_log.debug("Run of the Bootstrap.");
return (super.findClass(className));
}
}
What could be the problem?
P.S. Loader implemented on the basis of this article:
http://sysmagazine.com/posts/104229/
Look: The stack trace shows the message "Run of the System Classloader", which proves that the first catch was executed. This was caused by a FileNotFoundException, which clearly occurred in the getClassAsBytes method: This is what you must investigate: Find out what file you are trying to read (put a trace showing the the absolute path), and why that file does not exist.
(Eventually, that catch block tries to load the required class by the system classloader, which has no acces to that class, and so, it throws the ClassNotFoundException).

Running query from Amplab-shark to cassandra on hdfs

Please help needed for Amplab-Shark query on cassandra in hdfs.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/mapreduce/task/JobContextImpl
I can successfully run:
use database
show tables;
etc.
But can not run any select statement i.e:
select * from table;
I get the following error:
shark> select * from call limit 1;
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/mapreduce /task/JobContextImpl
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at org.apache.hadoop.hive.ql.metadata.Table.getInputFormatClass(Table.java:302)
at org.apache.hadoop.hive.ql.metadata.Table.<init>(Table.java:99)
at org.apache.hadoop.hive.ql.metadata.Hive.getTable(Hive.java:989)
at org.apache.hadoop.hive.ql.metadata.Hive.getTable(Hive.java:892)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.getMetaData(SemanticAnalyzer.java:1083)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.getMetaData(SemanticAnalyzer.java:1059)
at shark.parse.SharkSemanticAnalyzer.analyzeInternal(SharkSemanticAnalyzer.scala:139)
at org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:279)
at shark.SharkDriver.compile(SharkDriver.scala:210)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:337)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:909)
at shark.SharkCliDriver.processCmd(SharkCliDriver.scala:328)
at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:413)
at shark.SharkCliDriver$.main(SharkCliDriver.scala:233)
at shark.SharkCliDriver.main(SharkCliDriver.scala)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.mapreduce.task.JobContextImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 17 more
Thank you
I would need to see the full config and how you set up the tables for a better answer. Just looking at the error it seems like you are missing some hadoop jars on your classpath

flexjson: Could not load class

I'm new to flexjson.
I tried the following java code for my test: "FlexjsonTest.zip".
The result of running the program is in "Protocol.txt".
I ran the code from the command line:
javac FlexjsonTest.java
java Flexjson
I use flexjson 2.1 .
Using Java 6 or Java 7 doesn't make any difference.
The result is always:
Exception in thread "main" flexjson.JSONException: [ _address ]: Could not load Address
at flexjson.ObjectBinder.findClassInMap(ObjectBinder.java:235)
at flexjson.ObjectBinder.findClassName(ObjectBinder.java:202)
at flexjson.ObjectBinder.bind(ObjectBinder.java:83)
at flexjson.ObjectBinder.bindIntoObject(ObjectBinder.java:139)
at flexjson.factories.ClassLocatorObjectFactory.instantiate(ClassLocatorObjectFactory.java:38)
at flexjson.ObjectBinder.bind(ObjectBinder.java:86)
at flexjson.ObjectBinder.bind(ObjectBinder.java:65)
at flexjson.JSONDeserializer.deserialize(JSONDeserializer.java:158)
at FlexjsonTest.<init>(FlexjsonTest.java:22)
at FlexjsonTest.main(FlexjsonTest.java:32)
Caused by: java.lang.ClassNotFoundException: Address
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:188)
at flexjson.ObjectBinder.findClassInMap(ObjectBinder.java:230)
... 9 more
So, what am I doing wrong?
igel
it seems that you're trying to deserialize a JSON into an object called Address but the class Address seems not to be in your classpath
at flexjson.JSONDeserializer.deserialize(JSONDeserializer.java:158)
at FlexjsonTest.<init>(FlexjsonTest.java:22)
at FlexjsonTest.main(FlexjsonTest.java:32)
Caused by: java.lang.ClassNotFoundException: Address
also, you should post the code that actually throws this stacktrace in your question

Categories

Resources