• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using EJB3.1 with Spring 3.1

 
Greenhorn
Posts: 10
MS IE Netbeans IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I'm really hoping that somebody can explain this one to me I know that it's really simple but I'm missing the barn door somewhere, pardon the ranch reference! Anyway to explain. I'm using a simple system to learn spring which involves an online book library. The user logs in and the system uses custom validation, just grabbing user data from the DB to validate. The persistence layer is in EJB3.1 with the user entity, over that we have a @Stateful bean and a userFacade object implementing a UserFacade interface.

I have a service object which is a spring bean to handle the façade object.

The data is passing from the page to the service object's validate method quite happily but then I get a NullPointerException in the method call. This is because the façade object is not instantiated.

Can anybody point out where I am have lost the plot.
I have loads of books but they only go to spring 3.0 and I could use some advice here.

Do I need to use a lookup() with data in the applicationConfiguration file if so ok I know where to go for that info. If not what do I need to do.

The classes I have used are below for reference;-

UserContoller class



The userService class;-



The userFacade class;-

public UserFacade() {
super(User.class);
}

 
james loveay
Greenhorn
Posts: 10
MS IE Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry
Posted before I could say a thank you to anybody able to point me in the right direction>
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have never found the need to mix the 2. I just use Spring for all of my DI. I know it can be done, but I personally don't see the advantage in it. I would use one or the other personally.

I did find this:
http://what-when-how.com/enterprise-javabeans-3/combining-the-power-of-ejb-3-and-spring/
http://static.springsource.org/spring/docs/3.2.1.RELEASE/spring-framework-reference/htmlsingle/#ejb

Spring does have inbuilt support for some of the JSR-250 and JSR-330 annotations see:
http://static.springsource.org/spring/docs/3.2.1.RELEASE/spring-framework-reference/htmlsingle/#integration-testing-annotations-standard
and
http://static.springsource.org/spring/docs/3.2.1.RELEASE/spring-framework-reference/htmlsingle/#beans-standard-annotations
 
james loveay
Greenhorn
Posts: 10
MS IE Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bill Gorder wrote:I have never found the need to mix the 2. I just use Spring for all of my DI. I know it can be done, but I personally don't see the advantage in it. I would use one or the other personally.



Hi Bill,

Many thanks for your reply,

It was a great help. The sources confimed what I thought was the rightr way to go but always better having a wiser head show the path than to stumble around in the dark.

Anywho! totally agree with you that Spring is very good at handling everything I need for the project but then tah would be too easy!

Seriously the EJB were developed for another project I worked to learn the Struts framework and I wanted to re-use them instead of going the long route and re-building everything using spring, which would have been much easier.

Again many thanks.
 
james loveay
Greenhorn
Posts: 10
MS IE Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

james loveay wrote:

Bill Gorder wrote:I have never found the need to mix the 2. I just use Spring for all of my DI. I know it can be done, but I personally don't see the advantage in it. I would use one or the other personally.



Hi Bill,

Many thanks for your reply,

It was a great help. The sources confimed what I thought was the rightr way to go but always better having a wiser head show the path than to stumble around in the dark.

Anywho! totally agree with you that Spring is very good at handling everything I need for the project but then tah would be too easy!

Seriously the EJB were developed for another project I worked to learn the Struts framework and I wanted to re-use them instead of going the long route and re-building everything using spring, which would have been much easier.

Again many thanks.



Following on from my last post, just wanted to make an update!

I followed the links suggested and found a lot of examples on the net showing exactly the same thing, but they didn't work i.e. using a lookup configuration entry in the applicationConfiguration.xml file. Not sure why they didn't work but just in case anybody else comes across this problem I think that it may have something to do with the Glassfish server running with the Net Beans IDE, I have come across some peculiarities like this before, again though not 100% sure about that, although all of the examples I found used Tomcat or Weblogic.

Anyway I found another example which injected the EJB using annotations with a name mapping directly to the EJB

So I used

Using this I was able to directly inject a proxy into the controller without touching the configuration file.

Many, many thanks to Bill though because without his guidance I'd still be wandering about in the dark. Probable eaten by wolves by now
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your very welcome! Thanks for coming back and letting us know what worked for you.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic