A Developers Perspective on Spring vs JavaEE

In Java community Spring vs JavaEE is a never ending debate. In such debates people form two groups consisting of evangelists, architects and hard core fans of one platform and debate endlessly. Those who participate in the debates may be architects who are responsible for platform selection. But what would developers think about this Spring vs JavaEE debate?

I am a Java developer who uses both Spring and JavaEE and I am not part of Spring or JavaEE fan club. Here I would like to share my own thoughts on this epic Spring vs JavaEE debate.

1. Business(sometimes political) Aspects
In many organizations technology selection may not completely depends on developers choice. More specifically if you are working in so called giant enterprise organizations there are high chances that there is an Architecture Team who will decide what platform/language/framework/libraries to use in the projects.

In addition to that, large enterprises also considers the following aspects while choosing the technology platform:

  • Maturity of the platform/language/framework/libraries
  • Commercial support
  • Licensing cost etc etc

As a developer I can hardly influence the decision making process for any of the above aspects, especially when I am a developer in offshore development center. So I don’t worry too much about these things.

2. If you are really good at Spring/JavaEE then learning the other one shouldn’t be difficult
I am always surprised when someone says I am JavaEE expert but I can’t understand Spring or vice-versa. Both JavaEE and Spring work on the same core APIs (Servlet, JPA, JMS, BeanValidation etc), the difference is who is gluing the things together, Spring or AppServer.

Even though there are some different APIs for things like dependency injection (Spring DI, CDI), REST (JAX-RS, SpringMVC) etc they look and behave pretty similar to each other.

May be someone can say CDI is more typesafe than Spring DI. Doesn’t Spring and CDI behaves similarly when:

  • Injection using @Autowired or @Inject works fine if there is only one Spring/CDI Bean
  • Injection fails when there are more than one Spring or CDI bean implementations by throwing errors saying “Found more than one eligible beans that can be inject”
  • Use @Produces or @Bean annotated method to provide custom made objects as bean providers

As long as they are behaving similarly I don’t care whether they are implemented in more typesafe manner or used String based mappings in their internal implementations.

How can one be expert in Spring and can’t understand JavaEE and vice-versa?? How much time it can take for a Spring expert to learn JavaEE??!!

3. Which is more “Average Joe developer” friendly
I think by now many people should have realized that success of a technology may not be completely depends on its merits, but also based on developers adoption. The most important thing to realize is “Not every software developer is a rock star developer. There are more average joe developers than passionate, tech ninjas”. So in order to people adapt any framework it should be “Average Joe Developer” friendly.

I think Spring is doing pretty good job at it by providing more tools like SpringBoot, User Guides etc. Spring Security, Spring Integration, Spring XD, Spring Social addresses the modern business needs very well. Also think about various templates provided by Spring which makes easy to do things without worrying about boilerplate coding.

JavaEE is also doing very well by introducing JBossForge, Wildfly Swarm etc to quickly get started. I came across few JavaEE based frameworks like Picketlink which addresses Security requirements, but I felt it is much more complex than it should be.

The point I am trying to convey is “You can do pretty much everything in JavaEE that you can do with Spring”. The difference is which is giving more out-of-the-box to average joe developer.

4. Lame arguments without context
Whenever Spring vs JavaEE debate arises people form two groups and debate endlessly.  Unfortunately the debates focus on some useless or outdated points.

XML heavy: 
JavaEE fans first start saying Spring is XML heavy and I hate XML blah blah blah. If you are still using Spring older than version 2.5 and assuming it is still same XML based then my friend you should wake up and head to http://spring.io

EJBs are bad (or) JSF is bad
Spring fans jump on to bashing EJB and JSF as if they are same as EJB 2.x or JSF 1.x. If they really look at EJB 3.x and JSF 2.x then they wouldn’t argue on this at all. Don’t judge EJB 3.x with your 6 years back EJB2.x experience.

Heavy weight or light weight
My interpretation of this ‘weight’ thing is based on runtime foot print. To my knowledge, when you deploy your managed beans into JavaEE container then container will proxy it and inject all enterprise services (Transactions, Security etc) and in case of Spring it will be done by Spring AOP.
I don’t have any metrics to say which is more heavy weight Container Proxy or SpringAOP Proxy, but I guess there may not be significant difference.

Some people consider the size of war file as its ‘weight’. In that case compare (JavaEE AppServer + war) size with (SpringApp with 126 jars) and see which is light weight 🙂

JavaEE is standards based
Come on guys!!!!

Vendor lock-in
I think choosing a platform which doesn’t make you stick with one particular vendor is good. But going with an option purely based on the ability to move to a different implementation is not correct. How many times in an year you switch from one server to another? Choosing a platform which doesn’t lock you with a vendor is a ‘nice to have’ but it should not be major factor to choose your platform.

We don’t need external libraries
This is called “Arguing for the sake of arguing”. Show me any real application without having any dependencies. If you say I will develop my own logging library, I will write my own HTTP client, I will develop my own common-utilities then you need to look for a little bit more lazy architect/developers who doesn’t have “Re-invent all the wheels” sickness.

5. Don’t look at the crowd and say “You are all idiots because you are using X, you should migrate to Y”.
This is a common pattern that I observe on many community sites, especially on Reddit. Just post anything related to JavaEE vs Spring thing and there will be two groups who bash the other group like anything because other group are not using their favorite platform.

Think for a minute. If Spring is not any good why so many people use it and love it. If JavaEE is not good why so many people switch from Spring to JavaEE. There is so many good things in each platform. Respect others for choosing whatever option they choose. If possible ask them the reasons why they went with one over the other and learn if you miss anything.

Just saying “You all are idiots for not using my favorite option” doesn’t make them use your favorite technology. In fact it triggers the thought to come up with list of points why your favorite platform sucks.

If you really want them to switch to your favorite platform then show the reasons with code examples. Show them how easy it is to develop applications using your favorite platform with sample applications. Write more articles on commonly facing issues and how to resolve them. Get the “Average Joe Developer” on-board onto your favorite platform.

As an enthusiastic Java developer I read the Spring vs JavaEE discussions hoping there might be few things which I don’t know such as “in which areas one is better than the other”. But I find 70% of discussions goes on lame arguments which is not very interesting to me.

I wish Spring and JavaEE camps to fight more and more and made their platform superior than the other. End of the day, no matter who win the debate ultimately developers will have more powerful platforms.

Spring3+JPA2+JavaEE6AppServer = Confusion Over Configuration

Spring is great, JavaEE6 is great and latest JavaEE6 Application servers are also great. This post is not a rant on Spring Vs JavaEE6, but my experience of porting a Spring3+JPA2(Hibernate) application on JBoss AS-7.1 App Server.

My application requirement is very simple: Developing a couple of SOAP based webservices using Spring3.1 and JPA2(Hibernate) and host it on JBoss AS 7.1.

So I started creating a multi-module maven project with one jar module containing the service implementations using Spring & JPA and another war module which exposes those services as SOAP based webservices. But the key part is services needs to talk to multiple databases for some of the service methods.

 I am aware of JPA2 integration support from Spring without persistence.xml and cool packagesToScan attribute which makes life a bit easier. I configured 2 dataSources, 2 LocalContainerEntityManagerFactoryBeans, registered 2 JpaTransactionManagers and enabled Annotation based Transaction Management Support.

	<tx:annotation-driven transaction-manager="txnManager1"/>
<tx:annotation-driven transaction-manager="txnManager2"/>

<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/><!-- This will throw error because it found multiple EntityManagerFactory beans -->

<bean id="txnManager1"
class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="emf1"/>

<bean id="txnManager2"
class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="emf2"/>

<bean id="emf1" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="Sivalabs1PU"></property>
<property name="dataSource" ref="dataSource1"></property>
<property name="jpaVendorAdapter">
<bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:showSql="${hibernate.show_sql}"/>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
</props>
</property>
<property name="packagesToScan" value="com.sivalabs.springdemo.entities"></property>
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
</property>

</bean>

<bean id="emf2" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="Sivalabs2PU"></property>
<property name="dataSource" ref="dataSource2"></property>
<property name="jpaVendorAdapter">
<bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:showSql="${hibernate.show_sql}"/>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
</props>
</property>
<property name="packagesToScan" value="com.sivalabs.springdemo.entities"></property>
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
</property>

</bean>

<bean id="dataSource1" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${node1.jdbc.driverClassName}"></property>
<property name="url" value="${node1.jdbc.url}"></property>
<property name="username" value="${node1.jdbc.username}"></property>
<property name="password" value="${node1.jdbc.password}"></property>
</bean>

<bean id="dataSource2" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${node2.jdbc.driverClassName}"></property>
<property name="url" value="${node2.jdbc.url}"></property>
<property name="username" value="${node2.jdbc.username}"></property>
<property name="password" value="${node2.jdbc.password}"></property>
</bean>

After this I realized to bind Entitymanager with the correct PersistenceUnit I need to give persistenceUnitName to LocalContainerEntityManagerFactoryBean.

	
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor">
<property name="persistenceUnits" >
<map>
<entry key="unit1" value="Sivalabs1PU"/>
<entry key="unit2" value="Sivalabs2PU"/>
</map>
</property>
</bean>

<bean id="emf1" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="Sivalabs1PU"></property>
<property name="dataSource" ref="dataSource1"></property>
....
....
</bean>

<bean id="emf2" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="Sivalabs2PU"></property>
<property name="dataSource" ref="dataSource2"></property>
....
....
</bean>

Then in my Service Bean EntityManagers and transaction managers are glued together as follows:

@Service
public class AdminUserService implements UserService
{
@PersistenceContext(unitName="Sivalabs1PU")
private EntityManager sivalabs1EM;
@PersistenceContext(unitName="Sivalabs2PU")
private EntityManager sivalabs2EM;

@Override
@Transactional("txnManager1")
public List<User> getAllUsersFromSivalabs1DB() {
return sivalabs1EM.createQuery("from User", User.class).getResultList();
}

@Override
@Transactional("txnManager2")
public List<User> getAllUsersFromSivalabs2DB() {
return sivalabs2EM.createQuery("from User", User.class).getResultList();
}

}

With this setup now I got the Exception saying “No persistence unit with name ‘Sivalabs1PU’ found“. Then after some googling I created META-INF/persistence.xml file as follows:

<persistence>

<persistence-unit name="Sivalabs1PU" transaction-type="RESOURCE_LOCAL">
</persistence-unit>

<persistence-unit name="Sivalabs2PU" transaction-type="RESOURCE_LOCAL">
</persistence-unit>

</persistence>

Now the persistence unit name error got resolved and got other Exception saying “User is not mapped [from User]“. The User class is annotated with @Entity and is in “com.sivalabs.springdemo.entities” package which I configured to “packagesToScan” attribute. I didn’t understand why “packagesToScan” attribute is not working which is working fine without persistence.xml. So for time being I configured entity classes in persistence.xml file.

<persistence>

<persistence-unit name="Sivalabs1PU" transaction-type="RESOURCE_LOCAL">
<class>com.sivalabs.springdemo.entities.User</class>
</persistence-unit>

<persistence-unit name="Sivalabs2PU" transaction-type="RESOURCE_LOCAL">
<class>com.sivalabs.springdemo.entities.User</class>
</persistence-unit>

</persistence>

Finally when I ran my JUnit Test which invokes AdminUserService methods everything looks good and working fine. Then I deployed the war file on JBoss AS 7.1 Server then again got a bunch of errors. JBoss is complaining that “Connection cannot be null when ‘hibernate.dialect’ not set” …. “[PersistenceUnit: Sivalabs1PU] Unable to build EntityManagerFactory”.

After thinking for a couple of minutes, I understood that JBoss server is trying to do what it is supposed to do with “Convention Over Configuration” rules. JBoss is trying to create EntityManagerFactory because it found META-INF/persistence.xml in classpath. But as it doesn’t contain jdbc connection details its throwing Error. 

Again after some googling I found we can rename persistence.xml to something else(spring-persistence.xml) and hook up this new name with Spring as follows:

	<bean id="emf1" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="Sivalabs1PU"></property>
<property name="persistenceXmlLocation" value="classpath:META-INF/spring-persistence.xml"/>
<property name="dataSource" ref="dataSource1"></property>
....
....
</bean>

<bean id="emf2" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="Sivalabs2PU"></property>
<property name="persistenceXmlLocation" value="classpath:META-INF/spring-persistence.xml"/>
<property name="dataSource" ref="dataSource2"></property>
....
....
</bean>

Finally I got this application working on my JBoss AS 7.1 successfully(Still I don’t know how many other holes are there that I haven’t yet found).

But here I didn’t understand few Spring concepts:
1. When I try to give persistenceUnitName why Spring is checking for that name to be existed in persistence.xml? Anyway that persistence.xml doesn’t contain anything exception the unit-name!!

2. Why packagesToScan mechanism is failing when used with persistence.xml? Is it a Spring Bug?

Everything seems to be working fine except one thing is missing, a smile on my face which usually I have when working with Spring and Tomcat 🙁

I like Spring framework very much and I am using it since 2006 and I do enjoy while writing Spring code. That doesn’t mean I don’t like CDI, EJB3, JAX-RS 🙂

 Anyway, with all the above exercise I feel like Spring3+JPA2+JavaEE6AppServer=Confusion Over Configuration and it is my(an average java developer) opinion only.

Again say one more time : Spring is great, JavaEE6 is great and latest JavaEE6 Application servers are also great :-).

Keep The Code Clean: WatchDog & SpotTheBug Approach

Before going to discuss “WatchDog & SpotTheBug Approach“, let me give a brief context on what is the needs for this.

Three months back I was asked to write core infrastructure code for our new application which uses all the latest and greatest technologies.
I have written the infrastructure code and implemented 2 usecases to demonstrate which logic should go into which layer and the code looks good(atleast to me :-)). Then I moved on to my main project and I was hearing that the project that i designed(from Now on-wards I will refer this as ProjectA) is going well.

After 3 months last week one of the developer of ProjectA came to me to help him in resolving some JAXB Marshalling issue. Then I imported the latest code into eclipse and started looking into the issue and I was literally shocked by looking at the messy code. First I resolved that issue and started looking into whole code and I was speechless. How come the code become such a mess in this short span of time, it is just 3 months.

  • There are Date Formatting methods in almost every Service class(Copy&Paste with different names)
  • There are Domain classes with 58 String properties and setters/getters. Customer class contains homeAddressLine1, homeAddressLine2, homeCity.., officeAddrLine1, officeAddrLine2, officeCity… There is no Address class.
  • In some classes XML to Java marshaling is done using JAXB and in some other classes using XStream and in some other places constructing XML string manually even though there is core utilities module with lots of XML marshaling utility methods.
  • In some classes SLF4J Logger is used and in some places Log4J Logger is being used.

and the list goes on…

So what just happend? Where is the problem?

We started this project by pledging to keep the code clean and highly maintainable/enhanceable. But now it is in worst possible state.

Somehow it is understandable if the code is legacy code and is messy because today’s latest way of doing things becomes tomorrow’s legacy and bad approach like externalizing the application configuration into XML was the way to go sometime back and now it became XML hell with shiny new Annotations. I am pretty sure that in a couple of years we will see “Get Rid of Annotation Hell by Using SomeNew Gr8 Way”. 

But in my case it is just 3 months old project.

When I think about the causes of why that code becomes such a mess I end-up with never-ending list of reasons:

  • Tight dead lines
  • Incompetent developers
  • Not using code quality checking tools
  • No code reviews
  • No time to clean the messy code

etc etc

So whatever the reason your code will become messy after sometime, especially when more number of people are working the project.

The worst part is you can’t blame anyone. Developer will say I have no time to cleanup the code as I have assigned high priority tasks. Tech Lead is busy in analysing and assigning the new tasks to developers.
Manager is busy in aggregating the team’s task status reports to satisfy his boss. Architect is busy in designing the new modules for new third party integration services. QA people are busy in preparing/executing their test cases for upcoming releases.

So whose responsibility it is to clean the code? Or in other way, How can we keep code clean even with all the above said Busy circumstances?

Before going to explain How “WatchDog & SpotTheBug Approach” works let me tell you another story.

3 years back I worked on a banking project which is well designed, well organised and well written code that I have ever seen so far. That project started almost 10 years back, but still the code quality is very good. How is it possible?

The only reason is If any developer check-in the code with some bad code like adding duplicate utility methods then within 4 hours that developer will recieve an email from a GUY asking for the explanation what is the need to add that method when that utility method is already available in core-utilities module. In case there is no valid reason, that developer has to open a new defect with “Cleaning Bad Code” in the defect title, assign the defect to himself and change the code and should check-in the files ASAP.

With this process, every team member in our team used to tripple check the code before checking into repository.

I think this is best possible way to keep the code clean. By now you may have clue on what I mean by “WatchDog”. Yes, I called the GUY as WatchDog. First of all, sorry for calling such an important role as Dog but it better describe what that guy will do. It will bark as soon as it saw some bad code.

Need for WatchDog:

As I mentioned above, everyone in the team might be busy with their high-priority tasks. They might not be able to spend time on cleaning the code. Also from the Business perspective Adding new customer-requested features might be high-priority than cleaning the code. Sometime even though Business know that in long run there is a chance that entire application becomes un-maintainable if they don’t cleanup the mess they will have to satisfy their customer first with some quick new features and will opt for short-term benefits.

We have plenty of Quality Checking tools like PMD, FindBugs, Sonar. But does these tools suggest to create an Address class instead of repeating all address properties for different type of addresses as i mentioned above. Does these tools suggest you to use same xml marshalling library across the project. As far as I know, they won’t.

So if you really want your software/product to sustain over time, I would suggest to hire a dedicated WatchDog(Human Being).

The WatchDog’s primary responsibilities would be:

  • Continuously checking for the code smells, duplicate methods, coding standards violations and send the report to entire team.
  • If possible point out the existing utility to use instead of creating duplicate methods.
  • Checking for design violations like establishing Database Connection or Transaction management code in wrong places(web layer for ex).
  • Checking for cyclic dependencies for between modules.
  • Exploring and suggesting well established, tested generic libraries like apache commons-*.jars, Google Guava instead of writing home grown solutions(I feel like instead of writing home grown Cache Management better to use Guava Cache,but YMMV)

So far so good if the WatchDog does its job well. What if the WatchDog itself is inefficient?? What if WatchDog is not Skilled enough to perform its job? Who is going to check whether WatchDog is doing good or not?  Here “SpotTheBug” program comes into picture.

“SpotTheBug”
I strongly believe in having a friendly culture to encourage the developers to come up with thoughts to better the software.

Every week each team member should come up with 3 points to better/clean the code. They can be: Bad code Identification, Better Design, New Features etc.

Instead of just saying that code is bad code, he has to specify why he is feeling that code is bad, how to rewrite it in better way and what would be the impact.

Based on the effectiveness of the points, value-points should be given to the developer and those points should definitely be considered in performance review(There should be some motivation right :-)).

With WatchDog and SpotTheBug programs in place, if the team can identify the bad code before the WatchDog caught it then it is going to be a negetive point for WatchDog. If WatchDog continuously getting negative points then it is time to evaluate the effectiveness of WatchDog itself.

By using this WatchDog & SpotTheBug approach combined with proper usage of Code Quality Checking Tools(FindBugs, PMD, Sonar) we can make sure the code is clean to the maximum extent.


What additional features do JavaEE6 have to move from Spring?

I am a senior java developer who has to work on the technologies chosen by the application architect.
At the maximum I can express my opinion on a particular technology, I can’t make/influence technology selection decision. So I don’t have a choice of moving from Spring to JavaEE6 or from JavaEE6 to Spring on my official projects.

I strongly believe that as a Java developer I have to keep updated on (at least few) latest technologies.
So I(many java developers) generally follow java community websites or blogs to have an idea on whats going on in java community. Specifically I do follow updates from some Java Champions or well known popular authors because they might have better vision on what is next big thing in Java space.

Few years back I have seen so many people talking about Spring. Then I started learning Spring and still I just love it. I have been using JavaEE5 for a couple of years and I didn’t find any feature which Spring is not providing. But recently I am seeing so many articles on “Moving from Spring to JavaEE6” for every couple of days. So I thought of giving it a try, I installed NetBeans7.1, Glassfish3.1 and did a simple POC. Its wonderful, I am able to write a simple app in just 10 min.
Yes, JavaEE6 improved a lot over it predecessors.

But again I am not seeing anything new which I can’t do with Spring.
OK, let me share my thoughts on the criteria that is chosen by “Moving from Spring to JavaEE6” article authors.

1. So many Jars in WEB-INF/lib
Spring application has its dependencies in WEB-INF/lib and JavaEE6 app will have in server lib.
Even for Spring app, we don’t need to go and manually download all those Jars, we can use Maven/Ivy or even we can start with an archetype template with all dependencies configured. And its only onetime Job.
I am not sure will there be any performance improvement by having jars in server lib instead of WEB-INF/lib. If that is the case we can place Spring app dependencies in server lib.

What I am missing here?

2. Type-safe Dependency Injection
From Spring 2.5 we have annotation based DI support using @Autowired and if you are still saying Spring is XML based please take a look at Spring 3.x.
If you want to give a custom-name to spring bean(in case of multiple implementation for same Interface), you can.
How is it different from JavaEE6’s CDI @Injext and @Named?

3. Convention Over Configuration
EJB3 methods are transactional by default, just slap it with @Stateless.
In Spring we can create a custom StereoType, say @TransactionalServe, like

@Service
@Transactional
public @interface TransactionalServe
{

}
and we can achieve Convention Over Configuration.
Did I miss anything here?

4. Spring depends on JavaEE
Of course Spring depends on JavaSE and JavaEE. Spring is just making the development easier.
You can always use JavaEE APIs like JSF, JPA, JavaMail etc with Spring in easier way.
Did anybody said Spring came to completely vanish JavaEE?? No.

5. Standards based, App Server Support, License blah blah blah.
These are the things that developers don’t have much(any) control.
From a developer perspective, we love whatever makes development easier.

So I am not seeing any valid reason to migrate an existing Spring app to JavaEE6. Till now I didn’t find one thing which CDI can do and Spring can’t do. For green field projects just to have depency injection we might not need Spring as we already have CDI in-built in JavaEE6.

Does JavaEE6 address any of the following:
1. Batch Processing: Almost all the big enterprises have some batch jobs to run. Does JavaEE6 have any support for implementing them.
Do you suggest to use Spring Batch or start from scratch in vanilla JavaEE6.
2. Social Network Integration: These days it became very common requirement for web apps to integrate with Social Network sites.
Again what do you have in JavaEE6 for this?
3. Environment Profiles: In Spring I can have my mock services enabled in Testing profile and my real services in Production profile.
I am aware of @Alternative, but can we configure more than 2 Alternatives without using String based injection?
4. Web application Security: What is Spring-security’s counter part in JavaEE6?
5. What about integration with NoSQL, Flex, Mobile development etc?

JavaEE6 got CDI now, so suddenly Spring become legacy!!!!

Conclusion: Yeah JavaEE6 has cool stuff now(lately??) but it is not going to replace Spring anyway. Long live Spring.