Configure embedded jetty with web.xml?

Use a org.eclipse.jetty.webapp.WebAppContext Example: package jetty; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.webapp.WebAppContext; public class OnWebApp { public static void main(String[] args) throws Exception { // Create a basic jetty server object that will listen on port 8080. // Note that if you set this to port 0 then a randomly available port // will be assigned that … Read more

Spring 3.1 WebApplicationInitializer & Embedded Jetty 8 AnnotationConfiguration

The problem is that Jetty’s AnnotationConfiguration class does not scan non-jar resources on the classpath (except under WEB-INF/classes). It finds my WebApplicationInitializer‘s if I register a subclass of AnnotationConfiguration which overrides configure(WebAppContext) to scan the host classpath in addition to the container and web-inf locations. Most of the sub-class is (sadly) copy-paste from the parent. … Read more

How do I create an embedded WebSocket server Jetty 9?

Update: Dec 2, 2013 For an up to date example of the Embedded Jetty with WebSocket see: https://github.com/jetty-project/embedded-jetty-websocket-examples Original Answer There’s an example found in the test cases. http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/examples/echo/ExampleEchoServer.java Short Answer: Server server = new Server(8080); WebSocketHandler wsHandler = new WebSocketHandler() { @Override public void configure(WebSocketServletFactory factory) { factory.register(MyEchoSocket.class); } }; server.addHandler(wsHandler); server.start(); server.join(); This … Read more

Eclipse RCP plugin + embedded Jetty + JSF

Take a look at setting a context in jetty. You can define it before start your server. public class OneWebApp { public static void main(String[] args) throws Exception { String jetty_home = System.getProperty(“jetty.home”,”..”); Server server = new Server(8080); WebAppContext webapp = new WebAppContext(); webapp.setContextPath(“https://stackoverflow.com/”); webapp.setWar(jetty_home+”/webapps/test.war”); server.setHandler(webapp); server.start(); server.join(); } }

How does OkHttp get Json string?

try { OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() .url(urls[0]) .build(); Response responses = null; try { responses = client.newCall(request).execute(); } catch (IOException e) { e.printStackTrace(); } String jsonData = responses.body().string(); JSONObject Jobject = new JSONObject(jsonData); JSONArray Jarray = Jobject.getJSONArray(“employees”); for (int i = 0; i < Jarray.length(); i++) { JSONObject object … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)