my dog learned polymorphism*
The moose likes Spring and the fly likes Exception while deploying Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Exception while deploying" Watch "Exception while deploying" New topic
Author

Exception while deploying

Trilochan Bharadwaj
Ranch Hand

Joined: Feb 02, 2009
Posts: 100
I use following class hierarchy for Service:



And refer to it in controller resource:


I simply refer to this in my spring resource config xml (for controllers and restful resource configuration) like this:


However when I package and deploy the jar on JBoss, I get following exception:



What am I missing ...? My guess is that I am doing something fundamentally wrong in the code ... Any suggestions?


Any help would appreciable ...
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 460
You have to code to an interface, and not to the concrete class/implementation. Spring doesn't inject an object of your class, but in place injects a proxy to your class. This is needed for Aspect Oriented Programming (AOP). The proxy implements the interfaces that your class implements, but is not an instance of your class. Just code to the interface, and your problem should be solved (I guess). Another thing that might solve the problem is to add the following line to your bean definition

Of course you'll need to add the aop name-space to your XML file. As I have said that the second solution might solve the problem, but I do not guarantee this. We have used this to solve a similar problem with DWR, but that's another story.


Visit my blog: http://jnassef.blogspot.com/
Trilochan Bharadwaj
Ranch Hand

Joined: Feb 02, 2009
Posts: 100
What do you mean code to an interface ... I am not following; does that mean, I use:



instead of using DefaultActorModelService?

Can you clarify in the snippet please?

Appreciate your help!
Trilochan
Costi Ciudatu
Ranch Hand

Joined: Oct 24, 2006
Posts: 74
$Proxy310 implementing com.inews.service.IActorModelService

It looks like you already have an interface for the ActorModelService (which probably extends IService<DefaultActorModel, Long>).
If so, you should make the ActorModelService class implement the IActorModelService (so it will have the same interace as your declared service bean).
And then use:
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 460
Exactly. Thanks Costi
Trilochan Bharadwaj
Ranch Hand

Joined: Feb 02, 2009
Posts: 100
Replaced Concrete Implementation with Interface and also replaced and it worked fine ... Cool thanks All!

One more thing I noted since I am deploying on JBOSS; JBOSS's JNDI binding for UserTransaction are as opposed to . Once those changes were made it all went well.

Again appreciate everyone's help!
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 460
Glad to be of help
 
jQuery in Action, 2nd edition
 
subject: Exception while deploying
 
Similar Threads
[spring] aop config
Problem with the Sample Spring AOP application
Abstract Generic Class for DAO with spring SessionFactory injection setup help needed.
Error while executing simple application with jdk1.5
Spring 3 with Hibernate error