java-ee-7

Cannot Cancel @Asynchronous call to EJB

寵の児 提交于 2019-12-04 06:38:47
问题 What am I doing wrong in this simplest of examples? (Glassfish 4.0-b87 + Eclipse Kepler m6) Myself.java package com.example.cancelbug; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.ejb.Singleton; import javax.ejb.Startup; import javax.inject.Inject; @Singleton @Startup public class Myself { @Inject Other other; private Future < Integer > future; @PostConstruct public

JSF is unable to find resources in sub-folders

佐手、 提交于 2019-12-04 06:10:20
问题 I have a Javaee7, JSF2 web app running in Glassfish 4.0 using maven. I have all of my resources in my /src/main/webapp/resources folder, but because I am using a framework, they are sometime nested in multiple subfolders, (i.e. resources/theme/plugin/bootstrap/script.js ). The CSS, JS and image files that are stored one directory below the resources folder (i.e. resources/theme/custom.css ) would load fine with this code: <h:outputScript library="theme" name="custom.js" /> But if I try to

Warning: JACC: For the URL pattern xxx, all but the following methods were uncovered: POST, GET

不羁岁月 提交于 2019-12-04 05:06:28
In javax.faces.webapp.FacesServlet docs, it is mentioned, Allowable HTTP Methods The JSF specification only requires the use of the GET and POST http methods. If your web application does not require any other http methods, such as PUT and DELETE, please consider restricting the allowable http methods using the <http-method> and <http-method-omission> elements. Please see the Security of the Java Servlet Specification for more information the use of these elements. My application indeed does not depend upon other HTTP methods (except GET and POST ). Therefore, I am trying to use <http-method>

JSR-356: How to abort a websocket connection during the handshake?

扶醉桌前 提交于 2019-12-04 02:59:42
问题 I need to be able to abort a websocket connection during the handshake in case the HTTP request does not meet certain criteria. From what I understand, the proper place to do that is inside the ServerEndpointConfig.Configurator.modifyHandshake() method of my own Configurator implementation. I just can't figure out what to do to abort the connection. There's a HandshakeResponse parameter which allows adding headers to the response but I couldn't find any header that does the job. So how can I

Overriding hashcode and equals method in java?

删除回忆录丶 提交于 2019-12-03 21:22:45
I have the classes below: public class Sample implements java.io.Serializable{ //POJO with two fields and getters/setters private String name; private Integer id; //This POJO does not override equals() and hashCode() } public class B{ private Sample sample; //here i need override hashcode and equals() based on **sample** property. } When i tried overriding equals() and hashCode() in the B class I got the error below in Eclipse. The field type com.mypackage.Sample does not implement hashCode() and equals() - The resulting code may not work correctly. Now how can I compare two B instances

force glassfish 4 to use jackson 2.3

落爺英雄遲暮 提交于 2019-12-03 16:23:44
I wrote an maven application which should run on Glassfish 4. The Standard ApplicationConfig looks like this: @javax.ws.rs.ApplicationPath("resources") public class ApplicationConfig extends Application { @Override public Set<Class<?>> getClasses() { Set<Class<?>> resources = new java.util.HashSet<Class<?>>(); // following code can be used to customize Jersey 2.0 JSON provider: try { Class jsonProvider = Class.forName("org.glassfish.jersey.jackson.JacksonFeature"); } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE,

How to set Locale in Bean Validation

十年热恋 提交于 2019-12-03 16:17:58
By default Bean Validation gets Locale based on Locale.getDefault(), which is common to whole JVM. How to change BeanValidation's Locale for current EJB method call? I'm using JavaEE7 and want to get benefits from integration of JPA and Bean Validation, i.e. automatic triggering validation on insert/update/delete events, and as far as possible avoid of writing everything manually. EDIT After all, I'm just returning non-interpolated messages from EJB: public class DoNothingMessageInterpolator implements MessageInterpolator { @Override public String interpolate(String message, Context context) {

WildFly: randomly salted passwords in Java EE application

拟墨画扇 提交于 2019-12-03 13:51:05
问题 What is the WildFly (8.2) way to work with randomly salted passwords stored in a database? Is an implementation of org.jboss.crypto.digest.DigestCallback (in the password validation process) meant to have access to the salt part from the database? Or should I simply hash and salt passwords by my self before handing them over to the login method of HttpServletRequest ? 回答1: It looks to me like the 'WildFly way' to deal with passwords is to do what most containers do and deliver a non-secure

Which is better: multiple web socket endpoints or single web socket endpoint in Java EE7

隐身守侯 提交于 2019-12-03 13:04:26
Java EE 7 allows you to create new endpoints very easily through annotations. However, I was wondering is having multiple endpoints one to handle each message type a good idea or should I have just one endpoint facade for everything? I am leaning towards having one single end-point facade based on the theory that each endpoint creates a new socket connection to the client. However, that theory could be incorrect and Web Socket may be implemented so that it will use just one TCP/IP socket connection regardless of how many web socket end points are connected so long as they connect to the same

Load recursive object graph without N+1 Cartesian Product with JPA and Hibernate

五迷三道 提交于 2019-12-03 08:52:32
问题 When converting a project from Ibatis to JPA 2.1, I'm faced with a problem where I have to load a complete object graph for a set of objects, without hitting N+1 selects or using cartesian products for performance reasons. A users query will yield a List<Task>, and I need to make sure that when I return the tasks, they have all properties populated, including parent , children , dependencies and properties . First let me explain the two entity objects involved. A Task is part of a hierarchy.