Announcement Announcement Module
Collapse
No announcement yet.
Spring 3 + ejb 3 + weblogic 10.3 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring 3 + ejb 3 + weblogic 10.3

    Hi!

    I have a problem related to using local EJB (@Local) inside an MVC controller. This might be connected to the way Weblogic handles the @Local notation. Basically I have this interface:

    Code:
    package x.y.ejb.interfaces
    
    import javax.ejb.Local;
    
    @Local
    public interface MyServiceInterface{
        void someMethod();
    }
    Then I implement it this way:

    Code:
    package x.y.ejb.implementations
    
    import x.y.ejb.interfaces.MyServiceInterface;
    
    import javax.ejb.Stateless;
    
    @Stateless(mappedName="ejb/MyService")
    public class MyService implements MyServiceInterface{
        void someMethod(){
             System.out.println("Hello World!");
        }
    }
    I have this configuration in servlet-context.xml:

    Code:
    <jee:local-slsb id="myService"
    	jndi-name="ejb/MyService#x.y.ejb.interfaces.MyServiceInterface"
    	business-interface="x.y.ejb.interfaces.MyServiceInterface"
    	lookup-home-on-startup="true" resource-ref="false" />
    Finally I have this controller:

    Code:
    package x.y.web.controllers
    
    import x.y.ejb.interfaces.MyServiceInterface;
    
    @Controller
    public class MyController{
    
        @Autowired
        private MyServiceInterface myServiceInterface;
    
        public void setMyServiceInterface(MyServiceInterface myServiceInterface) {
    	this.myServiceInterface = myServiceInterface;
        }
    
    	@RequestMapping(value = "/")
    	public String home(Model model) {
    		myServiceInterface.someMethod();
    		return "home";
    	}
    }
    When I deploy I get the following:
    org.springframework.beans.factory.NoSuchBeanDefini tionException:No matching bean of type [x.y.ejb.interfaces.MyServiceInterface] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.

    I tried to substitute @Local with @Remote (and of course jee:local-slsb with jee:remote-slsb) and it works fine. However I need to find a solution for the @Local case.
    Last edited by sacul87; Apr 16th, 2012, 07:40 AM. Reason: TYPO

  • #2
    Judging from your code you haven't implemented the interface, contradictary to what you say (the bean doesn't implement the required interface).

    Also you don't need the jee:local-slsb lookup you can do with a plain jndi lookup, next to that I would use the jndi name as configured in the bean and not as generated by the server.

    Comment


    • #3
      Originally posted by Marten Deinum View Post
      Judging from your code you haven't implemented the interface, contradictary to what you say (the bean doesn't implement the required interface).

      Also you don't need the jee:local-slsb lookup you can do with a plain jndi lookup, next to that I would use the jndi name as configured in the bean and not as generated by the server.
      Thanks.
      Sorry, it was a typo.
      Please, can you provide an example of your solution?

      Comment

      Working...
      X