Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception while deploying

 
Trilochan Bharadwaj
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 471
Hibernate Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Trilochan Bharadwaj
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
$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
Posts: 471
Hibernate Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly. Thanks Costi
 
Trilochan Bharadwaj
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 471
Hibernate Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad to be of help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic