标签: embedded-jetty

如何在Mac上安装带有eclipse的jetty

我是一个新手wrt码头和RESTful API.我想使用Jetty创建REST服务,并希望在eclipse中使用嵌入式jetty.任何人都可以建议我在Mac OS中使用Eclipse安装Jetty/Jetty插件.

问候,

java eclipse jetty embedded-jetty

4
推荐指数
1
解决办法
6505
查看次数

仅从Jetty的响应标头中删除版本号

此答案解释了如何使用HttpConfiguration.setSendServerVersion(false)完全删除服务器版本标头.

有没有办法保留标题,只删除版本

我正在使用Jetty 9.

jetty embedded-jetty

4
推荐指数
1
解决办法
1970
查看次数

Spring + PostgreSQL>多个SLF4J绑定

我目前正在尝试设置Spring 4/Hibernate 4/PostgreSQL项目.当我为PostgreSQL添加JDBC驱动程序时,我得到以下异常:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/Thomas/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.7.7/8095d0b9f7e0a9cd79a663c740e0f8fb31d0e2c8/slf4j-simple-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/Thomas/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.1.2/b316e9737eea25e9ddd6d88eaeee76878045c6b2/logback-classic-1.1.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
Run Code Online (Sandbox Code Playgroud)

我的application.properties文件:

jdbc.driverClassName        = org.postgresql.Driver
jdbc.url                    = jdbc:postgresql://localhost:5432/itcareer
jdbc.username               = postgres
jdbc.password               = postgres
hibernate.dialect           = org.hibernate.dialect.PostgreSQL9Dialect
hibernate.show_sql          = true
hibernate.format_sql        = true
hibernate.hbm2ddl.auto      = update
Run Code Online (Sandbox Code Playgroud)

HibernateConfiguration.java

package at.itcareer.config;

import java.util.Properties;

import javax.sql.DataSource;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.hibernate4.HibernateTransactionManager;
import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@EnableTransactionManagement
@ComponentScan({ "at.itcareer.config" })
@PropertySource(value …
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc embedded-jetty spring-data spring-boot

4
推荐指数
1
解决办法
964
查看次数

如何从嵌入的 Jetty URL 中删除尾部斜杠?

我使用Scala中的嵌入式Jetty 9.3.8.v20160314(Scala在这里是偶然的,这是一个纯粹的Jetty问题),配置如下:

val loginService = new RepoLoginService(usersRepository, signInsRepo)

val server = new Server(8080)
server.addBean(loginService)

val security = new ConstraintSecurityHandler()
server.setHandler(security)

val constraint = new Constraint()
constraint.setName("auth")
constraint.setAuthenticate(true)
constraint.setRoles(Array[String]("user", "admin"))

val mapping = new ConstraintMapping()
mapping.setPathSpec("/*")
mapping.setConstraint(constraint)

security.setConstraintMappings(Collections.singletonList(mapping))
security.setAuthenticator(new BasicAuthenticator())
security.setLoginService(loginService)

val mapper = prepareJacksonObjectMapper

val listAccountsController = new ContextHandler("/api/accounts")
listAccountsController.setHandler(new ListAccountsController(mapper, accountsRepository))

val importBankAccountsController = new ContextHandler("/api/bank-account-transactions/import")
importBankAccountsController.setHandler(new ImportBankAccountTransactionsController(mapper, bankAccountTransactionsRepo))

val contexts = new ContextHandlerCollection()
contexts.setHandlers(Array(listAccountsController, importBankAccountsController))

security.setHandler(contexts)

server.start()
server.join()
Run Code Online (Sandbox Code Playgroud)

listAccountsController请注意:的上下文/api/accounts。当我curl时/api/accounts,我收到重定向到/api/accounts/(注意尾部斜杠):

$ curl …
Run Code Online (Sandbox Code Playgroud)

embedded-jetty jetty-9

4
推荐指数
1
解决办法
1239
查看次数

Jetty "javax.net.ssl.SSLHandshakeException: no cipher suites in common"

I've looked through similar questions on this but nothing seems to match what I'm doing or the suggested fixes work.

I've got a Jetty 9.4.0 server configured from Java (JDK 1.8.0_101) which is not accepting SSL connections from Chrome or from my own Java client. Connecting from openssl s_client works.

The reported error on the Jetty side is "javax.net.ssl.SSLHandshakeException: no cipher suites in common". Chrome reports "The client and server don't support a common SSL protocol version or cipher suite." …

java ssl https jetty embedded-jetty

4
推荐指数
1
解决办法
4685
查看次数

在嵌入式Jetty上启用TLS-1.2

目前我正在使用此代码启用TLS 1.2:

ServerConnector httpsConnector = new ServerConnector(server, 
       new SslConnectionFactory(sslContextFactory, "http/1.1"),
       new HttpConnectionFactory(https_config));
httpsConnector.setPort(8443);
httpsConnector.setIdleTimeout(50000)
Run Code Online (Sandbox Code Playgroud)

现在我正在使用TLS 1.1并希望将其更改为TLS 1.2.

embedded-jetty tls1.2

4
推荐指数
1
解决办法
4962
查看次数

org.eclipse.jetty.util.ssl.SslContextFactory$Client ClassNotFoundException 升级到 Jetty Server 9.4.16

我有一个正在使用 jetty-server version 的工作应用程序9.4.15.v20190215。由于在 jetty-server 依赖项中发现问题的漏洞扫描,我考虑升级我的应用程序以使用 jetty-server9.4.19-v20190610,这是我撰写本文时的最新版本。

我尝试再次编译应用程序,但在启动过程中出现此错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/util/ssl/SslContextFactory$Client
    at org.eclipse.jetty.websocket.client.HttpClientProvider.get(HttpClientProvider.java:49)
    at org.eclipse.jetty.websocket.client.WebSocketClient.<init>(WebSocketClient.java:261)
    at org.eclipse.jetty.websocket.jsr356.ClientContainer.<init>(ClientContainer.java:140)
    at org.eclipse.jetty.websocket.jsr356.server.ServerContainer.<init>(ServerContainer.java:94)
    at org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer.configureContext(WebSocketServerContainerInitializer.java:152)
    at it.kahoot.merlin.jetty.JettyServer.main(JettyServer.java:53)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.util.ssl.SslContextFactory$Client
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 6 more
Run Code Online (Sandbox Code Playgroud)

我了解班级 org.eclipse.jetty.util.ssl.SslContextFactory$Client再也找不到了。

我该如何进行?

java embedded-jetty websocket jetty-9

4
推荐指数
1
解决办法
3283
查看次数

如何在嵌入式Jetty中实现FileUpload?

我正在写一个包含网络服务器的Android应用程序.因此我使用Embedded Jetty(8.0.1).

我想要做的下一步是实现文件上传.

HTML看起来像这样,我认为正确:

<form action=\"fileupload\" method=\"post\" enctype=\"multipart/form-data\"> 
    <table>
        <tbody>
            <tr>
                <td><input type=\"file\" name=\"userfile1\" /></td>
            </tr>
            <tr>
                <td>
                     <input type=\"submit\" value=\"Submit\" /><input type=\"reset\" value=\"Reset\" />
                </td>
            </tr>
        </tbody>
    </table>
</form>
Run Code Online (Sandbox Code Playgroud)

当我使用这个表单时,我可以在logcat中看到我收到了一个文件但是我无法在我的Servlet中访问这个文件.

我试过了

File file1 = (File) request.getAttribute( "userfile1" );
Run Code Online (Sandbox Code Playgroud)

并具有以下功能:

request.getParameter()
Run Code Online (Sandbox Code Playgroud)

但每次我收到一个NULL对象.我该怎么办?

file-upload embedded-jetty

3
推荐指数
1
解决办法
1万
查看次数

为什么Jetty 9.x中的ServletTester如此之慢?

Jetty的ServletTester对于测试Servlet应用程序非常有用.我之前使用过Jetty 6的ServletTester,它运行得很好.

例如:

Jetty 6.x

的pom.xml

<dependency>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>jetty-servlet-tester</artifactId>
  <version>6.1.26</version>
  <scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)

SampleServletTest.java

package example;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import org.mortbay.jetty.testing.HttpTester;
import org.mortbay.jetty.testing.ServletTester;

public class SampleServletTest {

    @Test
    public void testDoGet() throws Exception {
        ServletTester tester = new ServletTester();
        tester.addServlet(SampleServlet.class, "/index");
        tester.start();

        HttpTester request = new HttpTester();
        request.setMethod("GET");
        request.setHeader("Host", "tester"); // should be "tester"
        request.setURI("/index");
        request.setVersion("HTTP/1.1");
        request.setContent("");

        String responses = tester.getResponses(request.generate());
        HttpTester response = new HttpTester();
        response.parse(responses);

        assertThat(response.getStatus(), is(equalTo(200)));
    }
}
Run Code Online (Sandbox Code Playgroud)

Jetty 9.x

ServletTester的API在Jetty 9.x中得到了很大改进.

的pom.xml …

java jetty embedded-jetty jetty-9

3
推荐指数
1
解决办法
1702
查看次数

Jetty 9:设置处理程序和连接器

我已经在架构上查看了Jetty 9的文档(http://www.eclipse.org/jetty/documentation/current/architecture.html),但我仍然对处理程序和连接器之间的关系感到困惑.

  1. 你可以将处理程序链接到特定的连接器(如果是这样,如何?连接器似乎没有setHandler方法)?

  2. 或者一切都去主处理程序,然后你从那里分配东西?(即你弄清楚它来自哪个连接器然后你把它转发给另一个处理程序或自己处理它)

非常感谢!

java jetty embedded-jetty jetty-9

3
推荐指数
1
解决办法
3004
查看次数