1 2 3 Previous Next 69 Replies Latest reply: Jul 7, 2011 11:59 AM by arjan tijms RSS

    Adding JBoss AS source to a project

    henk de boer Master
      What is the easiest way to get the JBoss AS source into Eclipse? I don't want to modify the JBoss AS code, just step through it in the debugger. In the src download, the directories containing the java files are spread all over the place. A single classpath variable or attachment will not do the job :-(

      Are there jar files like jboss-src.jar that I could add as a source attachment to a jar file on my project's build path? Or is there a way to build such jars?
        • 1. Re: Adding JBoss AS source to a project
          Denis Golovin Master

          You can just unpack archive with sources somewhere and configure Java Source Attachment properties for particular jar. Just point to root folder of unpacked archive and eclipse will take care about everything else.

           

          Be aware that not all archives that appear in JBoss AS class path containers are built form those sources, there are many third party archives that have no matching source in source archive.

           

          For example you are using JBoss AS 4.2.2.GA  so you have sources unpacked somewhere

           

          ~/temp/jboss-4.2.2.GA-src

           

          If you expand JBoss As 4.2.2.GA classpath container and configure in Properties dialog Java Source Attachment properties for policy.jar like

           

          Location Path: /home/username/temp/jboss-4.2.2.GA-src

           

          that doesn't affect eclipse behavior and it is still not able to find sources for this jar. It happens because it is 3rd party dependency which comes ( I guess) from apache foundation.

           

          But if you do the same for  jboss-ejb3-client.jar, It works.

           

          You also can zip or jar ~/temp/jboss-4.2.2.GA-src and set Location Path to that zip or jar. It works the same way as external folder but saves a lot of disk space.

          • 2. Re: Adding JBoss AS source to a project
            Denis Golovin Master

            Some screen shots below show an example for one jar from JBoss AS 4.2.2.GA classpath container.

             

            I've unpacked sources archive for JBoss AS 4.2.2.GA to /home/eskimo/Temp/jboss-4.2.2.GA-src and configured properties for jboss-ejb3x.jar

            jboss-4.2.2.GA-client-jboss-ejb3x-jar.png

            After that eclipse shows source for classes from jar like it shown below for javax.annotation.Generated annotation

            jboss-4.2.2.GA-javax.annotation.Generated.png

            The only drawback is you have to do it for each jar you need to see the sources.

            • 3. Re: Adding JBoss AS source to a project
              henk de boer Master

              dgolovin wrote:

               

              The only drawback is you have to do it for each jar you need to see the sources.

               

              And that, quite frankly, are a LOT of jars

               

              I thank you for your answer and the screenshots, but I was actually looking for an easy single jar file attachment.

              • 4. Re: Adding JBoss AS source to a project
                Denis Golovin Master
                It sounds like a feature request then Wanna add it to JBoss Tools JIRA for JBossAS component? Feel free to add it here https://jira.jboss.org/jira/browse/JBIDE. Do not forget to check that there is no similar issue here.
                • 5. Re: Adding JBoss AS source to a project
                  Max Rydahl Andersen Master

                  We dont produce the source jars, that is an issue for JBoss AS.

                   

                  I would think they soon should be able to have proper maven source jars for these, but doesnt hate to remind them about your usecase

                  • 6. Re: Adding JBoss AS source to a project
                    Denis Golovin Master

                    JBossAS jars have pom.xml inside but I cannot find a way to get sources for it usin m2eclipse. I was sinking about having "Source location" field in Server Runtime definition and just use it by default as Source Attachment attribute for every jar in JBoss AS ClassPath container.

                     

                    We can support only external folder for that in first version and that means JBoss AS src distribution should be unpacked first.

                     

                    That's a good feature because it is Open Source project and it should help developers to have easy access to other sources

                    • 7. Re: Adding JBoss AS source to a project
                      Denis Golovin Master

                      You can do it step by step, just start from jars you know and then you can use "Attach Source..." button for jars that doesn't have source attachment yet.

                      attach-source.png

                      • 8. Re: Adding JBoss AS source to a project
                        Denis Golovin Master

                        First approach I suggested above is for browsing sources in jars inside JBoss AS Classpath Container. I found better way to configure sources lookup for server during debug session:

                        1. Create JBoss AS Runtime and Server

                        2. Deploy your application on that server

                        3. Create breakpoint somewhere inside your code that is going to be called by JBoss AS

                        4. Start server from step 3 in Debug mode

                        5. Open Debug View and invoke "Edit Source Lookup Path" dialog for server through "Edit Source Lookup..." Item in popup menu

                        jbossas-source-lookup.png

                        In opened Dialog (see image below) press "Add" button

                        jbossas-source-lookup-config.png

                        Then select File System Directory type and press Ok.

                        jbossas-source-lookup-add.png

                        Point to root folder for JBoss AS sources and Do not forget to select "Search subfolders"

                        jbossas-source-lookup-add-lfs.png

                        Finish all opened fialog by pressing "Ok"

                        6. Try to open your application in browse.

                        7. When you make got to breakpoint eclipse will be able to search JBoss AS sources in path you configured on step 5.

                        • 9. Re: Adding JBoss AS source to a project
                          arjan tijms Novice

                          I tried exactly what you said, but it doesn't seem to work. It seems like this only works for directories containing .java files, not for directories containing .jar files.

                           

                          When I click on "Edit Source Lookup..." again, then my source directory "jboss-5.1.0.GA-src" has indeed been added, and when I unfold it I can see all directories of the source archive, but unlike the "Default" source lookup path, not a single jar file is listed.

                           

                          I think a big problem regarding JBoss AS sources is that the structure of the source archive is *completely* different from that of the compiled product. For instance, suppose you were looking for the sources of jboss-web-service.jar. This file is located in the binary distribution at /server/default/deploy/jbossweb.sar/jboss-web-service.jar. There is no way the source code location even remotely resembles this. Even if the path would not exactly match (since it's actually /server/*/deploy/jbossweb.sar/jboss-web-service.jar), then still one would expect some file called jboss-web-service-src.jar.

                           

                          Again, this is not how the source is organized. Maybe the source of jboss-web-service-src.jar is within an archive located in thirdpary/jboss/foo/bar/kaz-all.jar. You just don't know... and -that- is the problem.

                           

                          Maybe a solution is to recursively unjar every .jar file to a central location and then jar it up again. I don't know... but I do know that the current situation leaves a lot to be desired.

                          • 10. Re: Adding JBoss AS source to a project
                            arjan tijms Novice

                            p.s.

                             

                            I found the source of the mentioned example class in /tomcat/src/main/org/jboss/web/tomcat/security/login/WebAuthentication.java.

                             

                            Using the method of setting the source via "Edit Source lookup" in the debug view, the source of this particular class can be found when stepping into a method from this class using the debugger. So, this is definitely an improvement compared with not having sources at all.

                             

                            However, ctrl-click into this class from the Java editor still doesn't work, and you often need this too when programming.

                             

                            And, as mentioned before, stepping into a class where Jboss AS ships the source in a jar doesn't work at all (neither stepping into it nor via crtl-clicking on it).

                            • 11. Re: Adding JBoss AS source to a project
                              Denis Golovin Master

                              atijms wrote:

                               

                              I tried exactly what you said, but it doesn't seem to work. It seems like this only works for directories containing .java files, not for directories containing .jar files.

                               

                              When I click on "Edit Source Lookup..." again, then my source directory "jboss-5.1.0.GA-src" has indeed been added, and when I unfold it I can see all directories of the source archive, but unlike the "Default" source lookup path, not a single jar file is listed.

                              Right, it is solution for JBoss AS only, because they have source distribution archive which contains only *.java files inside. Eclipse has no source lookup type, that visiting jar files. But you can use Archive or External Archive type to configure them. It supports multi selection so it should be easier than configuring them one by one

                               

                              BTW this External Archive type can be used to configure JBoss AS sources without unpacking sources archive.

                              atijms wrote:

                               

                              I think a big problem regarding JBoss AS sources is that the structure of the source archive is *completely* different from that of the compiled product. For instance, suppose you were looking for the sources of jboss-web-service.jar. This file is located in the binary distribution at /server/default/deploy/jbossweb.sar/jboss-web-service.jar. There is no way the source code location even remotely resembles this. Even if the path would not exactly match (since it's actually /server/*/deploy/jbossweb.sar/jboss-web-service.jar), then still one would expect some file called jboss-web-service-src.jar.

                               

                              Again, this is not how the source is organized. Maybe the source of jboss-web-service-src.jar is within an archive located in thirdpary/jboss/foo/bar/kaz-all.jar. You just don't know... and -that- is the problem.

                              The problem is that JBoss AS sources doesn't include 3rd party sources, I guess. It includes only sources that are really compiled during build. If something was bundled in as binary dependency, it has no sources inside JBoss AS source distribution. To configure source look up for 3rd party jars you need to process one jar at time and that can be done when required by using "Attach Source..." button.

                               

                              We have source browser implementation that understands *src.zip archives, but that in lab component and it is not included in build.

                              • 12. Re: Adding JBoss AS source to a project
                                Denis Golovin Master

                                It works only for Debug view, because sources to lookup attached to particular process.

                                 

                                But you're right that there are several places where you can access sources in eclipse:

                                1. Classpath jar browsing

                                2. Ctrl+Click navigation in source

                                3. Debug View Stacktrace browsing

                                 

                                1 and 2 are based on sources attached to jar files in project Classpath

                                3 is actually using "chain of responsibility", it tries to get sources attached to jars and then source lookup (need to check if that right suggestion )

                                 

                                So solution here would be to have field or complex widget (like Source Lookup) in new server runtime  wizard and server runtime editor to configure server sources location(s)/lookup. As soon as we have that 1,2 and 3 can be configured automatically for project and server launcher.


                                For instance, you created JBoss AS 4.2.2 runtime and provided an archive with sources. This archive can be used to initialize Java Source Attachment preferences for every jar in server classpath container and that means points 1,2 should work. Source Lookup also can be configured using provided archive and that makes point 3 working as well.

                                • 13. Re: Adding JBoss AS source to a project
                                  John Waterwood Newbie
                                  This external archive is possible, but takes us back to square one. As others pointed out, it's quite hard to match the right jar in Eclipse to the right source jar in the Jboss source archive.  Also, the jboss source archive does contain the source code for third party libs, but these are all packaged in jar files. For the end user it's not always logical when something is or isn't a third party lib. Eg Jboss as implements Java ee and JSF is part of java ee. Thus the end user probably expects the jsf sources to be part of "jboss as". There are also many jar files containing jboss source code as jars in the thirdparty folder. For the end user it is very hard to understand why this is I think.
                                  • 14. Re: Adding JBoss AS source to a project
                                    Denis Golovin Master

                                    john.waterwood wrote:


                                    This external archive is possible, but takes us back to square one. As others pointed out, it's quite hard to match the right jar in Eclipse to the right source jar in the Jboss source archive.

                                    I would try to give eclipse a chanse to handle that for us considering we have an implememntation that uderstands sources packaged as zips, but I cannot find any thirdparty sources in source archive for jboss-4.2.2.GA.

                                    john.waterwood wrote:


                                    There are also many jar files containing jboss source code as jars in the thirdparty folder. For the end user it is very hard to understand why this is I think.

                                    I'm looking at boss-4.2.2.GA sources (just one I have locally), I've checked several jars from thirdpaty folder and haven't seen any sources. Is that true for all releases or only for last ones?

                                    1 2 3 Previous Next