java-ee-6

JavaEE 6: java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName null

烈酒焚心 提交于 2019-12-11 12:11:49
问题 Yesterday when I was working on my JavaEE application, it was happily getting deployed to Glassfish 3.1 and all the [web, ejb, jpa] engines were working and I was able to interact with database without any problem. But ever since I started working today I've been having java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName null error when I try to retrieve something from database. The application is still deploying without any problems but I can't see the [jpa]

Java EE getting servlet container port

倾然丶 夕夏残阳落幕 提交于 2019-12-11 11:34:06
问题 I want to programmatically get the servlet containers port that my Java EE application is deployed on. I assumed there would be something in the JMX beans but I can't seem to find anything. And before anyone says grab the port from the HttpRequest or HttpResponse it should be noted that this process is running behind the servlet and has no interaction with the Requests or Responses. 回答1: One possible "hack" would be to parse the server.xml at runtime and identify the port that is configured.

Problems with @Stateless and application startup on JBoss 6

久未见 提交于 2019-12-11 11:06:09
问题 I have created a Java Web project with just one class. If I compile and deploy the WAR to JBoss everything works fine. However, if I make the class @Stateless, JBoss deployment fails with the error. java.lang.IllegalArgumentException: EntityManagerFactory cannot be null I am (by now) sure that I must be doing something very stupid but I cannot see what my problem is. Update : Must be something with the installation I have been given. Works fine on a local install of JBoss 6. Larger stacke

Do I need getter for the injected Conversation interface in CDI bean?

萝らか妹 提交于 2019-12-11 10:45:37
问题 I have a @ConversationScoped CDI bean with a Conversation interface injected and access modifier set as private. Something like this: @Named @ConversationScoped public class MySampleCdiBean implements Serializable { @Inject private Conversation conversation; //other stuffs } My question is do I need a getter for this injected conversation interface? Does the CDI container need this getter? Any resource from where I can understand the underlying details of how CDI container handles a

Execute code when successful JAAS login is done

99封情书 提交于 2019-12-11 08:42:17
问题 Is there something like a listener that I can use when JAAS authentication is done successfully, so that I can execute code in that moment? Right now I'm using JBoss AS 7 with the DatabaseLoginModule . One way would be to implement a custom login class extending DatabaseLoginModule , however it feels like overkill for this requirement. I not completely clear about some aspects of the Java EE application life cycle, maybe an application or session listener is fired when login is done. What

JBoss7: Custom Login Module not working

给你一囗甜甜゛ 提交于 2019-12-11 07:51:04
问题 I am in the process of migrating from JBoss 5.0.1 to JBoss 7.2. I am calling EJBs with a remote EJB client. I have to migrate a custom login module that derives from AbstractServerLoginModule . I managed to configure JBoss so that the custom login module is actually called. In the custom login module I implement a javax.security.auth.callback.NameCallback and a javax.security.auth.callback.ObjectCallback like that: NameCallback ncb = new NameCallback("Username:"); PasswordCallback pcb = new

Embedded Glassfish v3: deploying sun-resources.xml programmatically fails

ⅰ亾dé卋堺 提交于 2019-12-11 07:26:07
问题 I would like to be able to package my jpa-ejb-web project as a standalone application, by using Glassfish embedded API. To use the JPA layer, I need to deploy the sun-resource.xml configuration, which should be possible with the asadmin command add-resources path\to\sun-resources.xml . I've this code to do it: String command = "add-resources"; ParameterMap params = new ParameterMap(); params.add("", "...\sun-resources.xml" ); CommandRunner runner = server.getHabitat().getComponent

EE6 web profile … no EJB container?

偶尔善良 提交于 2019-12-11 06:03:53
问题 I'm learning about Java EE (EE 6 specifically) and find the differences between EJB and EJB Lite a little confusing. Java EE6 web profile only supports EJB Lite. My understanding of "EJB Lite" is that it is a simpler subset of EJB (I can find those differences documented easily enough) and you package your EJB classes in a WAR. So will I only able to access those EJB classes from the webapp contained in the same WAR (or another webapp if I put both of them in the same EAR) ? I assume that

Creating new entities while enabling injection

大憨熊 提交于 2019-12-11 05:56:49
问题 I have a method on a stateless session bean which creates a new instance of an entity and persists it. You might normally use new MyEntity() to create the object but I would like injection to populate some of the properties of the entity for me. I got partial success using @Inject @New private MyEntity myNewEntity; in the session bean and then using that instance in my method. The problem I have now is that the second time the method is called, myNewEntity isn't a new object, its the same

where to put filter like logic in JSF2

可紊 提交于 2019-12-11 05:34:21
问题 I am currently banging my head where to put a common logic for some authorization stuff in my Java EE 6/JSF 2 webapp: I have the requirement, that all requests that come with a specific cookie should be redirected to another page. I considered 3 solutions: 1) use a servlet 3.0 filter (@WebFilter) this worked, i also could inject my managed beans there, but the managed beans require access to the faces externalContext, which at filter invocation time has not yet been set up, so i got NPE's