1 2 Previous Next 28 Replies Latest reply on Jun 17, 2008 3:55 PM by mkiel Go to original post
      • 15. Re: Seam Project Design
        gjeudy

        Its pretty clear based on the error messages that you get, the instance that it is trying to inject is not of a compatible type. Now why it happens is unknown to me.


        Can you provide more info on your application and deployment configurations ?

        • 16. Re: Seam Project Design
          metal610

          Basically my application lets people register for events that my company hosts. They can also do other things like view their events and such.


          I'm using Seam 2.1.0.1A and JBoss AS 4.2.1.GA. I know that I should probably upgrade my project to use the newest version of Seam and JBoss AS, but I wasn't sure if in doing that, something in my application would need to be changed. If that fixes it, then I'll be more than happy to upgrade, but otherwise, I was planning on doing it closer to the end of the project.


          I hope that helps and if it doesn't, just let me know and I'll tell you more.


          Thanks.

          • 17. Re: Seam Project Design
            gjeudy

            Seam 2.1.0 is still in alpha stage.


            Try with Seam 2.0.2.SP1 which is the latest production release. I would also use a more recent version of JBoss AS such as 4.2.2GA but that probably does not matter in this case.


            Let me know if the issue still occurs in that version.


            When I was asking about configuration and deployment I was asking about you EAR/WAR packaging setup and central configuration files such as web.xml, components.xml, etc..

            • 18. Re: Seam Project Design
              metal610

              It was still happening in Seam 2.0.2.SP1. I tried injecting it in different ways and it still occurred.


              Oh ok, I wasn't sure what you had meant when you said deployment configurations. I'm still kinda new to web development.


              I'm using an EAR packaging setup and for my config files, my web.xml was created by seam-gen, my components.xml is basically empty, save the namespaces and the EntityManager setup, faces-config.xml, application.xml, ejb-jar.xml, jboss-app.xml are all auto-generated,


              I hope that helps.


              Thanks.

              • 19. Re: Seam Project Design
                metal610

                One little thing that I just found out about. While messing around with injection, I found out that I am able to inject a string, but not a class. Does that mean that I am defining my classes wrong?

                • 20. Re: Seam Project Design
                  metal610

                  Just to let all of you know, I figured out what I was doing wrong. Apparently, you can't inject an EJB into an EJB. You can, however, inject a POJO into an EJB. You can also inject a POJO into a POJO just fine.


                  Thanks for all the help,
                  Robert

                  • 21. Re: Seam Project Design
                    gjeudy

                    Robert, you can inject an EJB into an EJB. I'm not sure why you can't achieve this. In my project I inject EJBs into EJBs without any problems.

                    • 22. Re: Seam Project Design
                      metal610

                      How are you doing it in your code?

                      • 23. Re: Seam Project Design
                        zergspirit

                        Shouldn't he use RegistrationLogicInterface as type instead of RegistrationLogic, since it's his @Local interface?

                        • 24. Re: Seam Project Design
                          gjeudy

                          I think Adrien is right. The type you refer in the injected instance variable must be the same type where you declared your @Local annotation. Would that be RegistrationLogicInterface ?


                          If so, then try this:


                          @Stateful
                          
                          @Scope(SESSION)
                          
                          @Name("registrationBean")
                          
                          public class RegisterBean implements Register, Serializable{
                          
                          
                              @In(value="registrationLogic")
                          
                              private RegistrationLogicInterface regLogic;
                          
                          



                          Below is how I do it:



                          @Stateless
                          
                          @Name("partyService")
                          
                          @Local(PartyService.class)
                          
                          public class PartyServiceImpl implements PartyService 





                          @Stateful(mappedName="ClassificationUseAction")
                          
                          @Scope(ScopeType.CONVERSATION)
                          
                          @Name("classificationUseAction")
                          
                          @Local(value=ClassificationUseAction.class)
                          
                          public class ClassificationUseActionBean implements ClassificationUseAction {
                          
                               
                          
                               @In(create=true)
                          
                               private PartyService partyService;



                          You can declare the @Local annotation in your concrete class and refer to the interface inside. This way your interface is completely generic and client classes don't know more than they should about a given implementation of the interface. Implementing classes are not constrained either by the interface @Local EJB annotation.


                          • 25. Re: Seam Project Design
                            metal610

                            Yeah, that is correct. I just tried that out a few minutes ago and it worked perfectly. I don't remember reading that in the Seam documentation though, so would that be an ejb specific thing?

                            • 26. Re: Seam Project Design
                              gjeudy

                              Yeah this is EJB3 specific stuff. Basically the exportable types (that can be referred by clients) are the ones tagged with @Local or @Remote annotations.

                              • 27. Re: Seam Project Design
                                metal610

                                O ok. That would explain a few things.


                                Thank you very much for you help.

                                • 28. Re: Seam Project Design
                                  mkiel

                                  Yes, the strict necessity is related to EJB, but referring to interaces is good practice in a JavaBean context, too. If you extract an interface from a JavaBean component and have all clients inject the component with the interface as type, you can easily exchange the implementation classes by using the @Install annotation (see the docs).


                                  On the other hand, using interfaces can sometimes be tedious, especially during prototyping. That's why I use concrete JavaBean components for the controllers which are directly accessed by JSF components. Forgetting a method on an interface here would result in an annoying runtime error and could not be cought at compile time.

                                  1 2 Previous Next