Search Results

Search found 174 results on 7 pages for 'jersey'.

Page 2/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • Jersey, Spring, Tomcat and Security Annotations

    - by jr
    I need to secure a simple jersey RESTful API in a Tomcat 6.0.24 container. I'd like to keep the authentication with Basic Authentication using the tomcat-users.xml file to define the users and roles (this is for now, like I said its small). Now, for authorization I'd like to be able to use the JSR 250 annotations like @RolesAllowed, @PermitAll, @DenyAll, etc. I cannot for the life of me figure out how to wire this all up together. I really don't want to go spring-security route, since I need something very simple at the current time. Can someone point me in the right direction.

    Read the article

  • Jersey, Apache HTTPD, and javax.annotation.security usage

    - by Nick Klauer
    So I'm having a heck of a time trying to piece together what I think is a pretty simple implementation. This is very similar to another StackOverflow question only I can't leverage Tomcat to handle role based authentication. I have an Apache httpd server in front of my app that handles authentication and then passes LDAP roles to a Jersey service through Headers. I've created a servlet filter to parse the header and tease out the roles the request came from, which works fine globally to the app, but isn't fine-grained enough to dictate what an Admin could do that a User could not. I'm thinking I could use the javax.annotation.security annotations that JAX-RS supports, but I don't know how to take what I've parsed out using a servlet filter to set or instantiate the SecurityContext necessary for the roles @RolesAllowed.

    Read the article

  • Jersey (Jax-RS) & EL

    - by smeg4brains
    Hi there! im trying to get a controller to return a view through a Expression Language-Filter, but have no idea on how to get jersey to use EL for filtering a view. View with EL-tags: <html> <title>%{msg}</title> </html> Controller: @GET @Produces("text/html") public Response viewEventsAsHtml(){ String view=null; try { view=getViewAsString("events"); }catch(IOException e){ LOG.error("unable to load view from file",e); return null; } Response.ResponseBuilder builder=Response.ok(view, MediaType.TEXT_HTML); return builder.build(); } How would one go about in order to get the controller to replace the ${msg} part in the view by some arbitrary value?

    Read the article

  • Java Jersey RESTful services

    - by pHk
    Rather new to REST and Jersey, and I'm trying out some basic examples. I've got one particular question though, which I haven't really found an answer for yet (don't really know how to look for this): how would you go about storing/defining common services so that they are stateful and accessible to all/some resources? For instance, a logger instance (Log4J or whatever). Do I have to manually initialize this and store it in the HttpSession? Is there a "best practice" way of doing this so that my logger is accessible to all/some resources? Thanks a lot.

    Read the article

  • Jersey 1.8 - Another GlassFish 3.1.1 component is ready

    - by alexismp
    We now have a new release of the JAX-RS 1.1 reference implementation - Jersey 1.8 is just out! Thisbug-fix release follows the EclipseLink 2.3 release from last week (as part of the Eclipse Indigo train release) and other components such as Woodstox 4.1.1 and Weld 1.1.1 which have already been released and integrated. To get started with Jersey 1.8, begin here and don't forget to visit the Jersey Wiki pages. You can also grab a nightly build of GlassFish 3.1.1 or wait for the next promoted build (#10) due out in a few days. As it currently stands for GlassFish 3.1.1, we have integration of the final bits for Metro 2.1.1 (currently at 2.1.1b7), Mojarra 2.1.3 (currently at 2.1.3b1), and MQ 4.5.1 (currently at 4.5.1b3) still ahead of us.

    Read the article

  • gwt-hosted mode when I am using jersey services

    - by Bhagyashree
    I am doing my project in GXT and using jersey services. I am trying to run that application in hosted mode.I have used -noserver option here. But still when I am trying to run the application in hosted mode it's giving me 'Error Response: 0' from the server side. According to me it's not able to find the server side in the tomcat. What must be the problem? Please someone give me the solution for the same. Thanks. -Bhagyashree

    Read the article

  • Jersey 2.0 Milestone 2 Now Available

    - by arungupta
    Jersey 2.0 milestone 2 is now available. It builds upon the first milestone and adds several new features such as server-side asynchronous processing, server-side content negotiation, improved JAX-RS parameter injection, and several others. The REST endpoints can be published on Java SE HTTP Server, Grizzly 2 HTTP container, and some basic Servlet-based deployments. It also provides HTTPURLConnection-based client API implementation. Read about these and more about what's new in Marek's detailed post. Of course this is also the future reference implementation for JAX-RS 2.0. Feel like trying it out? Simply go to Maven Central (of course none of this is production quality at this point). The latest JAX-RS Javadocs and Jersey 2.0 API docs are good starting points to explore. And provide them feedback at [email protected].

    Read the article

  • Centralized way of organizing urls in Jersey?

    - by drozzy
    Forgive me if I am asking an obvious question (maybe I missed it in the docs somewhere?) but has anyone found a good way to organize their URLs in Jersey Java framework? I mean organizing them centrally in your Java source code, so that you can be sure there are not two classes that refer to the same Url. For example django has a really nice regex-based matching. I was thinking of doing something like an enum: enum Urls{ CARS ("cars"), CAR_INFO ("car", "{info}"); public Urls(String path, String args) ... } but you can imagine that gets out of hand pretty quickly if you have urls like: cars/1/wheels/3 where you need multiple path-ids interleaved with one another... Any tips?

    Read the article

  • @Path and regular expression (Jersey/REST)

    - by Castanho
    Hi there! I'm using Jersey in a REST project and I'm needing to use regular expression. Digging about it is simple like: @Path("/resources) public class MyResource { @GET @Path("{subResources:.*}/bar") public String get() {...} } But, I'm only capable of using regex if in my @Path contains a variable or text value, example: @Path("{SubResource1}/{subResources:.*}/bar") Or @Path("hardCodeString/{subResources:.*}/bar") Today I could run with this solution of a variable, but is not oK for my perspective. Question Does anyone have worked with something related? I'm doing something wrong? I think that this could be a bug, when working with more then one @Path, one in the Class and other in the Method. Any tips is appreciated! Regards

    Read the article

  • Flex 4 front end connecting to Java Jersey Web Service

    - by user305801
    I created a Java REST service using Jersey. I use three of the HTTP "verbs" GET, POST and DELETE. I want to create several prototype front ends for the service. After much research, a lot dating to 2008 and 2009, I have been unable to find anything remotely simple. My three options are: 1) resthttpservice. This project hasn't been updated in a year. The only activity are one off suggestions that individual users have implemented. http://code.google.com/p/resthttpservice/ 2) Create an AIR application. This isn't unfeasible. 3) Writing my own socket level code but there is a security restriction with flash players and I need to implement a policy server. I have already read the question posted about asking whether using Flex for REST services were worth it. That information is old as well. I want to introduce REST services to my company but Flex's limited support for HTTP PUT and DELETE are discouraging. My service also uses the Accept header to determine if JSON or XML will be returned to the client. I can't seem to change HTTP headers without doing socket programming. I'm fine with that but the security policy thing is annoying. Is there an easy way to use Flex 4 with RESTful services that uses PUT/DELETE and the Accept HTTP header? Please help. I'm very frustrated.

    Read the article

  • When to use @Singleton in a Jersey resource

    - by dexter
    I have a Jersey resource that access the database. Basically it opens a database connection in the initialization of the resource. Performs queries on the resource's methods. I have observed that when I do not use @Singleton, the database is being open at each request. And we know opening a connection is really expensive right? So my question is, should I specify that the resource be singleton or is it really better to keep it at per request especially when the resource is connecting to the database? My resource code looks like this: //Use @Singleton here or not? @Path(/myservice/) public class MyResource { private ResponseGenerator responser; private Log logger = LogFactory.getLog(MyResource.class); public MyResource() { responser = new ResponseGenerator(); } @GET @Path("/clients") public String getClients() { logger.info("GETTING LIST OF CLIENTS"); return responser.returnClients(); } ... // some more methods ... } And I connect to the database using a code similar to this: public class ResponseGenerator { private Connection conn; private PreparedStatement prepStmt; private ResultSet rs; public ResponseGenerator(){ Class.forName("org.h2.Driver"); conn = DriverManager.getConnection("jdbc:h2:testdb"); } public String returnClients(){ String result; try{ prepStmt = conn.prepareStatement("SELECT * FROM hosts"); rs = prepStmt.executeQuery(); ... //do some processing here ... } catch (SQLException se){ logger.warn("Some message"); } finally { rs.close(); prepStmt.close(); // should I also close the connection here (in every method) if I stick to per request // and add getting of connection at the start of every method // conn.close(); } return result } ... // some more methods ... } Some comments on best practices for the code will also be helpful.

    Read the article

  • Returning JSON or XML for Exceptions in Jersey

    - by Dominic
    My goal is to have an error bean returned on a 404 with a descriptive message when a object is not found, and return the same MIME type that was requested. I have a look up resource, which will return the specified object in XML or JSON based on the URI (I have setup the com.sun.jersey.config.property.resourceConfigClass servlet parameter so I dont need the Accept header. My JAXBContextResolver has the ErrorBean.class in its list of types, and the correct JAXBContext is returned for this class because I can see in the logs). eg: http://foobar.com/rest/locations/1.json @GET @Path("{id}") @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Location getCustomer(@PathParam("id") int cId) { //look up location from datastore .... if (location == null) { throw new NotFoundException("Location" + cId + " is not found"); } } And my NotFoundException looks like this: public class NotFoundException extends WebApplicationException { public NotFoundException(String message) { super(Response.status(Response.Status.NOT_FOUND). entity(new ErrorBean( message, Response.Status.NOT_FOUND.getStatusCode() ) .build()); } } The ErrorBean is as follows: @XmlRootElement(name = "error") public class ErrorBean { private String errorMsg; private int errorCode; //no-arg constructor, property constructor, getter and setters ... } However, I'm always getting a 204 No Content response when I try this. I have hacked around, and if I return a string and specify the mime type this works fine: public NotFoundException(String message) { super(Response.status(Response.Status.NOT_FOUND). entity(message).type("text/plain").build()); } I have also tried returning an ErrorBean as a resource. This works fine: {"errorCode":404,"errorMsg":"Location 1 is not found!"}

    Read the article

  • ResourceFilterFactory and non-Path annotated Resources

    - by tousdan
    (I'm using Jersey 1.7) I am attempting to add a ResourceFilterFactory in my project to select which filters are used per method using annotations. The ResourceFilterFactory seems to be able to filters on Resources which are annotated with the Path annotation but it would seem that it does not attempt to generate filters for the methods of the SubResourceLocator of the resources that are called. @Path("a") public class A { //sub resource locator? @Path("b") public B getB() { return new B(); } @GET public void doGet() {} } public class B { @GET public void doOtherGet() { } @Path("c") public void doInner() { } } When ran, the Filter factory will only be called for the following: AbstractResourceMethod(A#doGet) AbstractSubResourceLocator(A#getB) When I expected it to be called for every method of the sub resource. I'm currently using the following options in my web.xml; <init-param> <param-name>com.sun.jersey.spi.container.ResourceFilters</param-name> <param-value>com.my.MyResourceFilterFactory</param-value> </init-param> <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>com.my.resources</param-value> </init-param> Is my understanding of the filter factory flawed?

    Read the article

  • JSON Formatting with Jersey, Jackson, & json.org/java Parser using Curl Command

    - by socal_javaguy
    Using Java 6, Tomcat 7, Jersey 1.15, Jackson 2.0.6 (from FasterXml maven repo), & www.json.org parser, I am trying to pretty print the JSON String so it will look indented by the curl -X GET command line. I created a simple web service which has the following architecture: My POJOs (model classes): Family.java import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class Family { private String father; private String mother; private List<Children> children; // Getter & Setters } Children.java import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class Children { private String name; private String age; private String gender; // Getters & Setters } Using a Utility Class, I decided to hard code the POJOs as follows: public class FamilyUtil { public static Family getFamily() { Family family = new Family(); family.setFather("Joe"); family.setMother("Jennifer"); Children child = new Children(); child.setName("Jimmy"); child.setAge("12"); child.setGender("male"); List<Children> children = new ArrayList<Children>(); children.add(child); family.setChildren(children); return family; } } My web service: import java.io.IOException; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jettison.json.JSONException; import org.json.JSONObject; import org.json.JSONTokener; import com.myapp.controller.myappController; import com.myapp.resource.output.HostingSegmentOutput; import com.myapp.util.FamilyUtil; @Path("") public class MyWebService { @GET @Produces(MediaType.APPLICATION_JSON) public static String getFamily() throws IOException, JsonGenerationException, JsonMappingException, JSONException, org.json.JSONException { ObjectMapper mapper = new ObjectMapper(); String uglyJsonString = mapper.writeValueAsString(FamilyUtil.getFamily()); System.out.println(uglyJsonString); JSONTokener tokener = new JSONTokener(uglyJsonString); JSONObject finalResult = new JSONObject(tokener); return finalResult.toString(4); } } When I run this using: curl -X GET http://localhost:8080/mywebservice I get this in my Eclipse's console: {"father":"Joe","mother":"Jennifer","children":[{"name":"Jimmy","age":"12","gender":"male"}]} But from the curl command on the command line (this response is more important): "{\n \"mother\": \"Jennifer\",\n \"children\": [{\n \"age\": \"12\",\n \"name\": \"Jimmy\",\n \"gender\": \"male\"\n }],\n \"father\": \"Joe\"\n}" This is adding newline escape sequences and placing double quotes (but not indenting like it should it does have 4 spaces after the new line but its all in one line). Would appreciate it if someone could point me in the right direction.

    Read the article

  • Unable to set cookie in response header (newcookie doesn't show in external browser) : Jersey jax-rs

    - by Pankhuri
    I am trying to set a session cookie from server side : import javax.ws.rs.core.NewCookie; import javax.ws.rs.core.Response; public class Login { @POST @Produces("application/json") @Consumes("application/json") public Response login (String RequestPacket){ NewCookie cookie=null; CacheControl cc=new CacheControl(); cookie = LoginBO.validUser(RequestPacket); cc.setNoCache(true); if(cookie.getValue()!=null) return Response.ok("welcome "+cookie.getValue()).cookie(cookie).cacheControl(cc).build(); else return Response.status(404).entity("Invalid User").build(); } } In eclipse browser: on the client side (using gxt for that) when I print header i get the Set-Cookie field. which is expected. But the browser is not storing the cookie. in external browser: the header doesn't have any set-cookie field. Should I use HTTPServletResponse? But shouldn't the javax.ws.rs.core.Response work as well?

    Read the article

  • How to pass a very long string/file into RESTWebservice JAX-RS Jersey

    - by Sashikiran Challa
    Hello All, I am trying to write a webservice that takes in an XML string, does parsing of it using DOM and extract particular things I want. My XML string happens to be very long so I do not want to pass it as a @QueryParam or @PathParam. Say If I write that XML string into a file, How do I go about writing a RESTful service that takes in this file, extracts whatever I want and return the results. I am actually trying to extract some number of strings, so my output should probably be an ArrayList having all these strings. Could somebody please shed some light on how I should go about doing this. Thanks in advance

    Read the article

  • Java REST implementation: Jersey vs CXF

    - by dexter
    What do you think is the advantages/disadvantages between this two libraries? Which of these two are best suited for production environment? By the way I will be using JSON instead of XML. I also would like to know what library is most supported by the community e.g. tutorials, documentation.

    Read the article

  • Jersey, JAXB and getting an objectextending an abstract class as a parameter

    - by krajol
    I want to get an object as a parameter of a POST request. I got an abstract superclass that is called Promotion and subclasses Product and Percent. Here's how I try to get a request: @POST @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_XML) @Path("promotion/") public Promotion createPromotion(Promotion promotion) { Product p = (Product) promotion; System.out.println(p.getPriceAfter()); return promotion; } and here's how I use JAXB in classes' definitions: @XmlRootElement(name="promotion") @XmlSeeAlso({Product.class,Percent.class}) public abstract class Promotion { //body } @XmlRootElement(name="promotion") public class Product extends Promotion { //body } @XmlRootElement(name="promotion") public class Percent extends Promotion { //body } So the problem now is when I send a POST request with a body like this: <promotion> <priceBefore>34.5</priceBefore> <marked>false</marked> <distance>44</distance> </promotion> and I try to cast it to Product (as in this case, fields 'marked' and 'distance' are from Promotion class and 'priceBefore' is from Product class) I get an Exception: java.lang.ClassCastException: Percent cannot be cast to Product. It seems like Percent is chosen as a 'default' subclass. Why is that and how can I get an object that is a Product?

    Read the article

  • Building Website with JAX-RS (Jersey)

    - by 0xMG
    Is it discouraged/not-common to build Websites (not web-services!) using Jersey or any other JAX-RS implementation ? I didn't find any guide/tutorial/article regarding that.. At first impression , it seems to me that building website using Jersey (with JSPs as Viewables) is easier and more efficient than using Servlets & JSPs. If anyone did it before , I will be pleased to get tips, Do's & Don'ts, best practices etc... And maybe a good tutorial.

    Read the article

  • Glassfish4 throw exception when I declare validation.xml file on classpath

    - by Rafael Ruiz Tabares
    I've tried to declare a custom validator for @NotNull constraint and Glassfish4 throw this exception when find /META-INF/validation.xml. Project works fine if I omit this file. Exception while dispatching an event java.lang.IllegalStateException: Singleton not set for WebappClassLoader(delegate=true; repositories=WEB-INF/classes/) at org.glassfish.weld.ACLSingletonProvider$ACLSingleton.get(ACLSingletonProvider.java:110) at org.jboss.weld.Container.instance(Container.java:54) at org.jboss.weld.bootstrap.WeldBootstrap.shutdown(WeldBootstrap.java:644) at org.glassfish.weld.WeldDeployer.doBootstrapShutdown(WeldDeployer.java:309) at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:220) at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131) at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:328) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:493) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219) at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491) at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527) at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:356) at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423) at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674) at org.glassfish.admin.rest.resources.admin.CommandResource.executeCommand(CommandResource.java:396) at org.glassfish.admin.rest.resources.admin.CommandResource.execCommandSimpInMultOut(CommandResource.java:234) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:125) at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:152) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:91) at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:346) at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:341) at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:101) at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:224) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.process(Errors.java:267) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:198) at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:946) at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:331) at org.glassfish.admin.rest.adapter.JerseyContainerCommandService$3.service(JerseyContainerCommandService.java:165) at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:181) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:246) at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191) at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168) at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189) at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544) at java.lang.Thread.run(Thread.java:744) ]] [2014-06-09T19:37:52.476+0200] [glassfish 4.0] [SEVERE] [AS-WEB-CORE-00108] [javax.enterprise.web.core] [tid: _ThreadID=32 _ThreadName=admin-listener(1)] [timeMillis: 1402335472476] [levelValue: 1000] [[ ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener at org.apache.catalina.core.StandardContext.start(StandardContext.java:5864) at com.sun.enterprise.web.WebModule.start(WebModule.java:691) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747) at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2278) at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1924) at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139) at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122) at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291) at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:497) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219) at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491) at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527) at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:356) at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423) at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674) at org.glassfish.admin.rest.resources.admin.CommandResource.executeCommand(CommandResource.java:396) at org.glassfish.admin.rest.resources.admin.CommandResource.execCommandSimpInMultOut(CommandResource.java:234) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:125) at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:152) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:91) at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:346) at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:341) at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:101) at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:224) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.process(Errors.java:267) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:198) at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:946) at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:331) at org.glassfish.admin.rest.adapter.JerseyContainerCommandService$3.service(JerseyContainerCommandService.java:165) at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:181) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:246) at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191) at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168) at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189) at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544) at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener at org.apache.catalina.core.StandardContext.addListener(StandardContext.java:3270) at org.apache.catalina.core.StandardContext.addApplicationListener(StandardContext.java:2476) at com.sun.enterprise.web.TomcatDeploymentConfig.configureApplicationListener(TomcatDeploymentConfig.java:251) at com.sun.enterprise.web.TomcatDeploymentConfig.configureWebModule(TomcatDeploymentConfig.java:110) at com.sun.enterprise.web.WebModuleContextConfig.start(WebModuleContextConfig.java:266) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:486) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:163) at org.apache.catalina.core.StandardContext.start(StandardContext.java:5861) ... 66 more Caused by: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener at org.apache.catalina.core.StandardContext.createListener(StandardContext.java:3391) at org.apache.catalina.core.StandardContext.loadListener(StandardContext.java:5414) at com.sun.enterprise.web.WebModule.loadListener(WebModule.java:1788) at org.apache.catalina.core.StandardContext.addListener(StandardContext.java:3268) ... 73 more Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:329) at com.sun.enterprise.web.WebContainer.createListenerInstance(WebContainer.java:1015) at com.sun.enterprise.web.WebModule.createListenerInstance(WebModule.java:2158) at org.apache.catalina.core.StandardContext.createListener(StandardContext.java:3389) ... 76 more Caused by: java.lang.NullPointerException at org.jboss.weld.bootstrap.WeldBootstrap.getManager(WeldBootstrap.java:435) at org.glassfish.weld.services.JCDIServiceImpl.createManagedObject(JCDIServiceImpl.java:320) at org.glassfish.weld.services.JCDIServiceImpl.createManagedObject(JCDIServiceImpl.java:263) at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.createManagedBean(ManagedBeanManagerImpl.java:485) at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.createManagedBean(ManagedBeanManagerImpl.java:439) at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:313) ... 79 more This is constraint xml file <constraint-definition annotation="org.hibernate.validator.constraints.NotNull"> <validated-by include-existing-validators="true"> <value>es.project.validator.customConstraint.NotEmptyValidator</value> </validated-by> </constraint-definition> And validation.xml <validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration" xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <constraint-mapping>META-INF/validation/mapping.xml</constraint-mapping> Project's structure WEB-INF +----\classes +-------\META-INF ------- validation.xml ----------\validation +----------\mapping.xml Validator code import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; import javax.validation.constraints.NotNull; import org.hibernate.validator.constraintvalidation.HibernateConstraintValidatorContext; public class NotEmptyValidator implements ConstraintValidator<NotNull,Object> { @Override public void initialize(NotNull constraintAnnotation) { } @Override public boolean isValid(Object value, ConstraintValidatorContext context) { if(value.toString().isEmpty()){ ........... ........... ........... } return true; } }

    Read the article

  • How can I emulate forward on 404 in jersey?

    - by koppor
    I have a picture on a given URL. The picture might need a referesh. I want to do the freshness-check at the time of the request. Therefore, I coded a jersey resource handling the request on the picture URL. It refreshes the picture on the filesystem if necessary. I do not want to re-code a caching mechansim, but rely on tomcat's implementation. Therefore, I would like to "forward" the request in the internal handler chain. I tried return new Viewable(sb.toString());, but a viewable is not a picture. What return type can I use? I could let the concrete picture reside on another URL and send a 307 (Temporary Redirect). Always sending that as answer seems odd to me. Related question: How to return a PNG image from Jersey REST service method to the browser

    Read the article

  • Beyond the @Produces annotation, how does Jersey (JAX-RS) know to treat a POJO as a specific mime ty

    - by hal10001
    I see a lot of examples for Jersey that look something like this: public class ItemResource { @GET @Path("/items") @Produces({"text/xml", "application/json"}) public List<Item> getItems() { List<Item> items = new ArrayList<Item>(); Item item = new Item(); item.setItemName("My Item Name!"); items.add(item); return items; } } But then I have trouble dissecting Item, and how Jersey knows how to translate an Item to either XML or JSON. I've seen very basic examples that just return a String of constructed HTML or XML, which makes more sense to me, but I'm missing the next step. I looked at the samples, and one of them stood out (the json-from-jaxb sample), since the object was marked with these types of annotations: @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "flight" }) @XmlRootElement(name = "flights") I'm looking for tutorials that cover this "translation" step-by-step, or an explanation here of how to translate a POJO to output as a specific mime type. Thanks!

    Read the article

  • RESTful resource not found. 404 or 204? Jersey returns 204 on null being returned from handler.

    - by jr
    If you are looking for /Resource/Id and that resource does not exist, I had always though that 404 was the appropriate response. However, when returning "null" from a Jersey handler, I get back a "204 No Content". I can likely work with either one, but am curious to others thoughts on this. To answer my own next question. To get jersey to return 404 you must throw an exception. if (a == null) throw new WebApplicationException(404);

    Read the article

  • Jersey message body reader not found in maven-built JAR

    - by Olvagor
    My application uses a REST (JAX-RS Jersey) interface. When I run it in Eclipse, everything' s fine. The domain objects are annotated, I'm not using XML files for the REST mapping. Now I created a standalone JAR using the maven-assembly-plugin, which packs the application and all dependencies in a single, executable JAR file. This also seems to work. But when I start the application and request an object from the server, Jersey complains, that it can't find a message body reader: com.sun.jersey.api.client.ClientHandlerException: A message body reader for Java type, class de.rybu.atuin.core.entity.User, and MIME media type, application/json, was not found Any ideas why this happens? EDIT: After I slept a night over it, I noticed that it complains about JSON... but I'm using only XML for serialization. Strange.

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >