ejb-3.1

Why session bean method throw EjbTransactionRolledbackException when RuntimeException was thrown

僤鯓⒐⒋嵵緔 提交于 2019-12-03 08:20:18
I am trying to persist the entity with constraint validation, when invoke persist - there is constraint that thrown and the caller get EjbTransactionRolledbackException ... so I try to call the validation explicit and throw ConstraintViolationException / RuntimeException and still the caller get EjbTransactionRolledbackException ... when I throw MyException extends Exception - the caller get MyException Even when I call explicit sc.setRollBackOnly it's still happened :( This shouldn't be the behavior. what's going on? Configuration: Netbeans 6.9.1 Glassfish 3.0.1 JPA 2.0 (EclipseLink) EJB 3.1

EJB3.1 System Exceptions vs javax.ejb.EJBException

ぐ巨炮叔叔 提交于 2019-12-03 08:12:36
Just a bit of background on EJB3.1 exceptions before bringing up my question - Application exceptions comprise of User defined checked or unchecked exceptions which have @ApplicationException annotation All checked exceptions java.lang.Exception & it's subclass exceptions except java.rmi.RemoteException & it's subclass exceptions System exceptions comprise of java.rmi.RemoteException and it's subclass exceptions All unchecked exceptions java.lang.RuntimeException and it's subclass exceptions java.lang.Error and it's subclass exceptions Below is a statement I have read in this book In EJB

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

Hold session in stateful EJB 3.1 bean?

狂风中的少年 提交于 2019-12-03 07:27:32
I'm working on a Java webapp trying to combine the following technologies: Java EE 6 CDI JSF 2 EJB 3.1 Spring Security I provide CDI-based backing beans (@ViewScoped, @Named) for my JSF pages. I use @Stateless EJB beans for the actual work to be done. I only need few session information like jSessionCookie (managed by container), internal username and some other internal IDs. Now, I wonder where to put this session information so that I can access it in the backing beans for JSF, but also provide it to the stateless EJBs? Should I use a @Stateful EJB session bean or should I create CDI-based

EJB 3.1 application deployed as WAR-only: What about ejb-jar.xml?

此生再无相见时 提交于 2019-12-03 06:43:41
I have a JavaEE6 application, consisting of Web stuff and EJBs and which is deployed as WAR-only (using EJB3.1). The build is based on Maven. I just read about a new possibility to order the module initialization in Java EE 6 here which i also need for my application. Also, i would like to have an option to define some EJB properties in XML. Since the example is deployed as an EAR-project the order is defined in the application.xml. But in a WAR-deployed project, there is no application.xml. Now i wonder where i can define such informations? Or is it possible to use an application.xml somehow

unit testing EJBs with Maven 2 and Glassfish 3

≡放荡痞女 提交于 2019-12-03 05:59:27
问题 I've been trying to set my application up so that I can unit test it's EJBs all day but I can't seem to get past what seems like a really simple problem. I have a standard Maven web application set up in NetBeans 6.9. I've automatically generated a unit test for one of the EJBs but whenever I go to run it I get the error message: Testcase: initializationError(com.example.ExampleTest): Caused an ERROR Absent Code attribute in method that is not native or abstract in class file javax/ejb

CDI: Using Interceptors across different modules / bean archives

自古美人都是妖i 提交于 2019-12-03 02:56:38
My Java EE 6 application consists of a war and an ejb module packaged in ear file. I'm using CDI for DI (i.e. I have a beans.xml file in both modules). I want to use a logging interceptor that is defined in the ejb module in the war module, as well. I've enabled the interceptor in the ejb's beans.xml: <beans> <interceptors> <class>com.test.interceptor.LoggingInterceptor</class> </interceptors> </beans> This is working only for the classes that are annotated with the interceptor in the ejb module . Classes in war module are not intercepted (although they're annotated with the interceptor too).

Possible to change ejb parameter at runtime for @Schedule annotation?

百般思念 提交于 2019-12-03 01:44:38
Probably a silly question for someone with ejb experience... I want to read and change the minute parameter dynamically for one of my EJB beans that uses the Java EE scheduler via the @Schedule annotation. Anyone know how to do this at runtime as opposed to hardcoding it in the class like below? If i were to do it programatically could i still use the @Schedule annotation? @Schedule(dayOfWeek = "0-5", hour = "0/2", minute = "0/20", timezone = "America/Los_Angeles") private void checkInventory() { } @Schedule is for automatic timers created by the container during deployment. On the other hand,

JPA dynamic persistence unit name

妖精的绣舞 提交于 2019-12-02 23:03:48
I need a way to dynamically specify the persistence unit in a EJB. Simplified example: I have an application using multiple databases as data stores. Each of the data stores are structurally the same. Depending on the client connecting to the application I need to access the data from a specific data store. Therefore, I would like to use the same EJB so that the business logic is not duplicated, but then just select the correct persistence unit based on the client. Up to this point I've only directly injected the entity manager with the persistence unit name hard coded. Is there a way I can

unit testing EJBs with Maven 2 and Glassfish 3

瘦欲@ 提交于 2019-12-02 19:38:49
I've been trying to set my application up so that I can unit test it's EJBs all day but I can't seem to get past what seems like a really simple problem. I have a standard Maven web application set up in NetBeans 6.9. I've automatically generated a unit test for one of the EJBs but whenever I go to run it I get the error message: Testcase: initializationError(com.example.ExampleTest): Caused an ERROR Absent Code attribute in method that is not native or abstract in class file javax/ejb/embeddable/EJBContainer java.lang.ClassFormatError: Absent Code attribute in method that is not native or