Delivery of JMS message before the transaction is committed

You are experiencing the classic XA 2-PC race condition. It does happen in production environments. There are 3 things coming to my mind. Last agent optimization where JDBC is the non-XA resource.(Lose recovery semantics) Have JMS Time-To-Deliver. (Deliberately Lose real time) Build retries into JDBC code. (Least effect on functionality) Weblogic has this LLR optimization … Read more

EJB 3.0 – Nested Transaction != Requires New?

RequiresNew does not create a nested transaction because the first transaction is suspended while the second transaction is running. A nested transaction looks like this: Nested transaction example > method1 – begin tran1 > method2 – begin tran2 workA < method2 – commit tran2 < method1 – rollback tran1 (tran2 also rolled back because it’s … Read more

How to create join table with JPA annotations?

You definitely shouldn’t create User_Group entity as it’s more the underlying database representation than the object oriented one. You can achieve the join table by defining something like: @Entity @Table(name=”USERS”, schema=”ADMIN”) public class User implements Serializable { //… @ManyToOne @JoinTable(name=”USER_GROUP”) Group group; @Entity @Table(name=”GROUPS”, schema=”ADMIN”) public class Group implements Serializable { //… @OneToMany(mappedBy=”group”) Set<User> users; … Read more

Spring Data JPA: How can Query return Non- Entities Objects or List of Objects?

You can do something like @NamedQuery(name=”findWhatever”, query=”SELECT new path.to.dto.MyDto(e.id, e.otherProperty) FROM Student e WHERE e.id = ?1″) Then the MyDto object would just need a constructor defined with the correct fields i.e. public MyDto(String id, String otherProperty) { this.id = id; this.otherProperty = otherProperty; }

Root URl of the servlet

You do realize that the URL client sees (and/or types into his browser) and the URL served by the container your servlet is deployed on can be very different? In order to get the latter, though, you have a few methods available on HttpServletRequest: You can either call getScheme(), getServerName(), getServerPort() and getContextPath() and combine … Read more

How to exclude one url from authorization

Omit the <auth-constraint> element in <security-constraint> for resources for which you don’t need authentication like: <security-constraint> <web-resource-collection> <web-resource-name>app</web-resource-name> <url-pattern>/info</url-pattern> </web-resource-collection> <!– OMIT auth-constraint –> </security-constraint> <security-constraint> <web-resource-collection> <web-resource-name>app</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>Role</role-name> </auth-constraint> </security-constraint>