Search This Blog

2009-05-19

Very nice JavaEE blue sheet about the interaction between the tiers

While browsing for some articles about the JPA's EntityManager's detached and attached state, i stumbled upon a very nice blue sheet.
If you want to create a web application with JavaEE you should definitly read this article, as it shows you a way of how to work with enities on the front end layer without having DTOs.
If you talk to J2EE architectures about this topic and suggest a solution like this, you might have a tough discussion. I understand that there are several cases where it makes sense to introduce DTO's but in my opinion you should always start with the leanest solution. Every line of code you write may contain an error, even if it's just some 'mapping code' (DTO2EntitieHelper).
JavaEE has made the life of a backend developer way easier. So, if you want to get rid of all those layers in your application from one tier to another, read this article.

2009-05-16

How to integrate GlassfishV2.1 and Websphere MQV6

For my latest project I had to create a web application which integrates an existing Websphere Message Broker application.According to what is so important at developing software, i am talking about "keep it simple",  i chose to stick to the components described in the javaEE specification.
JSF for the front end development, local stateless session beans for the business logic, oracle's toplink as JPA Provider to provide access to an Oracle database. WebApp and EJBs deployed into one EAR to the application server glassfish V2.1, using my favorite IDE Netbeans 6.5.1. 
The only tricky thing was: How do i integrate this Broker Application? 
The customer decided to have a request reply message broker flow for the web application. So i created a facade for the web application to handle the messages between the web app and the broker application. This facade has the TransactionAttribute 'Not supported' and delegates to 2 stateless session beans with TransactionAttribute 'Requires New'. One bean is responsible for sending messages, the other for receiving. 

But back to topic of this post. I chose the jms ressource adapter 'generic ra', which is part of the glassfish v2.1 download. I followed installation steps described in this document. This is a amazing document. Everything is very well described and all the commands i had to execute were successfull. However there is one sentence which confused me:
If you have the MQ broker running on a different machine and need to access it remotly, please refere the WebSphere MQ documentation for configuration details.
Yes, i have MQ broker running on a different machine. So what do i have to do now? I just had to change localhost with the ip adress of the machine where mq is running to the following line
def qcf(QCF) hostname(localhost) port(1414) channel(SYSTEM.DEF.SVRCONN) transport(CLIENT) qmanager(QM1)
That's all. BUT there was one thing i had to struggle for 2 days. While trying to send messages i always received the following error message:
MQError in allocating a connection. Cause: null
With the help and awesome support of Ramesh Parthasarathy,  thank you again Ramesh, we finally found the problem. The ressource adapter is configured to look up the MQ configuration in a .binding file. I placed this file into /tmp and configured the ressource adapter like this:
java.naming.provider.url=file://tmp
This configuration did not work for me. I had to add another slash like this, and finally i got it working
java.naming.provider.url=file:///tmp
it was really tough to find out what the problem was. After I was able to send a message to MQ with a local jms client (java program) on a windows xp machine, I thought there must be something wrong with the file system configuration. I'll post the java code of this very useful client in the next blog message. Another hint: If you don't use XA transaction support, configure your connection pool with the settings
--transactionsupport . NoTransaction
If you just skip this line, you will get the following error while trying to send a message.
MQError in allocating a connection. Cause: SupportsXA is configured as false. Dont use the resource adapter in XA mode
Last but not least. Never forget to start and close the connection in your java code. Otherwise you won't be able to send or read/consume messages from a Queue, even though the connection is working :)

2009-05-15

Hello World

Hi guys,
i created this blog to share my informations as an IT-Consultant with you.
My main focus is on developing enterprise applications with JavaEE technology.
I've been doing this since 2004, especially within large projects for insurance companies or the automotive industry. 2 weeks ago  i got the great opportunity to build an application, where i was able to describe the architecture, set up the environment and enjoy agile java ee development.
I'll write more about it soon...
So...where ever you are, feel free to leave a message and have a good day!
Daniel