java-ee

Rest service returns 404

倾然丶 夕夏残阳落幕 提交于 2019-12-12 02:53:13
问题 What is the best practice in return codes if a call to a rest service executes a database query, no results are found and it returns. Should this be a 404 or a 200 with a message stating no records? The URL has resolved correctly and no server error has occurred just that there are no records returned. EDIT: Example url is: http://localhost/app/pr_xyz/1234 Used to retrieve a list of xyz that belong to the existing user 1234. The user id 1234 has already been retrieved and is known to exist in

Spring-security, 404 errors should be 401 or 403 in restricted folder

血红的双手。 提交于 2019-12-12 02:52:24
问题 I have this configuration in spring-security.xml : <http create-session="stateless" realm="Protected API" auto-config="true" use-expressions="true"> <intercept-url pattern="/**" access="permitAll" /> <intercept-url pattern="/api/auth/**" access="hasAnyRole('ROLE_USER','ROLE_ADMIN')" /> <intercept-url pattern="/api/auth/admin/**" access="hasRole('ROLE_ADMIN')" /> <http-basic/> </http> So any user can access to /api/mypublicservice1 . Registered users can access to /api/auth/userservice2 . And

NullPointerException when inject enterprise bean into JAX-RS 2.0 REST service

陌路散爱 提交于 2019-12-12 02:51:16
问题 I am trying to inject and EJB 3.1 in one of my RESTful services. I've followed the post: Inject an EJB into JAX-RS (RESTful service) and tried all options except building an injection provider. The current solution that I am trying uses a combination of @RequestScoped and @Inject , but my injected bean variable is still null . I have a beans.xml in the /WEB-INF folder. How can I inject an EJB into my REST service class? UserService @Local @Path("user/v1") @Produces(MediaType.APPLICATION_JSON)

Application specific logging in WildFly 9.0.1 FINAL (SL4J + Logback)

可紊 提交于 2019-12-12 02:49:56
问题 I followed some articles and tried to come with the solution by following some similar SO questions but still can't make this work - my logfile is not being created anywhere I searched for it. My goal is to have working logging bundled within the application, not use vendor specific logging. My current situation is following: I have created jboss-deployment-structure.xml inside MyEAR/META-INF directory with following content: <?xml version="1.0" encoding="UTF-8"?> <jboss-deployment-structure>

Basic SpringMvC controller not working

心已入冬 提交于 2019-12-12 02:46:51
问题 I am trying to set up a basic MVC controller project. I have created a servlet and couple of jsp pages. I can deploy the project and access the jsp pages. The problem starts when I try to use the LoginController. The error I am getting is 404 error. Please help. I have attached a screenshot of my codes and project structure. I gut instinct is the dispatcher servlet is not working the way it suppose to (just a guess). I have googled and fiddled with the code for the past 5 hours to no avail.

Difference between org/springframework/web/servlet/ModelAndView class and org/springframework/web/portlet/ModelAndView [duplicate]

两盒软妹~` 提交于 2019-12-12 02:40:45
问题 This question already has an answer here : what is the difference in org.springframework.web.servlet.ModelAndView vs org.springframework.web.portlet.ModelAndView (1 answer) Closed 4 years ago . I have just answered the below question which revolves around this posted question. spring mvc InternalResourceViewResolver doesnt get prefix Can someone out there tell the difference between the classes org/springframework/web/servlet/ModelAndView and org/springframework/web/portlet/ModelAndView I see

Java EE Singleton Scheduled Task Executed twice

半城伤御伤魂 提交于 2019-12-12 02:38:15
问题 I want to execute two tasks on scheduled time (23:59 CET and 08:00 CET). I have created an EJB singleton bean that maintains those methods: @Singleton public class OfferManager { @Schedule(hour = "23", minute = "59", timezone = "CET") @AccessTimeout(value = 0) // concurrent access is not permitted public void fetchNewOffers() { Logger.getLogger(OfferManager.class.getName()).log(Level.INFO, "Fetching new offers started"); // ... Logger.getLogger(OfferManager.class.getName()).log(Level.INFO,

Redirect from ActionListener in jSF

笑着哭i 提交于 2019-12-12 02:34:54
问题 Im used JSF and PrimeFaces. I have an ActionListener that fires when someone clicks on a MenuItem: @Override public void processAction(ActionEvent event) throws AbortProcessingException { Resource resouce = getResources().get(0); try { ResourceDelegate delegate = new ResourceDelegate(resouce, configDao); JSFUtils.writeToOutputStream(Mime.getMimeTypeForFileType(FileUtilities.getExtension(resouce.getName())), delegate.getData()); } catch(Exception e) { logger.log(Level.SEVERE, "Cant show

Isolating client-side view from the server-side controller/model using DWR

。_饼干妹妹 提交于 2019-12-12 02:34:53
问题 I had a look at DWR for hosting remote client server communication. Is there a mechanism where I can connect an html file (physically present at an external client machine) to a POJO present (physically) at the server side? My intention is to let external clients change the view but give them access to the classes defined in dwr.xml. please let me know if my intentions are not clearly put up. 回答1: Thank you Michel, for your response. Okay, I did some research and found DWR Cross domain

Does EclipseLink support ORDER BY FIELD(field, :values)

放肆的年华 提交于 2019-12-12 02:34:16
问题 MySQL supports queries such as: SELECT id FROM users WHERE id IN(3,4,8,1) ORDER BY FIELD(id, 3,4,8,1); Does EclipseLink support this query (without reverting to a native query)? When I try the following: Select id from User user where user.id in :ids ORDER BY FIELD(user.id, :ids) I receive the error: Syntax error parsing the query ... line 1, column 98: unexpected token [(]. 回答1: ORDER BY FIELD(field, :values) is not supported by JPA (JQL) or EclipseLink. JPA does provide a mechanism to