Inject Java EE Beans into Tapestry-5.x

Tapestry uses it’s own Inversion Of Control (IOC) container. Tapestry pages are not Servlets or Servlet Filter (and not another managed class). Therefore they cannot be used for injection of Java EE Beans. But there is the AppModule, which is conceptual some kind of related to Spring Java Config. It allows to configure the Tapestry application directly in Java. Like everything in Tapestry it has an Adaptive API. Hence you have to follow a naming (signature) pattern for your methods and Tapestry finds them. You don’t have to implement an interface.
Read More

Tapestry-5.3.1 and Jboss-7.0.2-Final

The Java web framework Tapestry 5 has a hot deployment/reload feature, that traverses the classpath, looking for new resources to load. Unfortunately, it is not capable to parse URLs of Jboss’ virtual file system and therefore does not find it’s own core libraries. This issue has been tracked in TAP5-576 and a solution for Jboss-5 and Jboss-6 can be found in the corresponding wiki articles. The same problem remains for Jboss-7. Accidentally the reflective calls to virtual file are restricted. But the solution for Jboss-6.1 does still work. Here is a little tutorial how to achieve this.
Read More

Concurrent conversion of SVG to formats like PNG, EPS or PDF

In this post I’ll show how to use the ExecutorService of the java.concurrent package, in order to start as many inkscape shells as processors available on the current machine and to distribute a whole bunch of conversion tasks wisely on the cores. On my quad core I got a speedup of about 3.5, which is really near to 4.
Read More

Informative Exceptions with Java Proxies

Information is essential for reasonable exception handling. Unfortunately, it is not always affordable to write custom exceptions providing all necessary information, especially in test code, e.g. for selenium tests. So, here is an approach to weave informative exceptions into your [test] code.
Read More

Circular Dependencies of Session Beans via Manual EJB Lookup

In my last two posts (Circular Dependencies of Session Beans and Circular injection of Util Classes in EJB 3.0) I wrote, that it is possible to have circular dependencies between session beans via interceptors and manual EJB lookup. In this post I will sketch out how.
Read More

Circular Injection of Util Classes in EJB 3.0

In my last post Circular Dependencies of Session Beans I presented a method to use interceptors in session beans in order to inject beans. This works great until you want to add circular dependencies. Then you have to look up the beans by name and inject them into the bean. But this is kind of cumbersome. So, if it is possible, have a bean structure, which is topologically sortable and inject util classes having circular dependencies between each other. This post shows how to achieve the latter.
Read More

Circular Dependencies of Session Beans

This post is about circular dependencies between session beans (ejb 3.0), which is ‘not possible’ without manual loading. The manual variant might be the solution of choice for you. Therefore, I will sketch it out later in this post. The first part of this post post is about a trial to achieve this with @EJB annotation only … which failed! But perhaps it will stop some of you to try it out (for nuts) and it’s a great bridge to a solution by a snatch enabling to have circular injection of ‘your own’ beans. I will show you the latter in my next post.
Read More

Convert Programmatically Created Queries to Named Queries

Using named queries has some nice advantages as described in Organize Your Named JPQL Queries. But it is not easy to convert queries to named queries as former are often programmatically created via string concatenation. At a first glance this seems to be a show stopper. In this post I will show two approaches to convert such queries into named queries.
Read More

Optional ‘Paths’ in JPQL Queries

There exists a phenomenon in JPQL/SQL that isn’t quite intuitive in the first place, but gets clearer after you have understood how it works. A normal JOIN in a JPQL query is evaluated as an INNER JOIN. That means, that a row will not be selected, if the right hand side of the JOIN is NULL. This may sometimes lead to unexpected results…
Read More

Transaction Handling in Tapestry5 with Jboss-5.1.0GA

edit: This works with JBoss-7.0.2, too

In a session bean every method has set the transaction attribute REQUIRED by default, i.e., calling it without an active transaction results in the creation of a new transaction. In a tapestry application you may inject session beans and call methods on them. Unfortunately, every call will open up a new transaction being ‘commited’ as the method returns. This has the disadvantage, that the first level cache of the transaction will be cleared after every call, for example. In this post, you will learn how to set up a transaction before a page or component render request and commit it right after the request is completely processed.
Read More