java-ee-7

injectionPoint.getBean() returns null if bean is an EJB bean in Java EE 7 (CDI 1.1)

扶醉桌前 提交于 2019-12-03 07:55:09
I want to get bean from producer method in order to read its properties. In some scenarios the bean is a EJB Singleton bean. I've simplified my code to focus on the problem. My simple qualifier: @Qualifier @Retention(RUNTIME) @Target({TYPE, METHOD, FIELD, PARAMETER}) public @interface InjectMe {} Simple producer: @Dependent public class SimpleProducer { @Produces @InjectMe public String getInjectMe(InjectionPoint ip) { // ip.getBean() returns null for some reason return "ip=" + ip + ", bean=" + ip.getBean(); } } EJB (Singleton): @Singleton @Startup public class SimpleSingleton { @Inject

WildFly: randomly salted passwords in Java EE application

邮差的信 提交于 2019-12-03 03:53:07
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 ? It looks to me like the 'WildFly way' to deal with passwords is to do what most containers do and deliver a non-secure solution out-of-the-box. I don't know why, but every standard JDBC realm implementation I've seen so far just

changing the encode characters for Eclipse

孤者浪人 提交于 2019-12-02 13:52:02
问题 How do I to change the encoding on Eclipse ? I did all of these configurations: http://uploads.siteduzero.com/files/388001_389000/388662.png http://uploads.siteduzero.com/files/388001_389000/388661.png http://uploads.siteduzero.com/files/388001_389000/388660.png http://uploads.siteduzero.com/files/388001_389000/388659.png And Window > Preferences > General > Workspace > 'Other UTF-8' But, I still get this on my webpage which I had extracted from my DataBase, knowing that the encoding there is

Cannot Cancel @Asynchronous call to EJB

扶醉桌前 提交于 2019-12-02 08:58:39
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 void post_construct () { System.out.println("post_construct started"); future = other.ton_of_work();

CDI event observer handling on server crash and restart

…衆ロ難τιáo~ 提交于 2019-12-02 08:56:43
问题 I am trying to persist an item in DB using a service and firing a JMS message for the subsequent service to pick up the persisted item so that it can process the same. This particular operations happens in a single transaction. But due to race condition at times, the second service is not able to fetch the respective item as its not yet persisted. My use case is very common and there are so many discussions related to this in various forums. One solution for this issue is to use CDI events. I

PrimeFaces oncomplete backing method called on page load

蓝咒 提交于 2019-12-02 08:28:44
问题 PrimeFaces 5.0, JSF 2.2, Glassfish 4.1.1, I'm assuming that something in my setup isn't configured correctly but I'm not sure what to look at... So I'm using managedbeans to back JSF pages. Within the PrimeFace elements on the page if I use an oncomplete property the method it refers to gets called on the page load. I don't want it to call the method on each page load and i don't believe it should be! I have tested this through several pages and within different elements. I first noticed this

'Bean does not have a public constructor that does not take parameters' error despite clearly having one?

谁都会走 提交于 2019-12-02 07:56:10
问题 I have an EmailService EJB that has a very simple 'send_email' method. I'm receving the error in the title despite clearly having a public constructor that does not take parameters. Below is the exact error and the class code. This is very confusing. Error: [ERROR ] CNTR5007E: The websphere.jaxrs.service.EmailService bean class for the WebApiConsole#WebApiConsole.war#EmailService bean does not have a public constructor that does not take parameters. See here for error details (not much to see

JSF is unable to find resources in sub-folders

喜夏-厌秋 提交于 2019-12-02 07:36:44
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 load a resource that's located in sub-folders, it doesn't work: <h:outputScript library="theme" name=

PrimeFaces oncomplete backing method called on page load

一世执手 提交于 2019-12-02 03:52:11
PrimeFaces 5.0, JSF 2.2, Glassfish 4.1.1, I'm assuming that something in my setup isn't configured correctly but I'm not sure what to look at... So I'm using managedbeans to back JSF pages. Within the PrimeFace elements on the page if I use an oncomplete property the method it refers to gets called on the page load. I don't want it to call the method on each page load and i don't believe it should be! I have tested this through several pages and within different elements. I first noticed this issue with a <p:fileupload> element where I was trying to call a method, using oncomplete, once all

Where should I store credentials for my java application to access third party services?

℡╲_俬逩灬. 提交于 2019-12-02 03:51:11
问题 Where should I store credentials for my java application to access third party services? The credentials are not specific per user on my application. They are for accessing a web service my application is consuming. I know enough not to hard code them into my application, but where and how do I store them? I also assume they will need to be encrypted. 回答1: .jar file is best way to store all credentials. Create interface where store your credentials as a final String convert interface to jar