我使用 Jetty 9.4.8,我想限制可以发布到服务器的数据量。为此,我添加到 jetty.xml:
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.Request.maxFormContentSize</Arg>
<Arg>10000</Arg>
</Call>
Run Code Online (Sandbox Code Playgroud)
我测试了码头,如(request-xxlarge.xml - 文本文件(20mb)):
curl -X POST --data @request-xxlarge.xml http://localhost:8080/test -v
Run Code Online (Sandbox Code Playgroud)
结果我得到了
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST /test HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.47.0
> Accept: */*
> Content-Length: 21232818
> Content-Type: application/x-www-form-urlencoded
> Expect: 100-continue
>
< HTTP/1.1 200 OK
< Content-Length: 4
< Connection: close
< Server: Jetty(9.4.8.v20171121)
<
* Closing connection 0
POST
Run Code Online (Sandbox Code Playgroud)
服务器处理了请求
编辑
当 Content-Type: application/x-www-form-urlencoded 时,服务器返回 413。 …
我想在我的测试用例中使用嵌入的 Jetty 9 (v9.2.12.v20150709)。但我无法以编程方式更改 HTTP-Session-Timeout。
这个电话webapp.getSessionHandler().getSessionManager().setMaxInactiveInterval(timeoutInSeconds);好像打不通。
这是减少的代码段,它显示了我所做的:
import java.io.IOException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
@SuppressWarnings("javadoc")
public class EmbeddedJetty
{
@SuppressWarnings("serial")
public static class TimeoutServlet extends HttpServlet
{
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException
{
// return the value of the currently used HTTP-Session Timeout
response.setContentType("text/html");
response.setStatus(HttpServletResponse.SC_OK);
response.getWriter().println("<h1>Timeout: " + request.getSession()
.getMaxInactiveInterval() + "</h1>");
}
}
public static void main(String[] args) throws Exception
{
// the custom …Run Code Online (Sandbox Code Playgroud) 我们将 Spring-Boot (2.7.x) 与 Jetty 结合使用。我们的依赖项扫描器告诉我们,我们的依赖项树中仍然有 Tomcat 依赖项。
在查看 spring-boot-starter-jetty 2.7.1 的 POM 时,我发现 spring-boot-starter-jetty 依赖于 tomcat-embed-el。tomcat-embed-el 包含 javax.el 和 org.apache.el 包中的类,所以我认为这是 Tomcat 的 Expression-Language-Parser 实现?
有人知道为什么吗?我下载了相同版本的Standalone-Jetty,但它没有这个tomcat库。
请参阅此处的依赖项https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-jetty/2.7.1
我即将开始使用一个新的linode VPS服务器.我目前使用Tomcat和Jetty(在我的开发服务器上)为不同的Solr提供服务,但是我已经读了一下我意识到Tomcat可能是一个非常资源的人,因此建议我用Jetty.我已经在Jetty1/webapps/ROOT /中设置了一个带有应用程序的Jetty开发服务器
这是我的问题:
1)在同一个Jetty服务器中运行2个solr实例是否更好
要么
2)我应该运行两个不同的Jetty服务器(端口8080,8081都可以使用,因为它们仅用于Web服务)
以上哪项资源密集程度较低?
老实说,我的偏好是2),运行2个不同的jetty服务器,因为要让一个Jetty服务器运行多个solr实例需要做很多工作,因为我已经在Jetty1/solr中运行了一个应用程序/ home并且必须重新设置它,包括适应多个实例.这方面的教程也没有多少.
另外,我在Tomcat中设置了另一个Solr实例.我可以将索引复制并粘贴到Jetty2/solr中,索引是否正常工作,还是需要在Jetty中重新索引它们?
干杯
柯
我使用独立版本的Archiva,它使用Jetty作为其应用程序容器.它默认为http://mycompany.com:8080/archiva我想摆脱应用程序上下文,只是使它可以http://mycompany.com:8080/使我在Apache 2.2.x中使用虚拟主机将其映射到子域.
我无法弄清楚配置文件中要更改的内容.这是一个jetty.xml文件,其中包含所有注释以简洁起见.
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure id="Server" class="org.mortbay.jetty.Server">
<!-- =========================================================== -->
<!-- Server Thread Pool -->
<!-- =========================================================== -->
<Set name="ThreadPool">
<!-- Default bounded blocking threadpool
-->
<New class="org.mortbay.thread.BoundedThreadPool">
<Set name="minThreads">10</Set>
<Set name="maxThreads">250</Set>
<Set name="lowThreads">25</Set>
</New>
</Set>
<Call name="addConnector">
<Arg>
<New class="org.mortbay.jetty.nio.SelectChannelConnector">
<Set name="host"><SystemProperty name="jetty.host"/></Set>
<Set name="port"><SystemProperty name="jetty.port" default="8081"/></Set>
<Set name="maxIdleTime">30000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
<Set name="confidentialPort">8443</Set>
<Set name="lowResourcesConnections">5000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
</New>
</Arg>
</Call>
<Set name="handler"> …Run Code Online (Sandbox Code Playgroud) 我正在尝试让Maven自动下载jetty-start的所有依赖项,所以我运行这个:
java start.jar etc/jetty.xml
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时:
java start.jar --list-options
Run Code Online (Sandbox Code Playgroud)
我得到几个缺少的模块,我必须手动添加为我的Maven文件的依赖项.我试着加入他们,我会被卡住在寻找一个合适的版本servlet-api将提供javax.servlet.http.HttpServletResponse,即使下载了罐子jetty-servlet有javax/servlet/http/HttpServletResponse.class它里面.这是错误:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.jetty.start.Main.invokeMain(Main.java:457)
at org.eclipse.jetty.start.Main.start(Main.java:602)
at org.eclipse.jetty.start.Main.main(Main.java:82)
Caused by: java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletResponse
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.newInstance0(Class.java:326)
at java.lang.Class.newInstance(Class.java:308)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:333)
at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:291)
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1203)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1138)
... 7 more
Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServletResponse
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 17 more …Run Code Online (Sandbox Code Playgroud) 我正在使用maven-jetty-plugin来快速运行和调试我在Eclipse/m2eclipse下开发的WebApp.它开始正常,我可以完全使用调试器,但我不能优雅地停止应用程序.
当我在控制台视图中执行ctrl + c时它虽然在启动器配置中启用了"allocate console",但它什么也没做.
在简单的java项目中,ctrl + c选项工作正常(在Windows上测试).所以它似乎是一些远程/嵌入式jvm问题.我的应用程序使用持久性JMS队列,因此每次重启后我都需要手动终止其他服务器上的会话.这不是很敏捷.
任何人都知道问题的根源是什么?或者也许有一些已知的解决方法?
我正在尝试使用Jetty 9 Maven插件来创建JNDI资源.相同的配置适用于Jetty 8,但产生了java.lang.IllegalStateException: No suitable constructorJetty 9.以下是相关文件:
pom.xml中:
<?xml version="1.0"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>jetty-jndi</artifactId>
<version>1.0</version>
<build>
<plugins>
<plugin>
<!-- <groupId>org.mortbay.jetty</groupId>
<version>8.1.9.v20130131</version> -->
<groupId>org.eclipse.jetty</groupId>
<version>9.0.0.RC0</version>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<webAppConfig>
<jettyEnvXml>src/test/resources/jetty-ds-dev.xml</jettyEnvXml>
</webAppConfig>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.2.9</version>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
的src /测试/资源/码头-DS-dev.xml:
<?xml version="1.0"?>
<Configure id="Server" class="org.eclipse.jetty.webapp.WebAppContext">
<New id="DSTest" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg>jdbc/test</Arg>
<Arg>
<New class="org.hsqldb.jdbc.JDBCDataSource">
<Set name="DatabaseName">mem:foo</Set>
<Set name="User">SA</Set>
</New>
</Arg>
</New>
</Configure>
Run Code Online (Sandbox Code Playgroud)
和实际的错误:
2013-02-20 10:22:23.464:WARN:oejx.XmlConfiguration:main: Config error at <New id="DSTest" class="org.eclipse.jetty.plus.jndi.Resource">|??<Arg>jdbc/test</Arg>|??<Arg>|???<New class="org.hsqldb.jdbc.JD …Run Code Online (Sandbox Code Playgroud) 所以我在Jetty上部署了一个Web应用程序.让我们说war文件是hello.war.对于我在我自己的机器上访问Web应用程序,我需要去,http://127.0.0.1/hello但我希望该Web应用程序"监听" http://127.0.0.1而不将Apache放在Jetty前面.
通过eclipse插件启动应用程序时出现以下异常:“运行方式”>“带有码头的GWT开发模式”
环境:
-GWT
SDK 2.8-
春季启动1.5.3.RELEASE-
码头9.4.4
-GWT Eclipse插件3.0.0
堆栈跟踪:
11:50:51,971 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
11:50:51,971 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
11:50:51,971 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@4c292313 - Registering current configuration as safe fallback point
Loading Java files in com.mycompany.fonems.webapp.Fonemswebapp.
Ignored 1 unit with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
Module setup completed in 6335 ms
The code server …Run Code Online (Sandbox Code Playgroud)