Debug Karaf bundles in Eclipse: persist dev:watch URLs/IDs? - eclipse

I want to be able to easily debug an OSGi bundle running in Apache Karaf from Eclipse. The easiest way I've identified so far is to create a Java Application launcher that starts Karaf. If the bundle was previously installed then I can set breakpoints, even in the activator, and all is good.
The issue is that when a change is made to the code, mvn install invoked, and then the Eclipse Karaf launcher invoked, I am running the old cached version of the bundle. I have played with running Karaf from the command line, installing my bundle with a Maven URL, and using dev:watch with success. But I have found that the dev:watch URLs are not persisted. Thus, when starting Karaf from Eclipse, there are no watched URLs (the previous ones were lost when Karaf was shutdown) and new versions of the bundle are not installed.
Is there a way to get the dev:watch URLs to be persistent? I looked for either properties that might hold the URLs or even Karaf command line options that could be used to specify the URLs with no luck. I even tried to add the dev:watch command to etc/shell.init.script but I get this message at Karaf startup “Error in initialization script: Command not found: dev:watch.” I assume this means the command was run too early in the Karaf startup sequence (dev feature not yet started?).
Any help would be appreciated, even alternate ways I haven’t considered to easily debug bundles running in Karaf from Eclipse. The goal is to avoid needing to use manual commands such as osgi:install every time the code changes.

The Karaf team is now also working on a better integration with EIK, but at the current time it's not yet as deeply integrated as it would be needed.
Therefore your provided way is basically the best way in doing debugging.
Build your application with maven, do a dev:watch when your karaf is up and running.
Since dev:watch is a "Development-Time" command it's not intended to be persistent. But you still have the history to choose from and of course you're able to provide multiple bundle IDs to the command.

Related

Tomcat and Eclipse vs Intellij

I am working with Intellij but some of my co-workers don't. When I was writing install doc, I realized that Tomcat is not managed the same way on the two IDEs.
Which is a problem considering what happened next when I tried to set up our project on Eclipse.
Basically, on Intellij, you select a Tomcat on your computer and it will literally copy the war into the webapps folder and run the server with everything working fine.
I am not a user of Eclipse so I might have misunderstood something, but I found that when you create a Tomcat server, it will embed the one you gave it to it. Doing that is a bit of an issue when you are working with logback, because usually you set your logs location directly into the Tomcat folder. And in Eclipse you are working out of this folder.
So, I can't run my application because it can't find the location of the logs folder at the fine place.
Is there a way to use Tomcat in Eclipse like Intellij? Or did I just miss something because I am kind of new with Eclipse?
See the FAQ: (1) (2)
I found that when you create a Tomcat server, it will embed the one you gave it to it.
You have to be more specific with your description. How you do things and what do you see. What do you mean by "embed"? What is the actual failure that you are observing with your logging?
There are different ways to do things.
For me by default Eclipse does not embed Tomcat, but runs it as a proper java process. (org.apache.catalina.startup.Bootstrap) You should be able to see it with jconsole and similar tools.
It runs your web application expanded, i.e. without zipping it into a war file. It creates a separate configuration of Tomcat, i.e. runs it with separate CATALINA_HOME and CATALINA_BASE directories (as documented in RUNNING.txt file of Apache Tomcat). The CATALINA_HOME directory stays untouched and CATALINA_BASE directory is ${workspace}/.metadata/.plugins/org.eclipse.wst.server.core/tmp0 etc. A logs directory can be found there.
One known caveat is that java.util.logging is not configured by default (the system properties java.util.logging.manager and others are not set). See "How do I enable the JULI logging" item in the FAQ. -- In the same way you will set any other system properties that you may need.
The default configuration of java.util.logging (as provided by JRE) is to log everything to the console, without creating any files.

weird behaviour of eclipse osgi bundle

I'm trying to deploy a few bundles I implemented along all the required bundles from Eclipse in order to run my own. Let's say, include the Equinox container also with my bundles so it is like an executable old-school JAR.
That said, when I try to run
java -jar org.eclipse.osgi_3.8.1.v20120830-144521.jar
Nothing happens...it just stays there doing nothing...even if I copy just that bundle to some other place and try the same, nothing happens...is this usual? I mean, I have done this successfully with older versions of this bundle (3.6) and it worked flawlessly.
Alas, I tried -debug flag to see if I could get some output, but only a complain about mission .options file is happening, nothing else.
Thanks,
Alex
Just in case someone has the same problem...having checked this link: http://docs.codehaus.org/spaces/flyingpdf/pdfpageexport.action?pageId=82903240, I created the configuration folder, a config.ini in it with the following contents:
osgi.bundles=org.eclipse.equinox.common#start, org.eclipse.update.configurator#start,
org.eclipse.core.runtime#start, org.eclipse.core.jobs#start,
org.eclipse.equinox.registry#start, org.eclipse.equinox.preferences#start,
org.eclipse.core.contenttype#start, org.apache.felix.gogo.runtime#start,
org.apache.felix.gogo.shell#start,
org.eclipse.equinox.app#start,org.eclipse.equinox.console#start,
eclipse.ignoreApp=true
osgi.noShutdown=true
This seems to work. I believe this is the minimum set of bundles required to run the Equinox OSGi container...from there, you can use the osgi shell to play with your bundles
You havent included -console option, that is the one that will open up the console view right?

Easiest way to deploy OSGi framework from Eclipse?

I am developing a server with Jetty (servlet container). I am successfully running the server within Eclipse with an osgi-framework run configuration. Everything fine.
What is the best way to export this run configuration so that I have a valid config.ini and all plugins (the workspace bundles and the ones from my target platform) and am able to run the osgi-framework without Eclipse IDE running.
I tried to make a product to get the config.ini and all the bundles but I cannot run the framework with java -jar org.eclipse.osgi_3.6.2.R36x_v20110210.jar.
It is not finding the bundles in the plugin folder, because obviously the names do not match exactly (e.g.: com.mine.at-3.3.-3234234.jar instead of com.mine.at.jar)
There are about 150 bundles and I do not want to edit the config.ini manually.
What did I miss?
What worked pretty well for me was to make a new product, based on the (working) run configuration, and export the product. That project should then be 'runnable', or at least pretty close.
Did you try that?
Hope it helps, Frank

JBoss server does not get changes

Eclipse Indigo
Version: Indigo Service Release 1
Build id: 20110916-0149
JBoss 6.1.Final
I have a server which i have configured with some support, but it has broken down.
Broken down means, even tough i;
- stop the server,
- clean and build projects in workspace,
- and clean the server and publish from scratch,
- and start the server again
it responds like it has yesterday's code. I made lots of change but server seems not to be aware of changes.
If you have an advise on this issue, please provide.
Thanks
Try autodeploying your .war or .ear file manually, not using the Eclipse JBoss connector (which sometimes breaks down and acts strangely). Just copy the file to the autodeploy dir (for JBoss 6 i believe this is /server/default/deploy), check the JBoss's logs/console to see that your file is currently deployed, then delete it from there, and again check that the JBoss console confirms succesfully undeploying that application.
Now, that Eclipse JBoss connector is convenient because it lets you quickly deploy, debug, etc (even tho it has it's bugs). You can however to several things to simulate it's behavious without actually using it:
simplest one: Use Jetty: http://irc.codehaus.org/display/JETTY/Downloading+Jetty. Comes as Eclipse plugn, maven plugin, stand alone server. Jetty 8 supports servlet 3.0 so it's up to date. Deploying and debugging is fast and easy and it actually works (I use this a lot). Only downer: doesn't have EJB container.
Use tomcat 7 (stand alone install) and the Eclipse sysdeo plugin: http://www.eclipsetotale.com/tomcatPlugin.html. Allows for seamless deployment/debugging as you'd do with a Java SE application inside Eclipse. Again, the downer is no EJB container
If you really wanna use JBoss, try the following:
start in in debug mode all the time by adding this to your run.bat:
set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n %JAVA_OPTS%
make your "target" project folder (the one where either Eclipse or Maven (whichever you use)) to be something like [jboss root]\server\default\deploy\myAppName
Start a "Remote Java application" debug session from Eclipse on the port 8787.
With all this the project should deploy any changes you make on the fly, and stop at whatever breakpoints you have when execution reaches them. It's not awesome, as sometimes certain changes will not be taken into account (eg: if you modify the body of a method in a Java class it will be hot-deployed. If you add a new method it will not).

Launch an Eclipse Run Configuration from ANT

I am using Orion server for my Java-based web application. I have a run configuration that launches Orion with the correct classpaths and all necessary configuration. I also have several ANT scripts for copying files to the build path. I want to create an ANT script that shuts down Orion, copies necessary files, and restarts Orion. I can shutdown and copy in ANT, but I can't figure out how to launch a run configuration. I prefer to reference the launch configuration as opposed to specifying all of the configurations in the ANT script as well. Is this possible?
With eclipse remote control you can launch eclipse run configurations in eclipse from a simple java client application.
Ant4Eclipse is an Eclipse plugin and looks like it can do what you are asking. I have never used it myself so can't guarantee but reading their documentation they say you can create an Executor task that works on your launch configuration artifact. You will then reference this task in your build file.