embedded-jetty

Embedded Jetty handling urls to serve content

冷暖自知 提交于 2019-12-02 10:03:44
I am using embedded Jetty with Guice and am wondering the best way to handle serving my single page application. I wish for Jetty to handle requests like so (in priority order): /socket must be handled by the websocket servlet /fs/read/* , anything that matches this url I need to be handled by a custom servlet /* , anything that matches this url should be served from the /web on the classpath of my Java application assuming it isn't handled by the above. If the resource does not exist, then it serves /web/index.html Now I am wondering the best way to handle this? It seems heavy handed to use a

JUnit test with javax.websocket on embedded Jetty throws RejectedExecutionException: NonBlockingThread

ε祈祈猫儿з 提交于 2019-12-02 08:16:16
问题 I'm trying to write a test case which creates a socket and connects to an embedded jetty instance. I'm using Jetty: 9.2.0.RC0 javax.websocket-api & javax.websocket-client-api: 1.0 javax.websocket server & client impl: 9.1.5.v20140505 Starting the embedded jetty server with the websocket servlet seems to work fine. I took some code from this example. However this line ... container.connectToServer(SocketClient.class, uri); ... throws this exception java.io.IOException: java.util.concurrent

Upgrading Jetty 8 to Jetty 9

こ雲淡風輕ζ 提交于 2019-12-02 07:17:24
问题 I am upgrading from jetty 8 to jetty 9 and have come across some issues around compilation failures within some APIs. The SslSelectChannelConnector has been removed and from what I can see httpConfiguration with secureRequestCustomizer replaces this. But there are many methods that I cant find on both. For example setRequestBufferSize setResponseBufferSize setAcceptors setMaxIdleTime SessionHandler no longer has a getSessionManager() method. Also the queueThreadPool no longer has a

Why is Jetty serving css with text/html content type

本小妞迷上赌 提交于 2019-12-02 06:25:55
问题 I'm using an embedded Jetty server in a Scalatra app. The issue is that it serves css files with text/html content type: Here is the main method: package yard.web import org.eclipse.jetty.server.Server import org.eclipse.jetty.webapp.WebAppContext import org.scalatra.servlet.ScalatraListener object JettyMain { def main(args: Array[String]) { val server = new Server(9080) val context: WebAppContext = new WebAppContext("src/main/webapp", "/") context.setServer(server) context.setInitParameter

Why is Jetty serving css with text/html content type

北战南征 提交于 2019-12-02 03:31:16
I'm using an embedded Jetty server in a Scalatra app. The issue is that it serves css files with text/html content type: Here is the main method: package yard.web import org.eclipse.jetty.server.Server import org.eclipse.jetty.webapp.WebAppContext import org.scalatra.servlet.ScalatraListener object JettyMain { def main(args: Array[String]) { val server = new Server(9080) val context: WebAppContext = new WebAppContext("src/main/webapp", "/") context.setServer(server) context.setInitParameter(ScalatraListener.LifeCycleKey, "yard.web.ScalatraBootstrap") context.addEventListener(new

JUnit test with javax.websocket on embedded Jetty throws RejectedExecutionException: NonBlockingThread

雨燕双飞 提交于 2019-12-02 02:55:58
I'm trying to write a test case which creates a socket and connects to an embedded jetty instance. I'm using Jetty: 9.2.0.RC0 javax.websocket-api & javax.websocket-client-api: 1.0 javax.websocket server & client impl: 9.1.5.v20140505 Starting the embedded jetty server with the websocket servlet seems to work fine. I took some code from this example . However this line ... container.connectToServer(SocketClient.class, uri); ... throws this exception java.io.IOException: java.util.concurrent.RejectedExecutionException: org.eclipse.jetty.util.thread.NonBlockingThread@6f7476d at org.eclipse.jetty

How to use setThreadPool() in Jetty

家住魔仙堡 提交于 2019-12-01 23:53:43
I wanted to see how to use the setThreadPool() functionality. Let's say my main class is the following: import javax.servlet.SingleThreadModel; import org.eclipse.jetty.server.Server; public class FServer implements SingleThreadModel { public static void main(String[] args) throws Exception { Server server = new Server(x); server.setHandler(new Handler()); server.start(); server.join(); } } When trying to add the setThreadPool() , I'm always asked to implement abstract methods. My question is, how can I set the ThreadPool length for Jetty without being forced to use an XML configuration file,

JNDI lookup failing with Jetty for JDBC connection pooling with MySQL?

蓝咒 提交于 2019-12-01 21:22:51
I'm using Jetty 9.2 (embedded) with the standard MySQL connector API and I'm very confused by how this is supposed to be setup. Currently, I have this in my web.xml file: <webapp ... <resource-ref> <description>JDBC Data Source</description> <res-ref-name>jdbc/DataSource</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> </webapp> ...and this in my jetty-env.xml: <Configure class="org.eclipse.jetty.webapp.WebAppContext"> <New id="DatabaseConnector" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg></Arg> <Arg>jdbc/DataSource</Arg> <Arg>

Getting a 403 on root requests when using a ResourceHandler and custom handler in Jetty

无人久伴 提交于 2019-12-01 18:57:00
In (embedded) Jetty, I'm trying to use a ResourceHandler to serve static files and a custom handler to respond to dynamic requests. Based on this page I have a setup that looks like this: public static void main(String[] args) throws Exception { Server server = new Server(); SelectChannelConnector connector = new SelectChannelConnector(); connector.setPort(8080); server.addConnector(connector); ResourceHandler resource_handler = new ResourceHandler(); resource_handler.setDirectoriesListed(false); resource_handler.setResourceBase("."); HandlerList handlers = new HandlerList(); handlers

Resteasy and Google Guice: how to use multiple @ApplicationPath and resource with @Injection?

霸气de小男生 提交于 2019-12-01 16:19:17
I created a project to test the dependency injection offered by Google Guice in my Jax-rs resources, using Resteasy. My intentions are: Use multiple @ApplicationPath for the versions of my API. In each class annotated with @ApplicationPath I load a set of classes for the specific version. Each resource have a @Inject (from Google Guice) in his constructor to inject some services. I created two classes annotated with @ApplicationPath : ApplicationV1RS and ApplicationV2RS . In both I added the same resources classes ( UserResource and HelloResource ), only for my test. My Module is configured