jakarta-ee

Calling a CDI session scoped producer method from an EJB stateless session bean

北战南征 提交于 2020-01-12 18:19:17
问题 I want to inject the current user using @Inject @Current User across all layers (i.e. web layer, EJB layer). In order to do this, I have the following CDI Producer method: @Named @SessionScoped public class UserController { @Resource SessionContext sessionContext; @EJB UserDao userDao; @Produces @Current public User getCurrentUser() { String username = sessionContext.getCallerPrincipal().getName(); User user = userDao.findByUsername(username); } } @Qualifier @Target({TYPE, METHOD, PARAMETER,

HQL with a collection in the WHERE clause

こ雲淡風輕ζ 提交于 2020-01-12 14:31:15
问题 I've been trying for the this whole a query who is officially giving me nightmares. The system is a user and contact management. So I have UserAccount , Contact and Phone . UserAccount has a bidirectional one-to-many relationship with Contact and an unidirectional one on phone all mapped by a Set : //UserAccount mapping @OneToMany(targetEntity=PhoneImpl.class, cascade= {CascadeType.ALL}) @org.hibernate.annotations.Cascade(value=org.hibernate.annotations.CascadeType.DELETE_ORPHAN) private Set

WebSocket Error during Handshake Unexpected code 200

白昼怎懂夜的黑 提交于 2020-01-12 14:11:14
问题 I have been using Glassfish 4 as my server. I am opening a WebSocket connect using this statement: webSocket = new WebSocket(link); Where: link = 'ws://localhost:8080/CollabEdit/Document/file333B1CDF85-DDDC-E411-8299-F82FA8BE8622'; And in the Server File: @ServerEndpoint(value="/file333B1CDF85-DDDC-E411-8299-F82FA8BE8622", encoders = {MessageEncoder.class}, decoders = {MessageDecoder.class}) Actually, I have been using URL mapping as well, this " file333B1CDF85-DDDC-E411-8299-F82FA8BE8622 "

How to retrieve Weblogic's Deployment test points through Weblogic Java API

限于喜欢 提交于 2020-01-12 13:57:24
问题 I'm working on a Weblogic health monitoring code base, which is based on JMX. I am trying to get the list of all deployment test points (the http addresses, as shown in the following snapshot), and see if that web address is reachable or not. Is there a way to access the list of these test points in Weblogic's Java API? They are under [server_name] --> deployment (left menu) --> [app name] --> Testing pane, under " Deployment Tests " table. 回答1: There is no direct method call to generate test

Using arbitrary resources with JTA

荒凉一梦 提交于 2020-01-12 09:53:11
问题 Is it possible to make any type of custom resource transactioal with JTA? Let's assume a basic example and take a Folder creation that should be rolled back in case of an error. Can such custom resources be handled? 回答1: Yes. That resource needs to provide an implementation of XAResource, and an instance of that implementation needs to be enlisted with the transaction when the resource is used. The resource can get the current transaction from the transaction manager in order to carry out the

Are Threads in Java platform dependent?

社会主义新天地 提交于 2020-01-12 08:09:26
问题 It is obvious that OS scheduling/ threading algorithms have their impact on Java threads but can we safely say that Threads are OS/machine dependant? If this is the case then doesn't it make Java platform dependant? 回答1: Yes, the details of the scheduling of threads in Java depends on the JVM implementation and (usually) on the OS implementation as well. But the specifics of that scheduling is also not specified in the Java SE specification, only a selected few ground rules are specified.

Are Threads in Java platform dependent?

╄→尐↘猪︶ㄣ 提交于 2020-01-12 08:04:39
问题 It is obvious that OS scheduling/ threading algorithms have their impact on Java threads but can we safely say that Threads are OS/machine dependant? If this is the case then doesn't it make Java platform dependant? 回答1: Yes, the details of the scheduling of threads in Java depends on the JVM implementation and (usually) on the OS implementation as well. But the specifics of that scheduling is also not specified in the Java SE specification, only a selected few ground rules are specified.

How to Call java Rest WebService inside a Servlet

点点圈 提交于 2020-01-12 08:00:08
问题 I have a java Rest WebService URL http://localhost:8080/WebServiceEx/rest/hello/dgdg When i execute the URL ,the WebService Method Returns a String My Requirement is to call the above WebService URL inside a Servlet ,Could any one Help? ServletCode: public Class StoreServlet extends HttpServlet{ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { //Invoke WebService and Get Response String Here } WebService Code: public class

How do I write a Java EE/EJB Singleton?

我是研究僧i 提交于 2020-01-12 07:48:19
问题 A day ago my application was one EAR, containing one WAR, one EJB JAR, and a couple of utility JAR files. I had a POJO singleton class in one of those utility files, it worked, and all was well with the world: EAR |--- WAR |--- EJB JAR |--- Util 1 JAR |--- Util 2 JAR |--- etc. Then I created a second WAR and found out (the hard way) that each WAR has its own ClassLoader, so each WAR sees a different singleton, and things break down from there. This is not so good. EAR |--- WAR 1 |--- WAR 2 |-

Is it possible to observe a CDI Event inside a WAR when packaged as EAR

为君一笑 提交于 2020-01-12 07:47:10
问题 I have an Enterprise Application Archive ( EAR ) containing multiple backend modules ( EJB ) as well as some web modules ( WAR ). The Event gets fired inside one of the backend modules: @Inject private Event<MyEvent> myEvent; ... public void fireEvent() { myEvent.fire(new MyEvent()); } ... It can be observed in any of the other backend modules with code like this: public void listener(@Observes MyEvent myEvent) { .. } But I can't retrieve the event inside the WARs. Is this because of