9 Replies Latest reply on Sep 11, 2008 6:53 PM by Valerie Griffin

    Import example code to Eclipse

    Claus Nielsen Newbie

      Is there a easy way to import the Seam Example code to Eclipse, so that you can run the code from here ?

        • 1. Re: Import example code to Eclipse
          Joshua Jackson Master

          You can import Create new project from eclipse using the existing build.xml, it shouldn't be too difficult. Try it out first.

          • 2. Re: Import example code to Eclipse
            Claus Nielsen Newbie

            Hi Joshua,


            Thanks for your reply.


            I'm not sure that I understand you correct. Do you mean Import or Create ? and how can I use build.xml for this ?

            • 3. Re: Import example code to Eclipse
              Joshua Jackson Master
              Hi Claus,

              From your Eclipse:
              File -> New -> Project

              Open up the 'Java' tree and choose:
              Java Project from existing Ant buildfile

              And then Click next

              Then you specify the build.xml from the Seam examples.

              Try it out. Hopefully it works :-D
              • 4. Re: Import example code to Eclipse
                Claus Nielsen Newbie

                Hi Joshua,


                I end up with a Java Project with only the java class files in, so this is not what I wan't.


                Thanks for your reply.


                Best regards,
                Claus Nielsen

                • 5. Re: Import example code to Eclipse
                  Joshua Jackson Master

                  Didn't it retrieve the library into the classpath too?

                  • 6. Re: Import example code to Eclipse
                    Claus Nielsen Newbie

                    It didn't import the xhtml files and the configuration files. Therefore I can't run it on my the JBoss Server in Eclipse.

                    • 7. Re: Import example code to Eclipse
                      Joshua Jackson Master

                      Yes of course. Since Eclipse doesn't know that it is a web application. You have to do that manually. :-D

                      • 8. Re: Import example code to Eclipse
                        Tony Herstell Master

                        I use MyEclipse so this may not be possible in normal eclipse; never tried...


                        ...


                        Another way is to crack open the .ear that the build file produces and look at it.


                        This will give you a big clue as to where all the files are suppsed to go in the ear, ejb and war project that you will create in MyEclipse.


                        In MyEclipse, assuming you used the EJB3 wizard to create the EAR style project then the project(s) XXXEar, XXXEJB and XXXWAR will be created.


                        Copy the no class files from the cracked ear into the right places and pop the source in the right place.


                        To run the sucker all you do is deploy is the Ear as exploded and run the sucker...


                        If you change something that requires a re-start (Bean Spec) then a wee window pops up and tells you to restart the server; which you do...


                        To deploy to a live server then select packaged for deployment (as apposed to exploded) and copy the xxxx.ear produced in your local server area to the remote (live) server deploy area.


                        Side Effects...


                        It does mean you don't have to use Ant any more as you are levereging the capabilites of the MyEclipse deploy capabilities (You can still create Ant files (3 where 1 calls the other 2) and they are totaly trivial as the project is laid out in the right format already - I can supply these).


                        Just remember that .jars you put in the ear need to be only referenced in the EJB and WAR projects.. DONT add them again... this totally confuses things.


                        The Future...


                        One day MyEclipse will add in conditional deployment and then it's a lot easier to pop in and out the test files :)


                        MyEclipse wont work with the JBoss tools at present though so you got to decide if you can do without these. As I have never used them I can't make that call for you.


                        I suppose if you wanted to go this way I could wink a new install so you could follow along.


                        Hope this helps.

                        • 9. Re: Import example code to Eclipse
                          Valerie Griffin Newbie

                          Did you tell it to copy the files? I explicitly told it not to copy the files but to point to the project. That way, it knows about all of the files and I can still do additional seam-gen magic if I want to.


                          (I am using MyEclipse, but suspect that this is a feature of vanilla Eclipse, too. In fact, Dan specifically warns about this in Seam in Action, chapter 2.)