Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/concurrent/FutureCallback
at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68)
at iezon.main.WebSocket.getAllApps(WebSocket.java:21)
at iezon.main.Init.(Init.java:16)
at iezon.main.Init.main(Init.java:27)
Caused by: java.lang.ClassNotFoundException: org.apache.http.concurrent.FutureCallback
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
My current code is:
package iezon.main;
import org.json.JSONArray;
import org.json.JSONObject;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import iezon.interfaces.options.InterfaceController;
public class WebSocket {
public WebSocket() {
}
public void getAllApps() {
try {
HttpResponse<JsonNode> request = Unirest.get("https://iezontechnologywebapp.000webhostapp.com/api/store/get").asJson();
JSONArray response = request.getBody().getArray();
for (int i = 0; i < response.length(); i++) {
JSONObject object = response.getJSONObject(i);
// TODO: Load apps properly this is just a test dialog to show they loaded
InterfaceController.showDialog(new Object[] {
object.getString("name"),
object.getString("description")
}, "Apps loaded");
}
} catch (UnirestException e) {
e.printStackTrace();
}
}
}
I have tried adding httpclient-4.3.3.jar to the buildpath as well as commons-io-2.5.jar but neither has fixed the issue, I have checked documentation but doesn't say I need any other libraries to run Unirest
Related
Hi guys i've created a saml assertion with opensaml-j and when i run the program an exception occurs and throws NoClassDefFoundError
i've loaded all the necessary jar files but still don't work
here's my code:
package memory;
import java.security.SecureRandom;
import org.joda.time.DateTime;
import org.opensaml.saml.common.SAMLVersion;
import org.opensaml.saml.saml1.core.AttributeStatement;
import org.opensaml.saml.saml1.core.AttributeValue;
import org.opensaml.saml.saml1.core.NameIdentifier;
import org.opensaml.saml.saml1.core.Subject;
import org.opensaml.saml.saml1.core.impl.EvidenceBuilder;
import org.opensaml.saml.saml1.core.impl.NameIdentifierBuilder;
import org.opensaml.saml.saml1.core.impl.SubjectBuilder;
import org.opensaml.saml.saml2.core.Action;
import org.opensaml.saml.saml2.core.Assertion;
import org.opensaml.saml.saml2.core.Attribute;
import org.opensaml.saml.saml2.core.AuthzDecisionStatement;
import org.opensaml.saml.saml2.core.Conditions;
import org.opensaml.saml.saml2.core.DecisionTypeEnumeration;
import org.opensaml.saml.saml2.core.Evidence;
import org.opensaml.saml.saml2.core.Issuer;
import org.opensaml.saml.saml2.core.impl.ActionBuilder;
import org.opensaml.saml.saml2.core.impl.AssertionBuilder;
import org.opensaml.saml.saml2.core.impl.AttributeBuilder;
import org.opensaml.saml.saml2.core.impl.AttributeStatementBuilder;
import org.opensaml.saml.saml2.core.impl.AuthzDecisionStatementBuilder;
import org.opensaml.saml.saml2.core.impl.ConditionsBuilder;
import org.opensaml.saml.saml2.core.impl.IssuerBuilder;
public class CreateSamlAssertion {
#SuppressWarnings("deprecation")
public static Assertion createAssertion(){
Assertion assertion=(Assertion)new AssertionBuilder().buildObject();
assertion.setID(idGenerator());
assertion.setVersion(SAMLVersion.VERSION_20);
assertion.setIssueInstant(new DateTime());
Issuer issuer=(Issuer)new IssuerBuilder().buildObject();
issuer.setNameQualifier("bob");
assertion.setIssuer(issuer);
Subject subject=(Subject)new SubjectBuilder().buildObject();
NameIdentifier nameId=(NameIdentifier)new NameIdentifierBuilder().buildObject();
nameId.setFormat(NameIdentifier.EMAIL);
nameId.setNameIdentifier("alice");
subject.setNameIdentifier(nameId);
Conditions conditions=(Conditions)new ConditionsBuilder().buildObject();
conditions.setNotBefore(new DateTime());
conditions.setNotOnOrAfter(new DateTime().plusMinutes(20));
assertion.setConditions(conditions);
AuthzDecisionStatement authDecisionStatement=getAuthzDecisionStatement();
assertion.getAuthzDecisionStatements().add(authDecisionStatement);
return assertion;
}
private static AuthzDecisionStatement getAuthzDecisionStatement(){
AuthzDecisionStatement aDStatement=(AuthzDecisionStatement)new AuthzDecisionStatementBuilder().buildObject();
DecisionTypeEnumeration decision = DecisionTypeEnumeration.PERMIT;
aDStatement.setDecision(decision);
aDStatement.setResource("http://www.hb.com/Resources/Resource A1");
Action actions=getAction();
actions.setNamespace("http://www.hb.com/Resources/");
aDStatement.getActions().add(actions);
Evidence evidence=getEvidence();
aDStatement.setEvidence(evidence);
return aDStatement;
}
private static Evidence getEvidence(){
Evidence evidence=(Evidence)new EvidenceBuilder().buildObject();
Assertion assertion=(Assertion)new AssertionBuilder().buildObject();
AttributeStatement aStatement=(AttributeStatement) new AttributeStatementBuilder().buildObject();
Attribute attribute1=(Attribute)new AttributeBuilder().buildObject();
attribute1.setName("IssuerCapabilityID");
AttributeValue aValue1=(AttributeValue) AttributeValue.DEFAULT_ELEMENT_NAME;
attribute1.getAttributeValues().add(aValue1);
Attribute attribute2=(Attribute)new AttributeBuilder().buildObject();
attribute2.setName("IssuerCapabilityID");
AttributeValue aValue2=(AttributeValue) AttributeValue.DEFAULT_ELEMENT_NAME;
attribute1.getAttributeValues().add(aValue2);
aStatement.getAttributes().add((org.opensaml.saml.saml1.core.Attribute) attribute1);
aStatement.getAttributes().add((org.opensaml.saml.saml1.core.Attribute) attribute2);
assertion.getAttributeStatements().add((org.opensaml.saml.saml2.core.AttributeStatement) aStatement);
evidence.getAssertions().add(assertion);
return evidence;
}
private static Action getAction(){
Action action=(Action)new ActionBuilder().buildObject();
action.setAction("Read");
action.setAction("Write");
return action;
}
private static String idGenerator(){
SecureRandom random=new SecureRandom();
return String.valueOf(random.nextInt());
}
}
and here's the main class:
package memory;
import org.opensaml.saml.saml2.core.Assertion;
public class SamlTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
Assertion assertion=CreateSamlAssertion.createAssertion();
System.out.println(assertion);
}
}
the stack trace
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.opensaml.core.xml.AbstractXMLObject.<init>(AbstractXMLObject.java:47)
at org.opensaml.xmlsec.signature.AbstractSignableXMLObject.<init>(AbstractSignableXMLObject.java:47)
at org.opensaml.saml.common.AbstractSignableSAMLObject.<init>(AbstractSignableSAMLObject.java:44)
at org.opensaml.saml.saml2.core.impl.AssertionImpl.<init>(AssertionImpl.java:83)
at org.opensaml.saml.saml2.core.impl.AssertionBuilder.buildObject(AssertionBuilder.java:45)
at org.opensaml.saml.saml2.core.impl.AssertionBuilder.buildObject(AssertionBuilder.java:40)
at memory.CreateSamlAssertion.createAssertion(CreateSamlAssertion.java:34)
at memory.SamlTest.main(SamlTest.java:9)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
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)
... 8 more
and thanks in advance
I was watching this tutorial on making games using java and I was on the part where we import music to our game. However, when I try to load the sounds using a method created in this class:
package main;
import java.util.HashMap;
import java.util.Map;
import org.newdawn.slick.Music;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.Sound;
public class AudioPlayer {
public static Map<String, Sound> soundMap = new HashMap<String, Sound>();
public static Map<String, Music> musicMap = new HashMap<String, Music>();
public static void load(){
try {
soundMap.put("click_sound", new Sound("res/clickSound.ogg"));
musicMap.put("music", new Music("res/background_Music.ogg"));
} catch (SlickException e) {
e.printStackTrace();
}
}
public static Music getMusic(String key){
return musicMap.get(key);
}
public static Sound getSound(String key){
return soundMap.get(key);
}
}
i get an error that says this:
Exception in thread "main" java.lang.NoClassDefFoundError: com/jcraft/jorbis/Info
at org.newdawn.slick.openal.OggInputStream.<init>(OggInputStream.java:35)
at org.newdawn.slick.openal.OggDecoder.getData(OggDecoder.java:311)
at org.newdawn.slick.openal.SoundStore.getOgg(SoundStore.java:835)
at org.newdawn.slick.openal.SoundStore.getOgg(SoundStore.java:793)
at org.newdawn.slick.Sound.<init>(Sound.java:87)
at main.AudioPlayer.load(AudioPlayer.java:18)
at main.Game.<init>(Game.java:45)
at main.Game.main(Game.java:160)
Caused by: java.lang.ClassNotFoundException: com.jcraft.jorbis.Info
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)
... 8 more
AL lib: (EE) alc_cleanup: 1 device not closed
have I wrote something wrong? i imported the correct external jars and did everything that said in the tutorial. However, I keep getting this error?
This is my code
import processing.core.PApplet;
import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.utils.MapUtils;
public class SimpleMapApp extends PApplet {
UnfoldingMap map;
public void setup() {
size(750, 600,P2D);
map = new UnfoldingMap(this);
MapUtils.createDefaultEventDispatcher(this, map);
}
public void draw() {
map.draw();
}
}
When i run it throws exception:
Unfolding Map v0.9.6
Using OpenGLMapDisplay with processing.opengl.PGraphics2D
java.io.IOException: Server returned HTTP response code: 500 for URL:
http://a.tiles.wmflabs.org/bw-mapnik/2/2/2.png at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
Source) at java.net.URL.openStream(Unknown Source) at
processing.core.PApplet.createInputRaw(PApplet.java:7233) at
processing.core.PApplet.createInput(PApplet.java:7201) at
processing.core.PApplet.loadBytes(PApplet.java:7428) at
processing.core.PApplet.loadImage(PApplet.java:5867) at
de.fhpotsdam.unfolding.tiles.TileLoader.getTileFromUrl(Unknown Source)
at de.fhpotsdam.unfolding.tiles.TileLoader.run(Unknown Source) at
java.lang.Thread.run(Unknown Source)
Try changing your map provider.
map = new UnfoldingMap(this, new Google.GoogleMapProvider());
I am doing a project in java called visual speech recognition . while iam trying to run the below code in eclipse indigo..
package main.java.edu.lipreading;
import com.googlecode.javacpp.BytePointer;
import com.googlecode.javacv.cpp.opencv_core;
import main.java.edu.lipreading.vision.AbstractFeatureExtractor;
import main.java.edu.lipreading.vision.NoMoreStickersFeatureExtractor;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.eclipse.jetty.websocket.WebSocket;
import org.eclipse.jetty.websocket.WebSocketHandler;
import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.logging.Logger;
import static com.googlecode.javacv.cpp.opencv_core.CV_8UC1;
import static com.googlecode.javacv.cpp.opencv_core.cvMat;
import static com.googlecode.javacv.cpp.opencv_highgui.cvDecodeImage;
/**
* Created with IntelliJ IDEA.
* User: Sagi
* Date: 25/04/13
* Time: 21:47
*/
public class WebFeatureExtractor extends Server {
private final static Logger LOG = Logger.getLogger(WebFeatureExtractor.class.getSimpleName());
private final static AbstractFeatureExtractor fe = new NoMoreStickersFeatureExtractor();
public WebFeatureExtractor(int port) {
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(port);
addConnector(connector);
WebSocketHandler wsHandler = new WebSocketHandler() {
public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
return new FeatureExtractorWebSocket();
}
};
setHandler(wsHandler);
}
/**
* Simple innerclass that is used to handle websocket connections.
*
* #author jos
*/
private static class FeatureExtractorWebSocket implements WebSocket, WebSocket.OnBinaryMessage, WebSocket.OnTextMessage {
private Connection connection;
public FeatureExtractorWebSocket() {
super();
}
/**
* On open we set the connection locally, and enable
* binary support
*/
#Override
public void onOpen(Connection connection) {
LOG.info("got connection open");
this.connection = connection;
this.connection.setMaxBinaryMessageSize(1024 * 512);
}
/**
* Cleanup if needed. Not used for this example
*/
#Override
public void onClose(int code, String message) {
LOG.info("got connection closed");
}
/**
* When we receive a binary message we assume it is an image. We then run this
* image through our face detection algorithm and send back the response.
*/
#Override
public void onMessage(byte[] data, int offset, int length) {
//LOG.info("got data message");
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
bOut.write(data, offset, length);
try {
String result = convert(bOut.toByteArray());
this.connection.sendMessage(result);
} catch (Exception e) {
LOG.severe("Error in facedetection, ignoring message:" + e.getMessage());
}
}
#Override
public void onMessage(String data) {
LOG.info("got string message");
}
}
public static String convert(byte[] imageData) throws Exception {
opencv_core.IplImage originalImage = cvDecodeImage(cvMat(1, imageData.length, CV_8UC1, new BytePointer(imageData)));
List<Integer> points = fe.getPoints(originalImage);
if(points == null)
return "null";
String ans = "";
for (Integer point : points) {
ans += point + ",";
}
return ans;
}
/**
* Start the server on port 999
*/
public static void main(String[] args) throws Exception {
WebFeatureExtractor server = new WebFeatureExtractor(9999);
server.start();
server.join();
}
}
i am getting this error..
Exception in thread "main" java.lang.VerifyError: class org.eclipse.jetty.server.nio.AbstractNIOConnector overrides final method newBuffer.(I)Lorg/eclipse/jetty/io/Buffer;
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
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)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
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)
at main.java.edu.lipreading.WebFeatureExtractor.<init>(WebFeatureExtractor.java:33)
at main.java.edu.lipreading.WebFeatureExtractor.main(WebFeatureExtractor.java:118)
i got dis code from https://github.com/sagioto/LipReading/blob/master/lipreading-core/src/main/java/edu/lipreading/WebFeatureExtractor.java..
can anyone help me plz..
java.lang.VerifyError can happen if you're running against a different version of a library than the code was compiled against.
Looking in the github repository, I see the files are dated 25 April 2013. Apparently, Jetty has received an update during these last 10 months. Find the version of Jetty that was current on that date and try again.
in my program
package com.XSLTTransformation;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import net.sf.jxls.exception.ParsePropertyException;
import net.sf.jxls.transformer.XLSTransformer;
public class XSLTTransformation {
public static void main(String[] args) {
Collection<Employee> staff = new HashSet<Employee>();
staff.add(new Employee("Derek", 35, 3000, 0.30));
staff.add(new Employee("Elsa", 28, 1500, 0.15));
staff.add(new Employee("Oleg", 32, 2300, 0.25));
staff.add(new Employee("Neil", 34, 2500, 0.00));
staff.add(new Employee("Maria", 34, 1700, 0.15));
staff.add(new Employee("John", 35, 2800, 0.20));
Map<String, Collection<Employee>> beans = new HashMap<String, Collection<Employee>>();
beans.put("employee", staff);
XLSTransformer transformer = new XLSTransformer();
try {
transformer.transformXLS("C:/Users/hussain.a/Desktop/malay/newprojectpocdetails/temp.xls", beans, "C:/Users/hussain.a/Desktop/malay/newprojectpocdetails/proovNYOutput.xls");
} catch (ParsePropertyException e)
{
e.printStackTrace();
} catch (InvalidFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
i find this error
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/jexl2/parser/Node
at net.sf.jxls.transformer.XLSTransformer.transformWorkbook(XLSTransformer.java:269)
at net.sf.jxls.transformer.XLSTransformer.transformXLS(XLSTransformer.java:221)
at net.sf.jxls.transformer.XLSTransformer.transformXLS(XLSTransformer.java:201)
at com.XSLTTransformation.XSLTTransformation.main(XSLTTransformation.java:27)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.jexl2.parser.Node
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)
i have placed the jar which has this class , i am not able to identify real prob
Add commons-jexl.jar to the CLASSPATH as well ;
Try this link :https://stackoverflow.com/a/8286795/1743852