Results 1 to 3 of 3

Thread: Spring 3 + ejb 3 + weblogic 10.3

  1. #1
    Join Date
    Apr 2012
    Posts
    2

    Question 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 at 07:40 AM. Reason: TYPO

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Apr 2012
    Posts
    2

    Default

    Quote 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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •