java-ee

Audit Java: system to detect exceptions thrown / caught (aop?)

三世轮回 提交于 2019-12-20 17:48:30
问题 Due to checked exceptions, we can have some problems in production having all exceptions caught in the right place and logged correctly. I wonder if there is some opensource tool to help with auditing these problems. For example, is there some AOP tool that would intercept all exceptions thrown and see if they are re-thrown, wrapped or logged? This would help identify the bad catches. 回答1: I know the question asks for an open source solution. I don't know of one but if the option is there

EJB: Avoid Transaction rollback

寵の児 提交于 2019-12-20 17:32:16
问题 When a (transactional) method of an EJB calls another (transactional) method of another EJB, and an exception is thrown in the second, but catched in the first one, it seems that the transaction is automatically rolled back when the second one returns, even if the first one catches it, is this true? how can I avoid it? The scenario is the following one: @Stateless class ClassA { @EJB ClassB objectB; methodA() { try { objectB.methodB(); } catch(Exception e) { //Here the transaction started in

How do I make JNDI names compatible with both GlassFish and WildFly

旧时模样 提交于 2019-12-20 15:23:17
问题 I am developing a Java EE 7 application and have a requirement for the application to be deployed onto application servers running either GlassFish 4.0 or WildFly 8.1.0. The issue I've got is GlassFish and WildFly use slightly different formats for JNDI names but I can't see how to make my application compatible with both. In GlassFish my persistence.xml file references the data source jdbc/myDataSouce, but in WildFly the data source needs to be java:/jdbc/myDataSource. The same is also true

How does Spring Security sessions work?

本秂侑毒 提交于 2019-12-20 14:09:47
问题 How do Spring sessions work when you login to a form on Spring security as described in this tutorial? http://static.springsource.org/spring-security/site/tutorial.html Is it cookie based? Im not sure what exactly is going on that allows the user to log in and have it remember and keep you logged in for the remainder of the browsing session. 回答1: It is cookie based similar to how the servlet maintains sessions . If cookies are disabled, you would have to resort to URL rewriting .According to

EJB's and Threading

限于喜欢 提交于 2019-12-20 14:08:40
问题 From what I understand it is illegal to spawn threads from within an EJB as it may potentially interfere with the EJB's lifecycle. However, is it illegal to use predefined Java classes from the JDK which internally spawn and handle threads such as Executor within an EJB, specifically an MDB? 回答1: The biggest issue with threads and EJBs is that threads are a limited resource heavily used by the container, and thread mistakes lead to thread pool leaks that can effectively kill the whole JVM

EJB's and Threading

青春壹個敷衍的年華 提交于 2019-12-20 14:07:12
问题 From what I understand it is illegal to spawn threads from within an EJB as it may potentially interfere with the EJB's lifecycle. However, is it illegal to use predefined Java classes from the JDK which internally spawn and handle threads such as Executor within an EJB, specifically an MDB? 回答1: The biggest issue with threads and EJBs is that threads are a limited resource heavily used by the container, and thread mistakes lead to thread pool leaks that can effectively kill the whole JVM

How to merge wars into one?

与世无争的帅哥 提交于 2019-12-20 12:34:17
问题 In our company, we have a number different modules constructed as separate wars. Each client can pick and choose module he wishes to buy. Since all modules share same session, security context etc, it makes sense to merge them into a single war. Is it possible to automate this process? For example, it should merge web.xml, calculate each wars dependencies, copy files like .jsp and .class etc. By the way, we are using Maven, but were not able to find a solution to this problem. 回答1: Granted

How to avoid creating a new row if similar row exists?

风格不统一 提交于 2019-12-20 12:15:56
问题 I need to configure hibernate to avoid creating duplicate rows, (although the row exists it creates a new one, and since only one filed is set it set all the rest to NULL) Lets say I have a row as following id des index age 1 MyName 2 23 Although I just set MyName as des and it already exists in the Name table hibernate create a new row as following id des index age 1 MyName 2 23 2 MyName Null Null << new row with null values will be created rather than updating the previous one When I want

Java REST service using authentication token

杀马特。学长 韩版系。学妹 提交于 2019-12-20 11:53:13
问题 On my web app using Java EE 6. I want to expose some of my functionality as a Json Rest Service. I want to use authentication tokens for login, User will send their username, password and server will send back a token, which will be used to authorize the user on their further requests for a given time.. A few questions bothering me so far; When the server creates the token and sends to client, should server save it in a DB OR in a Bean using something like a hashtable as userid-token pairs?

Hibernate Query Hints for JPA

谁说胖子不能爱 提交于 2019-12-20 11:42:23
问题 I have been trying to find a definitive resource for all of the hints that can be set through the Query.setHint(String,Object) method call in JPA, but I am coming up empty. Anyone know a good reference? 回答1: See "3.4.1.7. Query hints". 来源: https://stackoverflow.com/questions/1015552/hibernate-query-hints-for-jpa