jetty

Limiting the number of threads Compojure spawns

北城以北 提交于 2019-12-09 23:29:38
问题 I'm running compojure on Heroku. They have a limit of a 100 threads per process. So when I go over that limit, I get: java.lang.OutOfMemoryError: unable to create new native thread. Compojure is using the jetty ring adapter. Is there away of configuring the the server to only accept a hundred threads to the servlet at a time? 回答1: The solution comes from Chris Perkins over at the compojure google group. (run-jetty app {:configurator #(.setThreadPool % (QueuedThreadPool. 5))}) This initializes

使用 jetty-maven-plugin发布maven项目

亡梦爱人 提交于 2019-12-09 22:44:29
使用 jetty-maven-plugin发布maven项目 1.先去maven官方查找插件 jetty-maven-plugin 2.然后在pom.xml文件中添加如下代码: <build> <finalName>projectName</finalName> <plugins> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.3.14.v20161028</version> </plugin> </plugins> </build> 3.运行 以后 通过 http://localhost:8080 访问(默认项目名是空的,默认端口8080)。 mvn jetty:run 4. 添加项目名和端口 <build> <finalName>mvc-test</finalName> <plugins> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.3.14.v20161028</version> <configuration> <webApp> <contextPath>

maven jetty plugin

倾然丶 夕夏残阳落幕 提交于 2019-12-09 22:42:17
前言: 在 maven 下测试调试时,相比较 Tomcat 、Jboss 、Jetty 而言,个人更倾向于使用 Jetty Plugin。 怎么说呢?使用 Jetty Plugin 的时候最爽的是不用你敲打包、部署,然后再启动服务器的指令,只需敲一句:mvn jetty:run 或直接点 eclipse 上的 run 按钮就完事了。而且更爽的是,你修改资源文件,Jetty 能自动扫描到并及时给予反馈进行重加载, 这对修改java文件很有帮助,不用每次修改java文件都要重启服务器,省掉了不少没必要浪费的时间。 当然,如果想要 Jetty 跑得更理想,还需要禁止 Jetty 使用映射缓存。 环境: Maven 3.0.4 Eclipse 3.6 maven-jetty-plugin 6.1.10 项目结构: pom.xml < project xmlns ="http://maven.apache.org/POM/4.0.0" xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation ="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" > < modelVersion > 4.0.0 </

how to read a file from a lift webapp

[亡魂溺海] 提交于 2019-12-09 18:29:27
问题 I want to read xml file in my lift app: val data = XML.load(new java.io.InputStreamReader(new java.io.FileInputStream(filename), encoding)); However, I am getting java.io.FileNotFoundException . where should I put the file, and what is the correct path from my scala code? BTW - I am using embedded jetty for my testing, although I need a solution for dev env and production. 回答1: There might be better solution for other paths but there is var LiftRules.getResource : (String) ⇒ Box[URL] or def

Embedded Jetty - Programmatically add form based authentication

痴心易碎 提交于 2019-12-09 17:43:13
问题 Is there a way to programmatically add Form based Authentication as per below? I am using my own LdapLoginModule . Initially I use Basic Authentication and it worked OK, but now I want more control on the Login page (like display logo, etc) Is there any good samples? I am using embedded jetty v8.1.7 . I don't use any web.xml for embedded jetty. The jetty server is started programmatically. <login-config> <auth-method>FORM</auth-method> <realm-name>Test JAAS Realm</realm-name> <form-login

How to gracefully shutdown embeded jetty

时光毁灭记忆、已成空白 提交于 2019-12-09 16:55:19
问题 I have an application runs on an embedded jetty server. Now i want to start/stop the server as a service. I use a script to start the server. java $JAVA_OPTS -DREQ_JAVA_VERSION=$JAVA_VERSION -jar myjetty.jar Main Class Server server = new Server(); SelectChannelConnector connector = new SelectChannelConnector(); connector.setPort(PORT); server.addConnector(connector); HandlerCollection handlers = new HandlerCollection(); NCSARequestLog requestLog = new NCSARequestLog(); requestLog.setFilename

Deactivate Jetty's default 404 error handler

自作多情 提交于 2019-12-09 16:39:05
问题 I want to provide a custom 404 error page in my Spring 3.1 web application, but I cannot deactivate Jetty 8's default 404 error page. Jetty 8, out of the box, provides a default 404 error page: when visiting a Jetty-hosted website, and providing a URL path that is not handled by any servlet (e.g. by visiting http://www.example.com/nonexisting ), Jetty responses with its own default HTML error page : HTTP ERROR 404 Problem accessing /nonexisting. Reason: Not Found Powered by Jetty:// To

how to configure jetty to listen to multiple ports

风格不统一 提交于 2019-12-09 16:02:39
问题 I just want to configure jetty to listen to more than one port. I don't want multiple instances nor multiple webapps, just one jetty, one webapp, but listening to 2 or more ports. The default way does not support multiple entries: <Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set> Thank you for your help! 回答1: In your jetty.xml file, add a new connector: <!-- original connector on port 8080 --> <Call name="addConnector"> <Arg> <New class="org.eclipse.jetty.server.nio

Basic Authentication with embedded Jetty 7 server and no web.xml file

匆匆过客 提交于 2019-12-09 15:55:48
问题 I have an embedded implementation of Jetty 7 running as a service and want to add basic authentication with no web.xml file for a servlet. I created my credentials using the steps described here I thought that I could create the server, create a security handler with basic authentication and attach a HashLoginService to the security manager. But I am clearly missing several things because I am never getting prompt for credentials. Below is the code. Any help would be greatly appreciated.

Map jetty ResourceHandler to a URL

蓝咒 提交于 2019-12-09 15:49:09
问题 Is it possible using embedded Jetty to serve static files from directory X but mapped to URL Y? I have static files stored under directory "web", but I want the URL be something like http://host/myapp . I have already successfully ran a server configured with ResourceHandler in the following way: ResourceHandler ctx = new ResourceHandler(); ctx.setResourceBase("path-to-web"); HandlerList list = new HandlerList(); list.addHandler(ctx); ... server.setHandler(list); But the result is serving the