java-ee-6

SessionContext Injection using @Resource annotation

孤者浪人 提交于 2019-12-11 03:54:14
问题 I need to rollback in EJB 3 Stateless SessionBean (CMT, JBoss version 5), for which I am using sessionContext.setRollbackOnly(); This sessionContext is injected using @Resource annotation. My questions: 1) Is it preferred way to rollback in EJB3? 2) Why Jboss complains on deployment if I use public setter injection // throws exception on deployment. private SessionContext sessionContext; @Resource public void setSessionContext(SessionContext sessionContext) { this.sessionContext =

JSF - Keep Faces Messages after redirect from @PostConstruct

南楼画角 提交于 2019-12-11 03:27:52
问题 I have page1 with button that navigates to page2, page 2 add some messages and navigates back to page1. I want display those messages on page1. I've tried many solutions, but nothing work. Sample code page1.xhtml: <p:commandButton value="edit" action="#{bean1.edit}"/> In the managed bean: public String edit() { return "page2?faces-redirect=true"; } page2 managed bean @PostConstruct private void postConstruct() { Faces.getFlash().setKeepMessages(true); Messages.addFlashGlobalError("cannot edit

TomEE throwing IndexOutOfBoundsException

a 夏天 提交于 2019-12-11 02:22:01
问题 I am trying to deploy a Vaadin/JEE6 application to TomEE. The following exception is thrown during deployment: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/myapp]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:812) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787) at org.apache

JPA CDI Injecting DAO into an Entity

我的梦境 提交于 2019-12-11 01:04:36
问题 I'm new to JPA and CDI and I'm trying to create an enterprise application using these frameworks. I get how I can inject into beans and keep everything tidy and stateless. I also get that JPA loads relations etc. for me so that I don't have to worry about it anymore. I still use my DAO's for specific find methods and ofcourse to create new entities. I understand that I don't want to be injecting stuff into my entities since they're managed by JPA and I need to use the new keyword to create a

How inject EJB into abstract CDI class?

拥有回忆 提交于 2019-12-11 00:26:26
问题 I have a problem with injecting an EJB into an abstract class which is the parent of my JSF CDI beans. In my project I am using MyFaces CODI 1.0.5 (ViewScope), Omnifaces 1.3, PrimeFaces 3.4.2 and GlassFish 3.1.2. The application is an EAR, the abstract class is in an EJB module and the JSF CDI beans are in a WAR module: webframework-demo.ear |__ webframework-war.war -> concrete JSF CDI bean |__ webframework-ejb-lib.jar -> abstract class with EJB injection |__ lib\ |__ shared libs My abstract

Spring - When should I consider loading another context in same JVM?

送分小仙女□ 提交于 2019-12-11 00:24:28
问题 I was just thinking that when should I actually consider loading more than one application contexts in Spring? All so far I have been merging the context files with <include> such that only one application context loads up. Do you have an idea about when to go for more than one application contexts in the same JVM? 回答1: When you need to use hierarchical contexts, for example - like Spring MVC does. Your "web" context is loaded separately from your "main" context, so stuff defined in "main"

Can JPA 2.0 be used without JavaEE 6?

℡╲_俬逩灬. 提交于 2019-12-10 23:13:48
问题 I am using OpenJPA 2.1 (which implements JPA 2.0 ) for a command line utility. I am using classes that are new for JPA 2.0 . My compile target is Java SE 1.6 OpenJPA 2.1 comes with all JPA 2.0 javax.persistence.* interfaces/implementations. Can I claim that my utility has no dependence on JavaEE 6 ? My understanding is that JavaEE 6 is a collection of standards. So it is no different in that respect from any other random set of standards. Hence JavaEE 6 depends on JPA 2.0 , but JPA 2.0 does

Using @RunAs in my EJB Schedulers

自作多情 提交于 2019-12-10 19:56:03
问题 I have many EJBs with my business methods. These methods use @RolesAllowed annotation to check if user can execute this method. So I have an EJB Scheduler that calls these EJB methods. EJB schedulers runs with anonymous user, so authorization fails. How I can run my schedulers with other role? For testing proposes, I run with @RunAs("SYSTEM") annotation, but I don't know if this is right. My scheduler class @RunAs("SYSTEM") public class InboxScheduler { protected void inboxFileScan(Timer t) {

@EmbeddedId with autogenerated id using @GenerateValue, this mix doesn't works as needed

假如想象 提交于 2019-12-10 19:54:16
问题 I am trying to work with @EmbeddedId, this is my code as follows, create table TBL_EMPLOYEE_002( ID integer generated always as identity (start with 100,increment by 10), COUNTRY varchar(50), NAME varchar(50), constraint PK_EMP_00240 primary key(ID,COUNTRY) ) The Embedded class as follows, @Embeddable public class EmployeeIdTwo implements Serializable{ public EmployeeIdTwo(){} public EmployeeIdTwo(String country){ this.empCountry = country; } @GeneratedValue(strategy=GenerationType.IDENTITY)

Glassfish 3.1.1: Retrieve HTTP-Authentication in RESTful Webservice

大憨熊 提交于 2019-12-10 19:39:58
问题 I´m using HTTP-Authentication based on my customer-table. After the user is authenticated a restful webservice is called. But how can I access in the webservice the HTTP-Authentication (the Header Data of the HttpRequest)? My code looks like this: @GET @Path("{id}") @Produces({"application/xml"}) public ObjectList read(@PathParam("id") Integer id) { ... //how to get here the HTTP-Username and Password? } 回答1: In order to get the Principal and its role, inject @Context SecurityContext in the