i am trying to connect to the magento soap api in java, i have added almost all the jar files as per the error logs, but i am stuck at this run time exception, please have a look a look at the code and the output.
import com.google.code.magja.soap.MagentoSoapClient;
import com.google.code.magja.soap.SoapConfig;
import org.apache.axis2.AxisFault;
public class testConnection {
public static void main(String[] args) throws AxisFault {
String user = "XXXXXX";
String pass = "XXXXX";
String host = "http://XXX.co.in/magento/index.php/api/soap?wsdl";
SoapConfig soapConfig = new SoapConfig(user, pass, host);
MagentoSoapClient magentoSoapClient = MagentoSoapClient.getInstance(soapConfig);
// configure connection
magentoSoapClient.setConfig(soapConfig);
}
}
OUTPUT
Exception in thread "main" java.lang.RuntimeException: org.apache.axis2.deployment.DeploymentException: org.apache.axis2.transport.http.CommonsHTTPTransportSender
at com.google.code.magja.soap.MagentoSoapClient.<init>(MagentoSoapClient.java:56)
at com.google.code.magja.soap.MagentoSoapClient.getInstance(MagentoSoapClient.java:79)
at magentomanager.testConnection.main(testConnection.java:14)
Caused by: org.apache.axis2.deployment.DeploymentException: org.apache.axis2.transport.http.CommonsHTTPTransportSender
at org.apache.axis2.deployment.AxisConfigBuilder.processTransportSenders(AxisConfigBuilder.java:708)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:122)
at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:857)
at org.apache.axis2.deployment.FileSystemConfigurator.getAxisConfiguration(FileSystemConfigurator.java:116)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(ConfigurationContextFactory.java:210)
at org.apache.axis2.client.ServiceClient.configureServiceClient(ServiceClient.java:151)
at org.apache.axis2.client.ServiceClient.<init>(ServiceClient.java:144)
at org.apache.axis2.client.ServiceClient.<init>(ServiceClient.java:251)
at com.google.code.magja.soap.MagentoSoapClient.login(MagentoSoapClient.java:138)
at com.google.code.magja.soap.MagentoSoapClient.<init>(MagentoSoapClient.java:53)
... 2 more
Caused by: java.lang.ClassNotFoundException: org.apache.axis2.transport.http.CommonsHTTPTransportSender
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 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at org.apache.axis2.util.Loader.loadClass(Loader.java:261)
at org.apache.axis2.deployment.AxisConfigBuilder.processTransportSenders(AxisConfigBuilder.java:683)
Added JAR Files
I just ran into the same issue and added these dependencies to my maven pom
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.6.2</version>
</dependency>
Hope this helps.
Related
I'm trying to connect a java client to my elasticsearch server.
The version of elasticsearch is 2.4.0.
This server has a special configuration that's why I use port 10700 instead of 9300 in order to connect.
(When I try "telnet serveraddress 10700" I succeed).
As you'll see below, I have an error and I don't know how to resolve it.
Can you help me, please ?
Thanks.
My Code :
public void connexionToEs() throws UnknownHostException {
String clusterName = "xxx";
String serverAddress = "xxx";
try{
Settings settings = Settings.builder()
.put("cluster.name", clusterName)
.put("client.transport.sniff", true)
.build();
TransportClient client = new PreBuiltTransportClient(settings);
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(serverAddress), 10700));
SearchResponse response = client.prepareSearch().execute().actionGet();
String output = response.toString();
System.out.println(output);
client.close();
}catch(Exception e){
e.printStackTrace();
}
}
My dependencies :
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<version>2.6.2</version>
</dependency>
My error :
Exception in thread "main" java.lang.NoClassDefFoundError: org/elasticsearch/plugins/ActionPlugin
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
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 org.elasticsearch.transport.client.PreBuiltTransportClient.<clinit>(PreBuiltTransportClient.java:54)
at fr.solocal.dao.impl.CentralDAOImpl.connexionToEs(CentralDAOImpl.java:422)
at fr.solocal.App.main(App.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.ClassNotFoundException: org.elasticsearch.plugins.ActionPlugin
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)
... 20 more
As #Roma Khomyshyn mentioned, Spring Data Elasticsearch only support transport client currently, but the version of Elasticsearch server and transport client must be the same. That's why you got unexpected error like this one.
A possible solution is another Spring Data implementation using JEST client - https://github.com/VanRoy/spring-data-jest
My code below is throwing following Error and only information i can find on Google involved logging errors but nothing that looks like mine. I have tried installing dependences it says are needed on the central maven repo but still the problem persists. Does anyone know why im getting class no found exceptions?
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.common.IOUtils;
import net.schmizz.sshj.connection.channel.direct.Session;
import net.schmizz.sshj.connection.channel.direct.Session.Command;
public class ConnectSSH {
public void connecting() throws IOException {
#SuppressWarnings("resource")
final SSHClient ssh = new SSHClient();
ssh.loadKnownHosts();
ssh.connect("*******");
try {
ssh.authPassword("*****", "*****");
final Session session = ssh.startSession();
try {
final Command cmd = session.exec("*****");
System.out.print(IOUtils.readFully(cmd.getInputStream()));
cmd.join(5, TimeUnit.SECONDS);
System.out.print("\n** exit status: " + cmd.getExitStatus());
} finally {
session.close();
}
} finally {
ssh.disconnect();
}
}
}
Error below is thrown when running:
Exception in thread "main" java.lang.NoClassDefFoundError: net/schmizz/sshj/SSHClient
at ssh.liq_con.stats.ConnectSSH.connecting(ConnectSSH.java:16)
at ssh.liq_con.stats.App.main(App.java:8)
Caused by: java.lang.ClassNotFoundException: net.schmizz.sshj.SSHClient
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Note i have:
<dependency>
<groupId>net.schmizz</groupId>
<artifactId>sshj</artifactId>
<version>0.9.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
<version>0.9.0</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.49</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jzlib</artifactId>
<version>1.1.3</version>
</dependency>
You actually don't need to install dependencies - they are auto-fetched by Maven. This might be a problem with your classpath, you may try adding as the first line of your public static void main(String[]):
System.out.println(System.getProperty("java.class.path"));
to make sure you have sshj-0.9.0.jar in your classpath.
I am using Twilio to send SMS messages from my web app and I have almost completed the integration. It's sending the SMS, but an error is being generated and I don't understand why. I have included a JSON dependency from this json and this file link but I'm still getting an error. Which other jar do I need to include?
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/jackson/JsonParseException
at com.twilio.sdk.TwilioRestResponse.getParser(TwilioRestResponse.java:225)
at com.twilio.sdk.TwilioRestResponse.toMap(TwilioRestResponse.java:243)
at com.twilio.sdk.resource.list.SmsList.create(SmsList.java:70)
at Example.main(Example.java:25)
Caused by: java.lang.ClassNotFoundException: org.codehaus.jackson.JsonParseException
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 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 4 more
screenshot showing json added
Update this is the new screesnshot
You have missed jackson-core-asl.jar 1.9.13 in you project. You can make use of this Maven POM dependency
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.13</version>
</dependency>
Hope this solves your problem. Check this link for more information. Direct link for download
Class is present in the jar Screen below
Remove your java-json.jar and add the jackson-core-asl.jar
I have the following errors when i try to run my Netbeans aplication of a map reduce algorithm:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Level
at org.apache.hadoop.mapred.JobConf.<clinit>(JobConf.java:349)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:1121)
at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:88)
at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:72)
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:125)
at org.apache.hadoop.security.Groups.<init>(Groups.java:54)
at org.apache.hadoop.security.Groups.getUserToGroupsMappingService(Groups.java:142)
at
org.apache.hadoop.security.UserGroupInformation.initUGI(UserGroupInformation.java:243)
at
org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation
.java:216)
at
org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation
.java:207)
at
org.apache.hadoop.security.UserGroupInformation.isSecurityEnabled(UserGroup
Information.java:286)
at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroup
Information.java:500)
at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroup
Information.java:483)
at org.apache.hadoop.mapreduce.Cluster.<init>(Cluster.java:73)
at org.apache.hadoop.mapreduce.Job.<init>(Job.java:133)
at org.apache.hadoop.mapreduce.Job.<init>(Job.java:138)
at cloudex.CloudEx.main(CloudEx.java:33)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Level
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 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 19 more
Could you please give me a hint on how to get rid of it? i do not know what it generates it
You need to add the log4j jar to your classpath.
Either add the log4j class to your classpath as #smcg has stated, or add the following into your project pom.xml if you're using maven.
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
Download Apache log4j *.jar file at log4j. Import external *.jar file to your project.
I could create a jira issue using the rest client API, but i wasn't able to attach the screeshot/attachment to the exsiting JIRA issue. Would be really helpful if anyone could provide a solution which would be really appreciated.
I just wrote the below code snippet for attaching a jpeg file to the existing JIRA Issue. But then i experienced "Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpConnectionManager"
Code Snippet :-
private static String addAttachment(String attachmentfilepath) throws URISyntaxException, FileNotFoundException{
final java.net.URI jiraServerUri = new java.net.URI("https://oliveits.atlassian.net");
FileInputStream fileStreamPath = new FileInputStream(attachmentfilenamepath);
JerseyJiraRestClientFactory factory = new JerseyJiraRestClientFactory();
NullProgressMonitor pm = new NullProgressMonitor();
System.out.println("Server Url :"+jiraServerUri);
JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraServerUri,"mobileqa","MobileQA1234");
Issue issue1 = restClient.getIssueClient().getIssue(newKey, pm);
final java.net.URI AttachmentUri = new java.net.URI(jiraServerUri+"/rest/api/2/issue/"+newKey+"/attachments");
System.out.println("URI :"+issue1.getAttachmentsUri());
//restClient.getIssueClient().addAttachment(pm,issue1.getAttachmentsUri(), fileStreamPath , imageName);
restClient.getIssueClient().addAttachment(pm, AttachmentUri, fileStreamPath, imageName);
return attachmentfilepath;
}
Exception:-
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpConnectionManager
at com.atlassian.jira.rest.client.internal.jersey.JerseyJiraRestClientFactory.create(JerseyJiraRestClientFactory.java:34)
at com.atlassian.jira.rest.client.internal.jersey.JerseyJiraRestClientFactory.createWithBasicHttpAuthentication(JerseyJiraRestClientFactory.java:39)
at com.jtricks.JTricksRESTClient.addAttachment(JTricksRESTClient.java:157)
at com.jtricks.JTricksRESTClient.main(JTricksRESTClient.java:101)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.HttpConnectionManager
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 4 more
Just added the missing jar files to the classpath. But I'm getting an exception as mentioned below.
Exception Msg-1: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java class com.sun.jersey.multipart.MultiPart, and Java type class com.sun.jersey.multipart.MultiPart, and MIME media type multipart/form-data; boundary=Boundary_1_18541827_1358346116249 was not found
Exception Msg-2: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java class com.sun.jersey.multipart.MultiPart, and Java type class com.sun.jersey.multipart.MultiPart, and MIME media type multipart/form-data; boundary=Boundary_1_18541827_1358346116249 was not found
You issue comes from inability to find org.apache.commons.httpclient.HttpConnectionManager class. Look for commons-httpclient JAR in your classpath.
You can try this :
String issueKey = "your-issue";
JiraRestClient restClient
= AsynchronousJiraRestClientFactory()
.createWithBasicHttpAuthentication(
getJiraUri(),
username,
password);
Issue issue = restClient.getIssueClient().getIssue(issueKey).claim();
restClient.getIssueClient().addAttachments(issue.getAttachmentsUri(), file).claim();
restClient.close();
in the pom.xml
<properties>
<jira-rest-java-client-core.version>5.2.4</jira-rest-java-client-core.version>
<atlassian.fugue.version>5.0.0</atlassian.fugue.version>
</properties>
...
<dependencies>
...
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>${jira-rest-java-client-core.version}</version>
</dependency>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-api</artifactId>
<version>${jira-rest-java-client-core.version}</version>
</dependency>
<dependency>
<groupId>io.atlassian.fugue</groupId>
<artifactId>fugue</artifactId>
<version>${atlassian.fugue.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>