This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Spring Data Access usage in JBoss

May 11th, 2009, 06:33 AM

Hi guys/gals,
This will be a lengthy post so please bear with me. I want to share as much as possible with you guys so you gurus out there can help me.
OK. So I've got this situation where I want to(rather have to) use a more standards compliant way of persisting data in a legacy enterprise application. The enterprise application uses a mixture of data access strategies, like EJBs(the ugly ones), hibernate 2.x and Apache DynaBeans. Lemme focus on the DynaBean part. This legacy app is actually a deployment and execution engine for a proprietary project definition file(a DSL in a way, in XML), where different applications are deployed and executed. The DSL contains the web UI definitions as well as the 'entity' (or domain data objects). These data objects are persisted by the engine using DynaBeans.
Now the major trouble with this implementation is that theres no transaction support in the DynaBean approach. I could change the persistence code and program transaction boundaries into it, but I don't think that's necessary(and would be error prone) when there are tools like those provided by Spring.
The DynaBean approach to persistence is also very slow, where apache beanutils will load the entire resultset into memory and then construct DynaBeans for each row.
Another issue with the DynaBean model is, well, it really isn't a model of the domain. It's basically a map containing the fields, which does not make it easy for anyone new in the team to understand.
Hence, I've been considering to use Spring+JPA(Hibernate3.x)+ Spring's transaction support for deploying future projects on the legacy execution engine and here's where I really need help. Following are my questions:
1) ClassLoader issues - The runtime environment is JBoss 3.2.3, which I believe has Tomcat 5.x(which 'x' version I'm not entirely sure). Since, all the Spring related tutorials/articles focus on using Tomcat, theres a mention of installing the Spring classloader to support runtime code weaving/modification. This said to be done in server.xml or an application specific config file. Where do we do this in JBoss?
2) What will be the impact of EJBs on the Spring managed, transaction aware persistence code? Some parts of the application engine are using EJBs(lets focus on session beans that are http request handlers delegated to by the servlets). These session beans form part of the web-framework that will execute my service layer objects, which will then use DAOs for persistence.
3) I don't intend to use(or see the need of) using a JTA datasource; even the EJBs themselves are using a local-tx-datasource in JBoss. Should I use a separate local datasource for the spring managed objects or just use the one defined by the enterprise application? Please remember that the application engine uses the local-tx-datasource for EJBs as well as the DynaBean approach to persistence, so I don't think there should be an issue with datasource, unless I'm missing something.