Meera has posted 70 posts at DZone. You can read more from them at their website. View Full User Profile

EJB 3.0 and Spring 2.5

08.27.2008
| 56669 views |
  • submit to reddit

Why is it that developers from these two communities don't like to see eye to eye? I have been using both Spring from its inception, and EJB's from 2001. Just like everyone else did, I just dreaded the huge amount of XML we had to write for both of these; configuration files in Spring, and deployment descriptors in EJB 2.x. However, Java 5 came to our rescue and now annotations have mostly replaced XML files in both these. But, after having used these two latest versions Spring 2.5 and EJB 3.0, I think that they complement each other, rather than compete with each other. There are certain features which are powerful in Spring, and equal number of features powerful on the EJB side as well.

Many developers fail to understand, that Spring is a popular non-standard framework created by Spring Source, while EJB 3.0 is a specification which is supported by major JEE vendors. There are a few developers with whom I have worked earlier, prefer to use standard specification, and they chose EJB2.x/ and are moving now to EJB 3.0. However, there isn't anything stopping you from using Spring along with EJB, is it? The complaint I have heard many times is: We can't use non-standard framework". The same developers who complain about Spring being non-standard use home grown frameworks, which was and will be forever so hard to even decipher. How can it be a specification when a couple of developers write several thousand lines of code?

Also, a recent article published here at Javalobby by Adam Bien showed the trend moving towards EJB 3.0, right? Anyway, in this article we will see how by adding a few lines in your Spring configuration file, you can seamlessly use EJB 3.0 components within your Spring application.

Back to our EJB 3.0 and Spring 2.5 article, we are going to see how easy and simple it is to access EJB 3.0 components in Spring by using its powerful dependency injection mechanism to inject an instance of our Customer session bean. This Customer session bean, in turn uses the Entity Manager for the CRUD operations on the Customer Entity.

Here are the detailed steps:

Step 1: Create a simple JPA Entity.

The Java Persistence API (JPA) is defined as part of the Java EE 5 specification. Creating entities using JPA is as simple as creating a POJO with a few annotations as shown below:

package com.ejb.domain;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

/**
*
* @author meerasubbarao
*/
@Entity
@Table(name = "CUSTOMER", catalog = "", schema = "ADMIN")
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "CUSTOMER_ID")
private Long customerId;
@Column(name = "FIRST_NAME")
private String firstName;
@Column(name = "LAST_NAME")
private String lastName;
@Column(name = "MIDDLE_NAME")
private String middleName;
@Column(name = "EMAIL_ID")
private String emailId;

public Customer() {
}

public Customer(Long customerId) {
this.customerId = customerId;
}

public Long getCustomerId() {
return customerId;
}

public void setCustomerId(Long customerId) {
this.customerId = customerId;
}

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public String getMiddleName() {
return middleName;
}

public void setMiddleName(String middleName) {
this.middleName = middleName;
}

public String getEmailId() {
return emailId;
}

public void setEmailId(String emailId) {
this.emailId = emailId;
}


}

Step 2: Create a EJB 3.0 Session bean.

This session beans uses the Entity Manager for the Create Read Update Delete (CRUD) operations for the Customer Entity we created in Step 1. The CRUD opertions are also published as web methods by adding a few basic annotations.

The Interface:

 
package com.ejb.service;

import com.ejb.domain.Customer;
import java.util.Collection;
import javax.ejb.Remote;

/**
*
* @author meerasubbarao
*/
@Remote
public interface CustomerService {

Customer create(Customer info);

Customer update(Customer info);

void remove(Long customerId);

Collection<Customer> findAll();

Customer[] findAllAsArray();

Customer findByPrimaryKey(Long customerId);
}

The Implementation Class:

package com.ejb.service;

import com.ejb.domain.Customer;
import java.util.Collection;
import javax.ejb.Stateless;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.jws.WebMethod;

/**
*
* @author meerasubbarao
*/
@WebService(name = "CustomerService", serviceName = "CustomerService", targetNamespace = "urn:CustomerService")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@Stateless(name = "CustomerService")
public class CustomerServiceImpl implements CustomerService {

@PersistenceContext
private EntityManager manager;

@WebMethod
public Customer create(Customer info) {
this.manager.persist(info);
return info;
}

@WebMethod
public Customer update(Customer info) {
return this.manager.merge(info);
}

@WebMethod
public void remove(Long customerId) {
this.manager.remove(this.manager.getReference(Customer.class, customerId));
}

public Collection<Customer> findAll() {
Query query = this.manager.createQuery("SELECT c FROM Customer c");
return query.getResultList();
}

@WebMethod
public Customer[] findAllAsArray() {
Collection<Customer> collection = findAll();
return (Customer[]) collection.toArray(new Customer[collection.size()]);
}

@WebMethod
public Customer findByPrimaryKey(Long customerId) {
return (Customer) this.manager.find(Customer.class, customerId);
}


}

Step 3. Compile, Package and Deploy to an application server.

There are no server specific annotations in either the Entity class or the Session bean. Package the entity class, the session bean interface, implemetation class along with the persistence.xml file in a JAR file. Since I am deploying this application to GlassFish, I am using the default persistence provider which is TopLink. Start your application server, and deploy this JAR to it. The contents of persistence.xml file is as shown below:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="SpringAndEJBPU" transaction-type="JTA">
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
<jta-data-source>spring-ejb</jta-data-source>
<properties>
<property name="toplink.ddl-generation" value="drop-and-create-tables"/>
</properties>
</persistence-unit>
</persistence>

Once your application is deployed, make sure you check the JNDI name of your session bean. In GlassFish, click on the JNDI Browsing toolbar button to view the JNDI names.

 

Step 4: Test the Stateless Session beans.

Since my session beans are published as web services, I can just easily test them using either the test page provided by GlassFish application server, or by using SoapUI and make sure that my Customer entity can be persisted using the CustomerService session bean. I am using the default test page provided by Glass Fish for web services:

Step 5: Create a Spring Bean.

Here, I define a simple CustomerManager interface, and an implementation class; just to show how things are wired using Spring.

package com.spring.service;

import com.ejb.domain.Customer;

/**
*
* @author meerasubbarao
*/
public interface CustomerManager {

public void addCustomer(Customer customer);
public void removeCustomer(Long customerId);
public Customer[] listCustomers();


}
package com.spring.service;

import com.ejb.domain.Customer;
import com.ejb.service.CustomerService;

/**
*
* @author meerasubbarao
*/
public class CustomerManagerImpl implements CustomerManager {

CustomerService customerService;

public void setCustomerService(CustomerService customerService) {
this.customerService = customerService;
}

public void removeCustomer(Long customerId) {
customerService.remove(customerId);
}

public Customer[] listCustomers() {
return customerService.findAllAsArray();
}

public void addCustomer(Customer customer) {
customerService.create(customer);
}
}

Step 6: Injecting the EJB 3.0 Session bean into our Spring Beans.

As seen above, I am using setter injection to inject an instance of Customer Service and in turn invoke a method on the Stateless session bean. How do we inject an EJB into a Spring bean? It is quite simple as shown below in the Spring configuration file:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
<jee:jndi-lookup id="customerService" jndi-name="com.ejb.service.CustomerService">
</jee:jndi-lookup>
<bean id="manageCustomer"
class="com.spring.service.CustomerManagerImpl">
<property name="customerService" ref="customerService" />
</bean>
</beans>

The most important aspect here is the wiring of the EJB within the Spring configuration using the <jee:jndi-lookup> element in the jee schema.

<jee:jndi-lookup id="customerService" jndi-name="com.ejb.service.CustomerService">
</jee:jndi-lookup>

Next, we need to wire this with our Spring bean which is done as shown below:

    <bean id="manageCustomer"
class="com.spring.service.CustomerManagerImpl">
<property name="customerService" ref="customerService" />
</bean>

Step 7: Test

How do we know that it works. Lets create a simple class and test.

package com.spring.client;

import com.ejb.domain.Customer;
import com.spring.service.CustomerManager;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringAndEJBMain {

public static void main(String[] args) {
ApplicationContext context =
new ClassPathXmlApplicationContext("SpringXMLConfig.xml");

CustomerManager service = (CustomerManager) context.getBean("manageCustomer");
Customer customer = new Customer();
customer.setFirstName("Meera");
customer.setLastName("Subbarao");
customer.setMiddleName("B");
customer.setEmailId("meera@springandejb.com");
customer.setCustomerId(new Long(1));

service.addCustomer(customer);
for (Customer cust : service.listCustomers()) {
System.out.println(cust.getFirstName());
System.out.println(cust.getLastName());
System.out.println(cust.getMiddleName());
System.out.println(cust.getEmailId());

}
service.removeCustomer(new Long(1));

}
}

And here is the sample output from my IDE:

 

We can go back to our GlassFish web services test page, and test the findAll method. It should have two entities.

In this article, we saw how quick and easy it was to create JPA entities, persist them using Entity Manager from within our session bean. We also saw how easy it was to publish web services by adding a few annotations to our session beans. Next, we saw how to create a simple Spring bean, inject our session bean, and finally call methods on this session bean from our Spring application.

Spring isn't in my opinion a replacement for EJB 3.0, you can mix and match EJB 3.0 and Spring 2.5 components to get the best of both.

Published at DZone with permission of its author, Meera Subbarao.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

John Denver replied on Wed, 2008/08/27 - 3:59am

Nice article,

I use too JPA with Spring and Spring 2.5 got annotations so I dont see much differemce between ejb3 services with spring anottations pojo's. JEE is learning from Spring so I think JEE and Spring are more close than ever.

As you said I could create a ejb3 service and a Spring service in a mix with JPA. It is good to have  in Java land lots of options.

Best Regards.

Note: I really hope JSF2 it is really very easy to use and very easy to create a component as a Pojo and have a choice to use xml template or anottations, Im a big fan of annotations, With all this JEE could Rock again!.

 

Meera Subbarao replied on Wed, 2008/08/27 - 6:21am in response to: John Denver

[quote=alpha512]

Note: I really hope JSF2 it is really very easy to use and very easy to create a component as a Pojo and have a choice to use xml template or anottations, Im a big fan of annotations, With all this JEE could Rock again!.

 

[/quote]

Why don't you use JBoss Seam, it combines EJB 3.0, JPA and JSF right? 

Meera Subbarao

Steve Hicks replied on Wed, 2008/08/27 - 7:48am in response to: Meera Subbarao

Meera,

 

One of the things that interests me at the moment is how much of each stack (Spring or J2EE Standards) to use. In the above example it is mainly using the J2EE Standards with a little bit of Spring. Now one could do the whole thing with Spring and non J2EE technologies (e.g. with Hibernate for persistence)!

Now if you are stuck on older platforms (e.g. WebLogic 9) then it is an easy choice (Spring and since WebLogic 9 has Java 5 then we can use the annotations that were added on Spring 2.x).

If you are using a JEE 5 application server, is there much advantage of going down either route (Spring or J2EE standards?

Meera Subbarao replied on Wed, 2008/08/27 - 8:20am in response to: Steve Hicks

Steve,

This was just an example of showing how to use EJB 3.0 in Spring. I have worked with clients who were using JPA for their persistence tier, EJB's for their business tier, and Spring MVC for their web tier. Of course, they were using JEE 5 compliant server. 

Meera Subbarao

adam bien replied on Wed, 2008/08/27 - 8:37am

Hi Meera,

 

you overengineered the Session Beaan a little bit. Just the two annotations would be enough. So instead providing this:

  1. @WebService(name = "CustomerService", serviceName = "CustomerService", targetNamespace = "urn:CustomerService")  
  2. @SOAPBinding(style = SOAPBinding.Style.RPC)  
  3. @Stateless(name = "CustomerService") 

you could write just this:

@Stateless

@WebService

 

even simpler :-),

 

regards,

 

adam

 

Gabriel Axel replied on Wed, 2008/08/27 - 8:49am

Greetings,

In my opinion, today there is really very little difference between Spring 2.5 and EJB 3.0 for most application developers. However there are three major differences I can think of in favor of Spring in some cases:

  1. EJB from its begining was designed for distributed systems, and still its development model is centered around this idea. Therefore it forces developers to use remote interfaces and JNDI even if the entire system is deployed to a single server and has no interaction with other systems. In Spring you can use JNDI, EJB and any remoting mechanism only if you really need it. Furthermore, Spring is not coupled to the "enterprise model" (DAOs and services deployed on a server and exposed to each other using JNDI or DI), but it can be used for any type of system - enterprise, desktop, mobile, batch etc, and it is up to the developer to decide which features of Spring should be used for the system.
  2. EJB, being a specification which was agreed apon by several vendors, is very limited in in what it provides. In order to add any feature it must go thrugh the entire JSR process, which can take a while. In Spring the process of adding new features is a lot faster and even if SpringSource decides not to add a certain feature, Spring's architecture it extremely plugable and everyone can easily add the desired functionality in any of Spring's extension points.
  3. AOP - not much to say about it: Spring provides a very rich AOP API, much more than that of EJB.

 
As I said, many developers may not care about these points, as in the bottom line EJB 3 does the job, but I think any architect who designs a new system architecture should think about these points and their relevance to the new system, and also some of the infrastructure developers would benefit from using Spring in certain points.

Meera Subbarao replied on Wed, 2008/08/27 - 8:55am in response to: adam bien

[quote=abien]

you could write just this:

@Stateless

@WebService

 

[/quote]

Never tried that. Thanks, Adam. 

Meera Subbarao

adam bien replied on Wed, 2008/08/27 - 9:00am in response to: Gabriel Axel

[quote=guznik]

Greetings,

In my opinion, today there is really very little difference between Spring 2.5 and EJB 3.0 for most application developers. However there are three major differences I can think of in favor of Spring in some cases:

  1. EJB from its begining was designed for distributed systems, and still its development model is centered around this idea. Therefore it forces developers to use remote interfaces and JNDI even if the entire system is deployed to a single server and has no interaction with other systems. In Spring you can use JNDI, EJB and any remoting mechanism only if you really need it. Furthermore, Spring is not coupled to the "enterprise model" (DAOs and services deployed on a server and exposed to each other using JNDI or DI), but it can be used for any type of system - enterprise, desktop, mobile, batch etc, and it is up to the developer to decide which features of Spring should be used for the system.[/quote]

 

Why remote interfaces? Dependency Injection just works fine with local-interfaces, without JNDI... I actually never used DI of @Remote beans  in my projects. It is actually an anti-pattern...

I used EJB 3.0 even on the desktop - why not? They are just POJOs... We had only to write a factory...

Cannot wait for embedded EJB 3.1 support in Glassfish v3  - then we can kill the factory :-).

[quote=guznik]


  1. EJB, being a specification which was agreed apon by several vendors, is very limited in in what it provides. In order to add any feature it must go thrugh the entire JSR process, which can take a while. In Spring the process of adding new features is a lot faster and even if SpringSource decides not to add a certain feature, Spring's architecture it extremely plugable and everyone can easily add the desired functionality in any of Spring's extension points.

[/quote]

Please some real world examples, where EJB 3 are not enough, or where the JCP is an disadvantage. In my eyes vendor-neutrality is huge, strategic benefit.

[quote=guznik] 

AOP - not much to say about it: Spring provides a very rich AOP API, much more than that of EJB.
[/quote]

 

You are right - Spring is more powerful. But: do you know some real world examples, where the power of EJB 3 interceptors isn't enough?

adam bien replied on Wed, 2008/08/27 - 9:02am in response to: Meera Subbarao

You should be careful - otherwise developers might think, that EJB 3 are too complicated :-).

Meera Subbarao replied on Wed, 2008/08/27 - 9:19am in response to: adam bien

[quote=abien]You should be careful - otherwise developers might think, that EJB 3 are too complicated :-).[/quote]

Let me challenge those developers who think EJB 3 is too complicated, to show what I did here with the session bean. Publish their POJOs as web services, and also have remote access with just one interface, one implementation class and a few annotations. No XML at all.

Meera Subbarao

Reza Rahman replied on Wed, 2008/08/27 - 6:12pm

Meera,

Thank you for an excellent article. As you know, these are some of the same ideas myself and Debu forwarded in the Spring and EJB 3 chapter of EJB 3 in Action. I definitely see excellent integration  opportunities for EJB 3 and Spring, just as I see excellent oppotunities for WebBeans/Seam and EJB 3 integration.

Indeed, I am curently working with SpringSource on an EJB 3.1 Lite implementation for the Spring framework/platform that should make such integration even easier (essentially a follow-up to the Spring Pitchfork project intiated by BEA but not followed through).

Cheers,

Reza

Meera Subbarao replied on Wed, 2008/08/27 - 7:28pm

Awesome, Reza. I very well remember the "Spring and EJB 3" chapter in "EJB 3 in Action". Keep us posted on the EJB 3.1 Lite implementation as well.

John Orlando replied on Wed, 2008/08/27 - 8:09pm

As one of the above posters noted this article was more of a "How To" with the new version of ejb and spring. What I would really like to see is a short litmus test that tells me when I have to use one technology over the other. For years I never really learned EJB. I kept it on the back burner in case I needed it for a job but since spring came out I pretty much use it for everything.

 After all these years I still don't understand when I need to use EJB. I'm starting to think that if there were times when I clearly needed one over the other then there would be plenty of blogs that would make it clear. 

 I speak with people who defend EJB but I don't really find their arguments persuasive. 

Any thoughts?

 

Andy Gibson replied on Thu, 2008/08/28 - 12:06am

John, when do you really need to use Spring? It doesn't really offer you anything you can't do yourself. The only difference with EJB really is that the the whole package is bundled together unlike spring where you can modularize the pieces (i.e. not include transaction management).

I've included more thoughts on the EJB vs Spring fan base in this blog post.

Overall, there is really very little difference in this day and age, it all just depends on what you consider important.

 

John Denver replied on Thu, 2008/08/28 - 5:42am in response to: Meera Subbarao

Hi Meera sorry to respond little late.

I use sometime Seam but the problem is not Seam or EJB or JPA or Spring everything is great the problem is JSF(little rant) It is to verbose and complicate to create a custom component that I don't want to touch it anymore, When I work with JSF I use ICEFaces and Spring as a bean, no problem is great,but all the time we need custom components and there come the problem is to complicate to work with it and to verbose really I dislike it. So I hope JSF2 really is simple and easy to create custom components. 

Im working right now in a project that we are using Spring MVC  with Spring 2.5 it is very easy to use and great but always I liked component frameworks I hope for my next project we will use Tapestry 5 looks promising with Spring and EJB3 with JPA.

 Best Regards.

Reza Rahman replied on Thu, 2008/08/28 - 8:52am

Sidewinder,

Indeed the JPA 2.0 EG is trying to make custom component development a lot easier ala Facelets. I think the draft for that is coming out soon. I would encourage you to take a look at it and send in early comments.

Here is the JSR page: http://jcp.org/en/jsr/detail?id=314

Reza

Reza Rahman replied on Thu, 2008/08/28 - 8:58am in response to: Meera Subbarao

Meera,

I'll definitely try to get as much community involvement as I can throughout the project. Right now, I am trying to get the project charter+requirements+high level architecture reveiwed/approved by the SpringSource folks. I am thiking of opening that document up for community review before I start work on the prototype...at this point, the project is likely going to be part of the SpringSource portfolio.

Reza

Meera Subbarao replied on Thu, 2008/08/28 - 9:08am

Thanks for sharing your thoughts, Reza. Will keep an eye on that.

Sandeep Khurana replied on Fri, 2008/08/29 - 1:45am

As per JEE spec "In general, lookups of objects in the JNDI java: namespace are required to return a new instance of the requested object every time. Some exceptions are allowed" . In spring by default (unless configured otherwise) beans are singletons, without making them singleton with private constructor etc. 

Sometime I have utility class(es) which need not be exposed as business interfaces, with spring I can inject those too in my service classes. 

David Sills replied on Fri, 2008/08/29 - 9:36am

Meera:

Nicely done. I couldn't agree more, with my current project heavily dependent upon both technologies. We have chosen to implement our business tier with EJB 3 beans and to implement our web tier using Spring MVC. Of course, Spring offers dozens of other features that have been invaluable along the way (as just one example, creating and sending an email in a few lines of code), and there has been some XML even for the EJB 3 part (more on that later), but overall, it's a very persuasive mix.

Warmly,

David

Steve Hicks replied on Fri, 2008/08/29 - 2:55pm in response to: David Sills

Yep, to provide the best solutions you need to know both the standards and Spring stacks. Knowing what to use in each stack and blending it is quite a useful skill.

 One nice thing about the Spring stack is that you do not need to migrate your application server versions which makes upgrading cheaper (and if the application server administration changes such as from WebLogic 8.1 to 9.X a lot less hassle from your sys admins)

Mohammad Nour El-Din replied on Mon, 2008/09/01 - 5:47am

Hi Meera...

  Thanks for this great article.

Adam Bien...

  I watched your interview published on the java.sun.com site and I really like your opinions about EJB3 and JEE in general. I think it is one the most right opinions I heard about JEE.

 

Reza Rahman...

   I followed all your articles about EJB 3.1. They are great.

 

And now here is what I want to say :)

I think the debate of being Spring better than EJB3 or EJB3 is better than Spring is nonsense. Technologies are made for different flavours. Just like ice cream why we don't have chocolate ice cream only cause customers have different flavours they prefer. And technology customers are technical people like Meera, Adam Bien, Reza Rahman and all people commented on that article or read it including me. and one good thing about ice cream is that you can have different flavours served together like chocolate and vanilla. The same goes with technology. I think we should measure the powerfulness of  a technology by how much standard/common is it and how much it can integrate and cooperate with other technologies. And both apply for Spring and EJB3 and JEE in general. JEE and EJB3 are standards and they are integrated with a lot of other technologies. Spring is a standard in the sense that it is a common well known technology/framework, in other words it is appreciated by a lot of developers - customers of technology - so you can say it is a community standard. Any way I think Meera is trying to show that side of both technologies that is how to get the best of of both of them.

Andy Gibson replied on Mon, 2008/09/01 - 11:33am

"Technologies are made for different flavours."

Yes, but ice cream, and food in general has a purpose,  to provide nutrition and energy to the body. You can get that nutrition and energy using either flavour. In an ideal diet, you would probably end up eating a lot of foods you don't care for and never eating the ones you do like. The point is that with food, nutrition is often secondary to personal taste.

 In technology, we use frameworks to deliver a solution, and we can use either Spring or EJB to get the job done. The reason we pick one over the other is because just like ice cream, it is down to personal taste.

Mohammad Nour El-Din replied on Tue, 2008/09/02 - 4:33am in response to: Andy Gibson

Thanks agibson you clarified what I wanted to say in a more accurate way :) . It is all about personal taste.

Meera Subbarao replied on Tue, 2008/09/02 - 8:07am in response to: Mohammad Nour El-Din

That indeed was a good analogy.

Meera Subbarao

Irshad Ahmed replied on Sat, 2008/12/20 - 8:34am

A good article. How do we make sure that this way of injection works on all the application servers viz, JBoss, Weblogic, Websphere, Oracle? All of these servers have a different way of exposing remote session beans in the jndi tree. --Irshad

David Sills replied on Sat, 2008/12/20 - 11:06am

Fortunately, though at the moment the JNDI names will be different from one server to another, EJB 3.1 is coming, where there will be a standard. The names in the Spring XML file may have to be changed from one server to another, but they will all work (this is what Ant was made for, of course). See Meera's excellent article on EJB 3.1 for more about that topic.

Of course, if you use the available XML descriptors to override the defaults, you are pretty much in control.

 

Meera Subbarao replied on Sat, 2008/12/20 - 11:07am in response to: Irshad Ahmed

[quote=ibuchh]How do we make sure that this way of injection works on all the application servers viz, JBoss, Weblogic, Websphere, Oracle? All of these servers have a different way of exposing remote session beans in the jndi tree. --Irshad [/quote]

The only way to know that it works on all these app servers is to write test for each and every server.

Meera Subbarao

Antonio De Vitis replied on Tue, 2009/11/24 - 12:45pm

Hi First of all,thanks for this article! But i Have a problem with run a little esample project,you can see at this link(JBoss Forum): http://www.jboss.org/index.html?module=bb&op=viewtopic&t=164202 I'm searching for a solution since three day but nothing. Hope that you can help me.Thank you!

Katchapakesan T... replied on Sun, 2011/02/06 - 8:18am

Meera, Please tell me how to integrate JSF2.0 with EJB3.0 and spring 2.5 framework. Which version of the eclipse should I use? and Which are the jars i need to include for the application using above said technologies? Because we are starting next project which is related to ERP domain...so we need some help from you people! Thanks, Katchapakesan Thamotharan

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.