8 Replies Latest reply on Jul 8, 2010 11:52 AM by ch21

    How can I debug in eclipse with JBoss OSGI?

    ch21

      Now I develop OSGI Bundle in Eclipse with JBoss OSGI. I must use JTA TransactionManager, so can not develop only in Eclipse with Equinox. I need Jboss OSGI. But everytime export bundle to jar, then in Jboss OSGI. There are not clever.

       

       

       

      How can I remote debug in eclipse with JBoss OSGI?

       

       

       

      Thanks

       


      Chen

        • 1. Re: How can I debug in eclipse with JBoss OSGI?
          bosschaert

          What I always do is run the JVM that runs JBoss OSGi in debug mode. After that you can simply attach the Eclipse Debugger to the process.

           

          So, beginning from the very start, you can do this:

          1. To develop a standard OSGi Bundle in Eclipse, create a plugin-project with as 'Target Platform' a standard OSGi Framework:

          New Plug-in Project.png

           

          2. Finish the wizard some code for your bundle...

          3. To be able to deploy it in JBoss OSGi, export it as a deployable plugin:

          Screenshot-Export .png

           

          4. Launch JBoss OSGi with the Java debug Agent enabled:

          $ export JAVA_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:7777

          $ bin/run.sh

           

          5. Attach the debugger to port 7777:

          Screenshot-Debug Configurations .png

          and set a breakpoint in your bundle source code, for instance in its Activator.

           

          6. Install and start your bundle in JBoss OSGi (e.g. through the web console) - you will see that you are in the debugger now at your breakpoint.

          Debugger.png

           

          Hope this answers your questsion.

           

          David

          • 2. Re: How can I debug in eclipse with JBoss OSGI?
            ch21
            I don't know whether I  really understand what you mean.
            You mean, man must first export Bundle in Jar.  And then install and start bundle in JBossOSGI. With romote debug in Eclipse can I know, how run my bundle. There are not good. If I hava correct my bundles thousend times, I must export from bundle in thousend jar.
            If not, in romote java App can I select just onlz a bundle. But I have more bundles. How can I do that?
            David, thanks for your Reply.
            chen
            • 3. Re: How can I debug in eclipse with JBoss OSGI?
              bosschaert

              Hi Chen,

              chen huang wrote:

               

              You mean, man must first export Bundle in Jar.  And then install and start bundle in JBossOSGI.

              Yes - I think that's the only way you can do it, but this can be very easy and quick to do. You can save the 'export bundle' action in an ant build.xml script. This script produces a bundle file that you can easily copy to the JBoss OSGi runtime/server/default/deploy directory. That copy action will install and start the bundle. You can put these actions in a script so that you can perform them easily and quickly.

              If not, in romote java App can I select just onlz a bundle. But I have more bundles. How can I do that?
              David, thanks for your Reply.
              chen

              You mean in Eclipse you need to specify the project in the Debug Configuration screen? AFAIK that's only to associate the correct source code. If you need to debug multiple bundles in a single session you can attach their source code quite easily so it doesn't actually matter that much which project you specified in the run configuration

              • 4. Re: How can I debug in eclipse with JBoss OSGI?
                ch21

                thank for your reply. Full untersand.

                 

                Now I must lernen Ant and write an Ant-script for my bundles.

                 

                There are special  requirements for OSGI-Bundle in Ant?

                 

                Best Regard

                 

                chen

                • 5. Re: How can I debug in eclipse with JBoss OSGI?
                  bosschaert

                  You don't really have to learn ant. You can simply execute the ant script that was generated by the export from within eclipse. It simply performs the same task again.

                  For copying the bundle to the deploy directory you can use any scripting language you like. It doesn't have to be ant at all...

                  • 6. Re: How can I debug in eclipse with JBoss OSGI?
                    ch21

                    Met you, I am so lucky, I unterstand your mean. but my superviser let me use Ant. And I can't use  eclipse plugin-project to create bundle. I must develop bundle in normal java project to create bundle.

                     

                    Development in normal java project is difference to Development in plugin-project.  He think structure of project is following:

                    project name:  authorization

                                                                src/authorization/java/....(source code)

                                                                                          /META-INF/MENIFEST.MF

                                                                                                            / .......hbm.xml

                                                                 build.xml

                                                                test/...

                     

                    all dependenced jars must configure in class path. If I have forgot some Import-package in MENIFEST.MF, I can find Error no more in Eclipse. There are not good. But I have not alternative.  Do you have some suggestion for me?

                     

                    Thank very much!!!

                     

                    Best Regard!

                     

                    Chen


                    • 7. Re: How can I debug in eclipse with JBoss OSGI?
                      bosschaert

                      chen huang wrote:

                       

                      all dependenced jars must configure in class path. If I have forgot some Import-package in MENIFEST.MF, I can find Error no more in Eclipse. There are not good. But I have not alternative.  Do you have some suggestion for me?

                      You can use a free tool called Bnd (http://www.aqute.biz/Code/Bnd) to automatically generate the bundle manifest (including the Import-Package statements) for you.

                       

                      It also has a really good maven integration: http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

                       

                      Hope this helps,

                       

                      David

                      • 8. Re: How can I debug in eclipse with JBoss OSGI?
                        ch21

                        Thanks for your suggestion.

                         

                        I am clear.

                         

                        Thanks!!!

                         

                        Best Regard!!!

                         

                        chen