<p>My team is developing a new service oriented product with a web front-end.  In discussions about what technologies we will use we have settled on running a JBoss application server, and Flex frontend (with possible desktop deployment using Adobe AIR), and web services to interface the client and server.</p>

<p>We've reached an impasse when it comes to which server technology to use for our business logic.  The big argument is between EJB3 and Spring, with our biggest concerns being scalability and performance, and also maintainability of the code base.</p>

<p>Here are my questions:</p>

<ol>
<li>What are the arguments for or against EJB3 vs Spring? 

<ul>
<li>What pitfalls can I expect with each?</li>
<li>Where can I find good benchmark information?</li>
</ul></li>
</ol>

[{'answer_id': 68798, 'author': 'rustyshelf', 'author_id': 6044, 'author_profile': 'https://Stackoverflow.com/users/6044', 'pm_score': 3, 'selected': False, 'text': "<p>I would definitely recommend EJB3 over spring. We find that it's more streamlined, nicer to code in, and better supported. I have in the past used Spring and found it to be very confusing, and not as well documented as EJB3 (or JPA I guess at the end of the day)</p>\n\n<ol>\n<li>As of EJB3 you no longer have to deal with external config files, and there's only one POJO that you annotate per database table. This POJO can be passed to your web tier without any problems. IDEs like Netbeans can even auto-generate these POJOs for you. We've used EJB3 now as the back end for quite a few large scale applications, and haven't noticed any performance problems.\nYour Session Beans can be easily exposed as web services which you could expose to your Flex frontend.\nSession beans are easy to lock down at either a method or class level to assign roles and things like that if you need to.</li>\n</ol>\n\n<p>I can't speak that much about spring, as I only tried it out for a few weeks. But my overall impression of it was very poor. That doesn't mean it's bad framework, but our team here has found EJB3 to be the best for the persistence/business layer.</p>\n"}, {'answer_id': 69467, 'author': 'Brian', 'author_id': 700, 'author_profile': 'https://Stackoverflow.com/users/700', 'pm_score': 4, 'selected': False, 'text': '<p><strong>What are the arguments for or against EJB3 vs Spring?</strong>\nSpring is always innovating and recognizes real-world constraints. Spring offered simplicity and elegance for the Java 1.4 application servers and didn\'t require a version of the J2EE specification that no one had access to in 2004 - 2006.  At this point it is almost a religious debate that you can get sucked into - Spring + abstraction + open-source versus Java Enterprise Edition (Java EE) 5.0 specifications.  </p>\n\n<p>I think Spring <strong>complements more than competes</strong>  with the Java EE specifications. As the features that were once unique to Spring continue to get rolled into the specification, many will argue that EJB 3 offers a \'good enough\' feature set for most internal business applications.</p>\n\n<p><strong>What pitfalls can I expect with each?</strong>\nIf your treating this as persistence issue (Spring+JPA) versus EJB3 your really not making that big of a choice.</p>\n\n<p><strong>Where can I find good benchmark information?</strong>\nI haven\'t followed the <a href="http://www.spec.org/jAppServer2004/results/jAppServer2004.html" rel="nofollow noreferrer">specj benchmark results</a> for sometime, but they were popular for a while.  It seems that each vendor (IBM, JBOSS, Oracle, and Sun) get less and less interested in having a compliant server.  The lists get Shorter and shorter of certified vendors as you go from 1.3, 1.4. 1.5 Java Enterprise Edition.  I think the days of a giant server that is fully compliant with all the specifications are over.</p>\n'}, {'answer_id': 69595, 'author': 'Soumitra', 'author_id': 10844, 'author_profile': 'https://Stackoverflow.com/users/10844', 'pm_score': 2, 'selected': False, 'text': '<p>i have used a very similar architecture in the past. Spring + Java 1.5 + Actionscript 2/3 when combined with Flex Data Services made it all very easy (and fun!) to code. \nthough, a Flex front end means you need adequately powerful client machines.</p>\n'}, {'answer_id': 71582, 'author': 'John Stauffer', 'author_id': 5874, 'author_profile': 'https://Stackoverflow.com/users/5874', 'pm_score': 7, 'selected': True, 'text': "<p>There won't be much difference between EJB3 and Spring based on Performance. We chose Spring for the following reasons (not mentioned in the question):</p>\n\n<ul>\n<li>Spring drives the architecture in a direction that more readily supports unit testing. For example, inject a mock DAO object to unit test your business layer, or utilize Spring's MockHttpRequest object to unit test a servlet. We maintain a separate Spring config for unit tests that allows us to isolate tests to the specific layers.</li>\n<li>An overriding driver was compatibility. If you need to support more than one App Server (or eventually want the option to move from JBoss to Glassfish, etc.), you will essentially be carrying your container (Spring) with you, rather than relying on compatibility between different implementations of the EJB3 specification.</li>\n<li>Spring allows for technology choices for Persistence, object remoting, etc. For example, we are also using a Flex front end, and are using the Hessian protocol for communications between Flex and Spring.</li>\n</ul>\n"}, {'answer_id': 73997, 'author': 'James Strachan', 'author_id': 2068211, 'author_profile': 'https://Stackoverflow.com/users/2068211', 'pm_score': 3, 'selected': False, 'text': '<p>I tend to prefer Spring over EJB3 but my recommendation would be whichever approach you take, try to stick to writing POJOs and use the standard annotations where possible, like the JSR annotations such as @PostConstruct, @PreDestroy and @Resource which work with both EJB3 or Spring so you can pick whichever framework you prefer. </p>\n\n<p>e.g. you could decide on some project to use Guice instead for IoC.</p>\n\n<p>If you want to use pre-request injection such as in a web application you might find Guice is quite a bit faster for dependency injection than Spring.</p>\n\n<p>Session beans mostly boil down to dependency injection and transactions; so EJB3 and Spring are kinda similar really for that. Where Spring has the edge is on better dependency injection and nicer abstractions for things like JMS</p>\n'}, {'answer_id': 343833, 'author': 'PEELY', 'author_id': 17641, 'author_profile': 'https://Stackoverflow.com/users/17641', 'pm_score': 5, 'selected': False, 'text': "<p>The gap between EJB3 and Spring is much smaller than it was, clearly. That said, one of the downsides to EJB3 now is that you can only inject into a bean, so you can end up turning components into beans that don't need to be.</p>\n\n<p>The argument about unit testing is fairly irrelevant now - EJB3 is clearly designed to be more easily unit testable.</p>\n\n<p>The compatibility argument above is also kind of irrelevant: whether you use EJB3 or Spring, you're still reliant on 3rd party-provided implementations of transaction managers, JMS, etc.</p>\n\n<p>What would swing it for me, however, is support by the community. Working on an EJB3 project last year, there just weren't a lot of people out there using it and talking about their problems. Spring, rightly or wrongly, is extremely pervasive, particularlty in the enterprise, and that makes it easier to find someone who's got the same problem you're trying to solve.</p>\n"}, {'answer_id': 343996, 'author': 'kamal.gs', 'author_id': 43605, 'author_profile': 'https://Stackoverflow.com/users/43605', 'pm_score': 0, 'selected': False, 'text': '<p>Another thing in favor of spring is that most of the other tools / frameworks out there have better support for integration with spring, most of them use spring internally as well (e.g. activemq, camel, CXF etc).</p>\n\n<p>It is also more mature and there are a lot more resources (books, articles, best practices etc) &amp; experienced developers available than for EJB3.</p>\n'}, {'answer_id': 5073365, 'author': 'HARIKRISHNAN RAMAKRISHNA PILLA', 'author_id': 627593, 'author_profile': 'https://Stackoverflow.com/users/627593', 'pm_score': -1, 'selected': False, 'text': '<p>I think EJB is a good component technology but not a good framework.Spring is the best framework available as of today.So i should consider Spring as the best implementation of JEE in the sense of a framework and my recommendation is to use spring in every project which gives us  the flexibility to integrate with any component technology easily .</p>\n'}, {'answer_id': 8721182, 'author': 'krams', 'author_id': 228837, 'author_profile': 'https://Stackoverflow.com/users/228837', 'pm_score': 1, 'selected': False, 'text': '<p>Regarding your question: </p>\n\n<blockquote>\n  <p>What are the arguments for or against EJB3 vs Spring?</p>\n</blockquote>\n\n<p>I suggest reading the response from the experts: <a href="http://blog.springsource.org/2007/11/09/a-response-to-ejb-3-and-spring-comparative-analysis/" rel="nofollow">A RESPONSE TO: EJB 3 AND SPRING COMPARATIVE ANALYSIS by Mark Fisher</a>. Read the comments to find Reza Rahman\'s remarks (EJB 3.0).</p>\n'}]
['https://Stackoverflow.com/questions/68527', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/92/']