embedded-jetty

Starting up embedded jetty server for a JAR file

旧时模样 提交于 2019-11-28 03:27:03
问题 What I am trying to do, is to build an executable JAR file which will contain my project. I have included its dependencies right next to it, also in JAR files, so my directory listing looks something like this: ~/Projects/Java/web-app/out: web-app.jar dependency1.jar dependency2.jar dependency3.jar I know and am sure that my problem does not arise from dependencies, as my application functions properly, right up to the moment I start up Jetty embedded. The code I use to start Jetty is like

Jetty 9 The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved

折月煮酒 提交于 2019-11-27 18:45:00
问题 I'm using Jetty 9 embedded. Maven Java 1.7 JSTL When I run my app in Eclipse and browse to my webpage which contains JSTL tags it works fine. When I bundle it in an executable jar and run from cmd prompt I get org.apache.jasper.JasperException: /jsp/pcReport.jsp(4,62) PWC6188: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application My Dependencies <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl<

Java / Jetty: How to Add Filter to Embedded Jetty

≡放荡痞女 提交于 2019-11-27 18:09:53
问题 I am working with embedded Jetty and I want to add a servlet filter to check for authentication before each request. I tried following this example but it looks like the signature has changed. <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-server</artifactId> <version>9.0.4.v20130625</version> </dependency> My Jetty starter looks like this: public class JettyStarter { public static void main( final String[] args ) throws Exception { Server server = new Server(8080); final

How does OkHttp get Json string?

青春壹個敷衍的年華 提交于 2019-11-27 17:49:37
Solution : It was a mistake on my side. The right way is response.body().string() other than response.body.toString() Im using Jetty servlet, the URL is http://172.16.10.126:8789/test/path/jsonpage , every time request this URL it will return {"employees":[ {"firstName":"John", "lastName":"Doe"}, {"firstName":"Anna", "lastName":"Smith"}, {"firstName":"Peter", "lastName":"Jones"} ]} It shows up when type the url into a browser, unfortunately it shows kind of memory address other than the json string when I request with Okhttp . TestActivity﹕ com.squareup.okhttp.internal.http.RealResponseBody

Jersey: How to Add Jackson to Servlet Holder

回眸只為那壹抹淺笑 提交于 2019-11-27 15:13:33
I am creating an embedded Jetty webapp with Jersey. I do not know how to add Jackson for automatic JSON serde here: ServletHolder jerseyServlet = context.addServlet( org.glassfish.jersey.servlet.ServletContainer.class, "/*"); jerseyServlet.setInitOrder(0); jerseyServlet.setInitParameter( ServerProperties.PROVIDER_CLASSNAMES, StringUtils.join( Arrays.asList( HealthCheck.class.getCanonicalName(), Rest.class.getCanonicalName()), ";")); // Create JAX-RS application. final Application application = new ResourceConfig() .packages("com.example.application") .register(JacksonFeature.class); // what do

How to embed Jetty and Jersey into my Java application

无人久伴 提交于 2019-11-27 13:04:31
问题 So I'm trying to embed jetty into my web application so that if I package it as a jar someone can just run the jar file without having to worry about configuring a server. However, I'm having some problems setting up my main class so that jetty can access my resource classes. I've looked at tutorials but they haven't given me exactly what I'm looking for. This is what I have so far. package pojo; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.DefaultServlet; import

Embedded Jetty looking for files inside its Jar file

烈酒焚心 提交于 2019-11-27 12:56:21
问题 I successfully embedded Jetty on a test application. It can serve files without issues. Now I want to know if it's possible for Jetty to serve files that are inside its own Jar file. Does anyone know if that's possible? 回答1: An example is listed on the Jetty embedding page at http://docs.codehaus.org/display/JETTY/Embedding+Jetty The trick is to create a File URL to your classpath location. String webDir = this.class.getClassLoader().getResource("com/company/project/mywebdir").toExternalForm(

Spring 3.1 WebApplicationInitializer & Embedded Jetty 8 AnnotationConfiguration

孤人 提交于 2019-11-27 11:08:03
问题 I'm trying to create a simple webapp without any XML configuration using Spring 3.1 and an embedded Jetty 8 server. However, I'm struggling to get Jetty to recognise my implementaton of the Spring WebApplicationInitializer interface. Project structure: src +- main +- java | +- JettyServer.java | +- Initializer.java | +- webapp +- web.xml (objective is to remove this - see below). The Initializer class above is a simple implementation of WebApplicationInitializer : import javax.servlet

Configure embedded jetty with web.xml?

二次信任 提交于 2019-11-27 10:32:00
问题 I am trying to generate both a war with my web application as well as a self contained jar file with embedded jetty. For the embedded jetty (the jar file distribution) I add a servlet as follows: public static void main(String[] args) throws Exception { Server server = new Server(8080); ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setContextPath("/"); server.setHandler(context); context.addServlet(new ServletHolder(new HelloServlet()),"/*"

How do I create an embedded WebSocket server Jetty 9?

て烟熏妆下的殇ゞ 提交于 2019-11-27 09:51:28
问题 I hate asking such a vague question, but I'm having a hard time finding a simple example. Here's what I have so far: public class JettyWebSocketServlet extends WebSocketServlet{ @Override public void configure(WebSocketServletFactory factory) { factory.register(MyEchoSocket.class); } } @WebSocket public class MyEchoSocket { @OnWebSocketMessage public void onText(WebSocketConnection conn, String message) { System.out.println("text: " + message); try { conn.write(null, new FutureCallback(),