How to debug start of eclipse plugin? - debugging

I try to migrate an eclipse plugin from Java8 to Java9. If I start a debug session (Run as Eclipse Application...) all works fine.
However, after installing my plugin I am not able to use it. If I use ss in the OSGI console I get following status for my plugin:
1102 STARTING org.treez.core_1.0.0.201712191435
and if I manually try to start it I get
osgi> start 1102
gogo: BundleException: Error loading bundle activator.
I tried to start a remote debug session, as suggested here:
Debugging Eclipse plug-ins
I set a break point in the constructor of my Activator but that break point is never reached.
=> How can I get additional information about why the loading of the bundle activator fails? Is there some log file? Can I somewhere set a logging level to TRACE?
I assume that the issue might be that a resource can be found while debugging the Eclipse Application but not when using the bundled jar. More info, e.g. the name of the resource that could not be found, would be very helpful.
Related questions:
Debugging Eclipse plug-ins
CQ5 OSGi bundle does not start:- Activator cannot be found

When plugins fail to start there is normally a message in the .log file in the workspace .metadata directory.
On Linux, Unix and macOS this file and directory are hidden so you may need to do something special to see them.

Related

Spring Boot Dev Tools Restart Not Working

I'm trying to get restart working with Spring Boot DevTools. I have been following the instructions provided here: https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html
I am using gradle and included this in my build.gradle file:
bootJar {
excludeDevtools = false
}
I create the jar file and run the jar file:
java -jar app.jar
I am able to connect to the running application through Intellij. When I make a change I can see in the Intellij console that the updated classes are uploaded to the running process. And in the logs of the running process, I see the process attempts to restart. However, the process quits and spits out this log:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.example.BootApplication]; nested exception is java.io.FileNotFoundException: class path resource [com/example/ExampleService.class] cannot be opened because it does not exist.
ExampleService is the class I modified.
I attempted to google the heck out of this, but could find nothing. I looked at many tutorials online, but could find nothing.
Has anyone encountered this or has anything I can try, would be much appreciated.
The issue is based on how compilation of a file works.
When you compile a file, it first deletes the already compiled file and then adds a new one. During this process, file system watcher consider it as two different updates (deletion of file and addition of a new file) if the poll time is too low. And deletion of file triggers deletion of file from the remote application and tries to restart the application without the file you changed and therefore, you get this error.
I was facing the similar problem but solved it by adding following in application.properties
spring.devtools.restart.pollInterval=10s
You can change the pollInterval that suits you

Unable to run application with Gradle: Error: Could not find or load main class 1.8

I am using IntelliJ Idea 2017.3 and on any Gradle project (even for simple 'hello world' from GitHub) I always got next error:
"Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/3.5-rc-2/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
Error: Could not find or load main class 1.8"
Meanwhile, if I run an application with Gradle wrapper (gradlew.bat in my case) everything works perfectly. For me it looks like misconfiguration issue, but I cannot find what I am doing wrongly in Idea configuration or any other place. I appreciate any help with it or clue where to dig.
The issue was resolved and I would like to share this knowledge with all those who encounter a similar problem.
In my case, I had to delete two configuration files gradle.experimental.xml and gradle.settings.xml from IDEA configuration directory %IDEA_HOME%\config\options. I suppose they were created at the time when I installed Gradle globally on my PC. Somehow these settings were persisted, even after I removed globally installed Gradle and started to use Gradle's wrapper.

Start Equinox from Windows prompt

I want to start the latest Equinox framework but I'm stuck. I downloaded the latest version and tried to execute the command into windows prompt:
C:\equinox\plugins>java -jar org.eclipse.osgi_3.10.100.v20150529-1857.jar -console
But nothing happens. Do you know how I can start the framework?
EDIT
I downloaded launchers-win32.win32.x86_64.Mars.zip
C:\equin\eclipse\plugins>java -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dosgi.console.enable.builtin=true -jar org.eclipse.equinox.la
uncher_1.3.100.v20150511-1540.jar -console
An error has occurred. See the log file
c:\equin\eclipse\configuration\1435578389939.log
C:\equin\eclipse\plugins>
In error log I get this:
!SESSION Mon Jun 29 14:44:18 IDT 2015 ------------------------------------------
!ENTRY org.eclipse.equinox.launcher 4 0 2015-06-29 14:44:18.529
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.lang.RuntimeException: Could not find framework
at org.eclipse.equinox.launcher.Main.getBootPath(Main.java:1025)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:588)
at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
Looks like starting standalone Equinox is very tricky.
It seems that sadly the build-in console is removed in equinox 3.10 so the osgi.console.enable.builtin=true system property will not work. It was useful when someone wanted to start equinox with a console rapidly, without adding any more bundles.
To use the gogo shell, there are many tutorials. In short:
Download the following artifacts (they are in the zip of Equinox Mars):
org.eclipse.equinox.console_1.1.100.v20141023-1406.jar
org.apache.felix.gogo.runtime_0.10.0.v201209301036.jar
org.apache.felix.gogo.shell_0.10.0.v201212101605.jar
org.apache.felix.gogo.command_0.10.0.v201209301215.jar
Run the command:
java -Declipse.ignoreApp=true -Dosgi.bundles=reference:file:org.eclipse.equinox.console_1.1.100.v20141023-1406.jar#start,reference:file:org.apache.felix.gogo.runtime_0.10.0.v201209301036.jar#start,org.apache.felix.gogo.shell_0.10.0.v201212101605.jar#start,org.apache.felix.gogo.command_0.10.0.v201209301215.jar#start -jar org.eclipse.osgi_3.10.100.v20150529-1857.jar -console -consoleLog
Alternatively, you can specify osgi.bundles in the config.ini file of equinox if there is one.
You can put the necessary jars into a subfolder. In that case, you must use the relative path after reference:file:. E.g.: reference:file:lib/myjar.jar.
Edit
I uploaded two samples (one with config.ini and one without) to here: https://drive.google.com/file/d/0B1GigvByKQkIbFRqbjFvbmNYdk0/view?usp=sharing
There are pre-configured Equinox OSGi Starter Kits available from eclipse itself. They are somehow tricky to find. Open the Equinox Project Download page and click on the blue triangle for OSGi starter kits.
Then you can download them for your platform. They have native executables but also valid configuration for "java -jar ..." executions.

How to avoid unneeded recompilation from IntelliJ Idea 13 when it runs a maven vaadin project created in the command line

I have created a maven vaadin project using the command line like this:
mvn archetype:generate -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-application -DarchetypeVersion=7.1.9
Then I change into the folder of the application and I give at the command line the following :
mvn install
After waiting for the application to compile, I open it using IntelliJ Idea (by opening the pom.xml file), I add Tomcat Server and I press run.
Then the IntelliJ Ide recompiles the application again.
Is there any way I can avoid this second compilation?
Thank you.
You should have tomcat configured as a server, and configure your module(s) to deploy at server startup. On the run configuration you will see a list of things to do before launch. It will probably say Make -- you can remove this if you need to.
However, you probably should allow idea to do this for you and really stop doing it on the command line. Idea can handle more complex build patterns for you. You should trust it.

Setting osgi.configuration.area breaks my Equinox OSGI app

I have an application which uses Equinox as an osgi framework for a while now. Until now I used the system property osgi.install.area to specify where my bundles are like so
${osgi.install.area}/
plugins/
org.eclipse.osgi_3.7.0.v20110613.jar
... my app bundles
Equinox then automatically uses ${osgi.install.area}/configuration as the configuration area.
Everything works fine.
Now I need to move the configuration area out of ${osgi.install.area} because that may be read-only and I thought it was as simple as setting ${osgi.configuration.area} to a suitable path but when I do this the application no longer starts and I have the following stack trace in the logs:
java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:74)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at org.eclipse.core.runtime.adaptor.EclipseStarter.main(EclipseStarter.java:150)
...
The path is used because at that location the log file is created and a directory "org.eclipse.osgi".
Paths to bundles are referenced in my config.ini like so:
osgi.bundles=de.mycomp.app-0.6.0.20121116-1834.jar#start, ...
The error message does not really give a hint where to look. It must be something rather simple but I am rather clueless at the moment.
Thanks in advance,
Robert
I tested changing the configuration area an existing osgi app and it worked, with the following argument below in the .ini file in the root of the install. Are you sure you are setting the config param correctly like this:
-Dosgi.configuration.area=c:\mytest
After doing that and running the app again, it created the folder and a new configuration.
Here is a copy of my .ini file that works, also it's important that osgi params come after and vm args.
-loglevel=trace
-vmargs
-Dosgi.configuration.area=c:\mytest
-Dorg.osgi.service.http.port=8094
-Declipse.ignoreApp=true
-Dosgi.noShutdown=true
-Dequinox.ds.print=true

Resources