Tag: jersey

没有使用Spring安全性找到AuthenticationProvider

我一直在尝试使用他们的x509证书通过LDAP对用户进行身份validation,但似乎无法使用它。 我声明了一个身份validation提供程序,但我仍然收到一个错误,说没有提供程序。 这是我的调试输出: INFO: Initiating Jersey application, version ‘Jersey: 1.12 02/15/2012 04:51 PM’ DEBUG: ossecurity.web.FilterChainProxy – /x509 at position 1 of 8 in additional filter chain; firing Filter: ‘SecurityContextPersistenceFilter’ DEBUG: osswcHttpSessionSecurityContextRepository – No HttpSession currently exists DEBUG: osswcHttpSessionSecurityContextRepository – No SecurityContext was available from the HttpSession: null. A new one will be created. DEBUG: ossecurity.web.FilterChainProxy […]

这个奇怪的泽西警告意味着什么?

这个警告在泽西岛1.4中意味着什么: WARNING: A sub-resource method, public final java.lang.String com.XXX.render(), with URI template, “/”, is treated as a resource method 这是方法的外观: @GET @Produces(MediaType.APPLICATION_XML) @Path(“/”) public final String render() { return “test”; }

使用jersey获取所有html表单参数名称和值

我有一个包含这样的元素的html表单 在服务器端,我使用Jersey实现来捕获表单名称和值。 有没有办法在这样的单个地图中捕捉上述所有内容 Name1 ==> Val1 Name2 ==> Val2 Name3 ==> Val3 我知道使用@FormParam,我可以捕获变量中的表单值。 但我需要捕获表单元素名称以及值。 任何帮助表示赞赏。

处理泽西岛中不匹配的内容类型

我一直收到表格的错误: java.lang.IllegalStateException: The @FormParam is utilized when the content type of the request entity is not application/x-www-form-urlencoded 所以我试图防范这个错误,如下所示: @Path(“auth”) @Produces(MediaType.APPLICATION_JSON) public class Auth { @POST @Path(“login”) @Consumes(MediaType.WILDCARD) public Response create() { return Response.status(Status.UNSUPPORTED_MEDIA_TYPE).build(); } @POST @Path(“login”) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response create(@Valid @NotNull @FormParam(“username”) final String username, @Valid @NotNull @FormParam(“password”) final String password) { 但是,这并不能解决问题。 生成的FINE日志消息非常垃圾。 我有两个问题: […]

HK2注释未被处理

我正在通过泽西岛使用HK2,我希望得到@Immediate服务。 在这个过程中,我注意到(似乎)我的服务的所有注释都没有注册。 例如,在启动我的ServiceLocator并查看我的描述符以获取使用@Singleton注释的服务之后,它仍然设置为@PerLookup。 我的启动应用程序处理程序的代码如下: ApplicationHandler handler = new ApplicationHandler(resourceConfig, new AbstractBinder() { … }); 我的活页夹注册了这样的服务: bindAsContract(ShouldHaveSingletonScope.class); 在此之后立即查看我的ServiceLocator,我发现范围没有从类中拉出(仍然是@PerLookup)。 我需要指定一些额外的内容来告诉HK2解析类注释吗? 这似乎是一个非常标准的用例,所以我必须遗漏一些东西。

Jersey MIME类型“text / xml;找不到charset = UTF-8”的麻烦

为什么在jar包中运行程序时会出现以下exception,但在netbeans中执行时却没有得到此exception? com.sun.jersey.api.client.ClientHandlerException:Java类javax.xml.bind.JAXBElement的消息体读取器,Java类型为javax.xml.bind.JAXBElement,MIME媒体类型为text / xml; charset = UTF-没找到8 我正在使用maven和程序集插件构建我的程序。 mvn汇编:汇编 当我运行“运行文件”时,netbeans有什么不同?

如何使用Jersey的内部路由机制来提取类/方法引用?

我正在运行Jersey 1.8应用程序。 Jersey正在作为Servlet运行。 我需要编写一个给出普通请求/响应的servletfilter ,能够确定哪个REST资源/方法将响应请求并从注释中提取值。 例如,假设我有以下资源: @Path(“/foo”) @MyAnnotation(“hello”) public class FooResource { @GET @Path(“/bar”) @MyOtherAnnotation(“world”) public Response bar(){ … } } 当请求GET /foo/bar进来时,我需要我的servletfilter能够在Jersey自己的servlet处理请求之前从MyAnnotation和MyOtherAnnotation提取值”hello”和”world” 。 此filter逻辑应该能够适用于所有请求和注册的所有资源。 有没有办法访问Jersey的内部路由机制来获取Jersey将发送请求的类/方法引用? 我也对其他建议持开放态度,但理想情况下,通过自己阅读@Path注释来试图破解我自己的路由机制就没有了。

Restful webservices – NoClassDefFoundError:org / glassfish / jersey / ExtendedConfig

所以我在这个线程中创建了webservice,最后我设法解决了这个问题。 现在我正在尝试使用这个Web服务。 我在Netbeans上创建了一个新的Web项目,我正在使用Apache Tomcat。 这是使用Web服务的代码。 我已经完成了一些教程来生成这段代码。 package com.client; import java.net.URI; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import org.glassfish.jersey.client.ClientConfig; public class HelloClient { public void consumeRest(){ ClientConfig config = new ClientConfig(); Client client = ClientBuilder.newClient(config); WebTarget target = client.target(getBaseURI()); System.out.println(“response”); System.out.println(target.path(“hello”).path(“world”).request() .accept(MediaType.APPLICATION_JSON).get(Response.class) .toString()); } private URI getBaseURI() { return UriBuilder.fromUri(“http://localhost:8084/restful_example”).build(); […]

Jersey 2中的自定义MOXyJsonProvider无法正常工作?

我正在阅读Moxy的答案忽略json中的无效字段,并且方法匹配了我正在尝试做的事情,所以我决定试一试..我创建了一个function来禁用默认的ConfigurableMoxyJsonProvider; @Provider public class JsonFeature implements Feature { @Override public boolean configure(final FeatureContext context) { final String disableMoxy = CommonProperties.MOXY_JSON_FEATURE_DISABLE + ‘.’ + context.getConfiguration().getRuntimeType().name().toLowerCase(); context.property(disableMoxy, true); return true; } } 我创建了一个非常简单的自定义提供商; @Provider @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public class JsonProvider extends MOXyJsonProvider { @Override protected void preWriteTo(Object object, Class type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap httpHeaders, […]

Guice – Jersey – Servlet绑定

我最近切换到两阶段注入,这在我的servlet绑定中创建了一个错误。 我目前正在两种错误模式之间切换,不确定哪种方向最好。 我遇到的第一个错误是: com.sun.jersey.api.container.ContainerException:ResourceConfig实例不包含任何根资源类。 我的servlet模块看起来像这样: public class MyServletModule extends JerseyServletModule { @Override protected void configureServlets() { bind(MyServlet.class).asEagerSingleton(); serve(“/*”).with(GuiceContainer.class); } } 我能够通过显式提供com.sun.jersey.config.property.packages参数来删除此错误。 public class MyServletModule extends JerseyServletModule { @Override protected void configureServlets() { bind(MyServlet.class).asEagerSingleton(); Map parameters = new HashMap(); parameters.put(PackagesResourceConfig.PROPERTY_PACKAGES, MyServlet.class.getPackage().getName()); serve(“/*”).with(GuiceContainer.class, parameters); } } 但是当我这样做时,Guice会尝试一个Just in Time绑定,它不尊重我的servlet构造函数上的@Inject。 com.google.inject.ConfigurationException:Guice配置错误: 1)无法为MyServlet创建绑定。 它已经在MyServletModule.configureServlets绑定的一个或多个子注入器或私有模块上配置(MyServletModule.java:44)如果它在PrivateModule中,您是否忘记公开绑定? 在找到MyServlet时 com.google.inject.internal.InjectorImpl.getBinding上的1个错误(InjectorImpl.java:150) 我的servlet有一个@Inject构造函数,它的参数不能及时绑定。 在调试InjectorImpl之后,我相信当我使用PROPERTY_PACKAGES时这就是失败的原因。 我只是不确定使用PROPERTY_PACKAGES是否正确,我需要修复一些绑定? […]