How to integrate Fabric8 with Eclipse? - java

I'm using fabric8-karaf-1.1.0.CR5 in a stand-alone installation and it works fine there.
Now I wanted to embedd it into Eclipse Kepler SR2.
I basically followed Integrating Felix with Eclipse. But, instead of just adding bin/felix.jar to the project's build path as in Figure 8 I added all jars of lib and its sub-directories bin and endorsed (after a lot of errors were thrown at me by just adding lib/karaf.jar).
There are still three issues:
The following is printed to System.err:
Jul 28, 2014 12:12:24 AM org.apache.karaf.main.SimpleFileLock lock
Information: locking
What does this error(?) message try to inform me of? That a file named lock is created in the project's root directory? Thank you, but why?
The following is printed to System.err:
Error in initialization script: \shell.init.script
(The system cannot find the file specified)
The parenthesized is the Windows version of a FileNotFoundException's detail message. There exists an etc\shell.init.script and for the sake of the directory not mentioned I copied it to the project's root folder, to no avail.
I had to comment the following bundles in etc\config.properties:
#org/apache/sshd/sshd-core/0.9.0/sshd-core-0.9.0.jar=30
#org/apache/karaf/shell/org.apache.karaf.shell.ssh/2.3.0.redhat-610379/org.apache.karaf.shell.ssh-2.3.0.redhat-610379.jar=30
#io/fabric8/fabric-zookeeper/1.1.0.CR5/fabric-zookeeper-1.1.0.CR5.jar=39
#io/fabric8/fabric-api/1.1.0.CR5/fabric-api-1.1.0.CR5.jar=40
#io/fabric8/fabric-agent/1.1.0.CR5/fabric-agent-1.1.0.CR5.jar=40
#io/fabric8/fabric-core/1.1.0.CR5/fabric-core-1.1.0.CR5.jar=45
#io/fabric8/fabric-boot-commands/1.1.0.CR5/fabric-boot-commands-1.1.0.CR5.jar=45
#io/fabric8/fabric-commands/1.1.0.CR5/fabric-commands-1.1.0.CR5.jar=50
#io/fabric8/fabric-configadmin/1.1.0.CR5/fabric-configadmin-1.1.0.CR5.jar=50
... to get rid off errors of the form:
ERROR: Bundle <Bundle-SymbolicName> [<ID>]
Error starting mvn:<bundle-path> (org.osgi.framework.BundleException:
Unresolved constraint in bundle <Bundle-SymbolicName>:
Unable to resolve <ID>.0: missing requirement [<ID>.0] osgi.wiring.package;
(&(osgi.wiring.package=<Other Bundle-SymbolicName>)(<versions>))))
... but with these bundles disabled Fabric8 shuts down immediately.
It's right, the few missing bundles I have checked aren't in my local .m2 repository. But Maven works well with all other projects, in and out of Eclipse. Go on Fabric8, download them!
What am I missing?

Related

My Bukkit plugins has a plugin.yml but it gives this error [duplicate]

I am trying to create a Spigot plugin that allows players to use a compass to track other players. While exporting and running the server, I noticed that it was giving me an error:
[21:57:15 ERROR]: Could not load 'plugins\Manhunt.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:172) ~[patched_1.16.5.jar:git-Paper-683]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:148) ~[patched_1.16.5.jar:git-Paper-683]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:389) ~[patched_1.16.5.jar:git-Paper-683]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:252) ~[patched_1.16.5.jar:git-Paper-683]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1066) ~[patched_1.16.5.jar:git-Paper-683]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:290) ~[patched_1.16.5.jar:git-Paper-683]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_291]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
... 7 more
I have never seen this error before and I'm not sure how to fix it. I have made sure to export the .yml file while in Eclipse, but it still shows me this error.
The plugin.yml file is a required part of a SpigotMC plugin that defines some basic information about the plugin like its name and the version of the Spigot API that it uses. For example, here's one for a Minecraft plugin I'm currently working on.
The error you're getting comes from that file not getting bundled into the jar. As a result, when the Spigot server tries to load your plugin, it can't find the plugin.yml because it's literally not present in your compiled jar.
I recommend setting up a build system like Gradle or Maven that will handle the complexities of building the jar for you independent of the IDE you use.
Set up a SpigotMC plugin using Maven
Set up a SpigotMC plugin using Gradle
I personally use Gradle, so feel free to see how I implemented it in one of my plugins. If you'd prefer Maven, there are many examples available including the popular Multiverse-Core.
You need the plugin.yml to run your plugin. If you're using spigot or bukkit, you should make your plugin.yml inside the src folder, in there, you need to include a minimum of:
name: (plugin name, no spaces allowed in name)
author: (your name)
version: (your plugin version)
api-version: (use 1.14)
main: (your main class)
description: (optional description, otherwise delete this line)
then you can export or rebuild the jar
This is an example of what my plugin.yml looks like:
name: ThornsPlugin
version: 1.0
author: MOREORLESS
api-version: 1.14
main: com.MOREORLESS.plugin.plugin
description: MC Stuff
Learn more about Plugin.yml here: https://www.spigotmc.org/wiki/plugin-yml/

jar: Package org.apache.catalina.ssi missing from ModulePackages class file attribute

I changed my tomcat version 9 to 8 but when I wrote jar uf ../catalina.jar org/apache/catalina/util/ServerInfo.properties it gave me the following error
jar: Package org.apache.catalina.ssi missing from ModulePackages class
file attribute
How can I solve this issue?
Had the same issue. Upgraded from apache 9.0.16 to 9.0.41, wanted to remove server version/infos, edited ServerInfo.properties, and when time came to
jar uf ../catalina.jar org/apache/catalina/util/ServerInfo.properties
got the same error than you.
I think I found the why :
I opened catalina.jar both on 9.0.16 and 9.0.41, and lo and behold : there is no ssi in org/apache/catalina/ for 9.0.41
Yet the MANIFEST.MF still includes it, as well as the module-info.class
From reading Tomcat changelog, it looks like this happened with tomcat 9.0.30 :
Moved server-side include (SSI) module into a separate JAR library. (schultz)
(looking in the lib directory, it seems like it is catalina-ssi.jar now)
Not sure how clean this is, but I went around the problem by opening catalina.jar with 7zip, modify the ServerInfo.properties from there, saved, restarted Tomcat, and it worked.
That is a really weird issue I'm facing myself right know, excluding
org.apache.catalina.ssi from the module-info.class
using ModiTect helped, hope it won't crash in a long run...

OSGI Activator class not found

I'm trying to make the simplest OSGI example in order to see if it works on a particular Java Virtual Machine. Currently I'm testing it with Open JDK 1.8.0.
I'm following this tutorial. I have the exact same files except that I removed the package statement from the .java file and also from the manifest (I just want to make it simpler).
So basically the manifest looks like that:
Bundle-Name: Service listener example
Bundle-Description: A bundle that displays messages at startup and when service events occur
Bundle-Vendor: Apache Felix
Bundle-Version: 1.0.0
Bundle-Activator: Activator
Import-Package: org.osgi.framework
I am able to generate the jar file. It's contents is the following:
" zip.vim version v27
" Browsing zipfile /home/cosmin/OSGI_Testing/osgi/test.jar
" Select a file with cursor and press ENTER
META-INF/
META-INF/MANIFEST.MF
build/Activator.class
I run the Apache Felix, I install the .jar file and when I start it throws that exception:
ERROR: Bundle [1] Error starting file:/home/cosmin/OSGI_Testing/osgi/. /test.jar (org.osgi.framework.BundleException: Not found: Activator)
java.lang.ClassNotFoundException: Activator not found by [1]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1610)
at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.felix.framework.BundleWiringImpl.getClassByDelegation(BundleWiringImpl.java:1404)
at org.apache.felix.framework.Felix.createBundleActivator(Felix.java:4505)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2220)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2145)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1372)
at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
What is the problem?
Thank you respectfully.
There are several problems in this. The Activator class is in the wrong folder ... but that was already mentioned. Apart from this you should always use a package name in OSGi. Especially later when you want to share packages you have to make sure that the same package is not used in more than one jar.
You seem to create the Manifest by hand. This is a very error prone process. I recommend to use a maven build and use either the maven-bundle-plugin or the bnd-maven-plugin to generate the Manifest. This is a lot safer.
You can look into a tutorial I did some time ago. Maybe you need to strip it down for your case but you will see the maven build.
Starting with an Activator for your first try is a good idea .. but you should then quickly switch to a dependency injection framework. For OSGi I recommend to look into declarative services.
I think the Activator-class should not be in the build-folder. Remove the build-folder.

Android Studio - Resource Entry already defined

After compiling my Android application using the Android Studio (Beta), I have the following error:
Error:error: Resource entry background is already defined.
res\drawable-xhdpi-v4\background.9.png:0: Originally defined here.
This occurred when I had a image file called "background" in my res folder.
I then made a 9 patch version of it and pasted it in the same folder. This meant that there was 2 files with the same name. So I unsurprisingly I had this error.
However I now deleted all instances of the background image file (including the 9 patch version and original image) in my code and layout file and I still have this error.
You could try to do one of the following:
Clean and Build or gradle clean build assemble
Invalidate and restart Android Studio
1 Build > Clean Project
2 Build > Rebuild Project
I am using Android studio and I run exactly into the same issue and none of the answers I found on the web helped me solve the problem, including the previous one. So reading through all details of the error messages and found this lines:
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\user\AppData\Local\Android\android-studio\sdk\build-tools\android-4.4W\aapt.exe package -f --no-crunch -I C:\Users\user\AppData\Local\Android\android-studio\sdk\platforms\android-20\android.jar -M C:\Users\user\AndroidStudioProjects\DartsApp\app\build\intermediates\manifests\debug\AndroidManifest.xml -S C:\Users\user\AndroidStudioProjects\DartsApp\app\build\intermediates\res\debug -A C:\Users\user\AndroidStudioProjects\DartsApp\app\build\intermediates\assets\debug -m -J C:\Users\user\AndroidStudioProjects\DartsApp\app\build\generated\source\r\debug -F C:\Users\user\AndroidStudioProjects\DartsApp\app\build\intermediates\libs\app-debug.ap_ --debug-mode --custom-package com.dartstransit.dartsapp -0 apk --output-text-symbols C:\Users\user\AndroidStudioProjects\DartsApp\app\build\intermediates\symbols\debug
Error Code:
1
Output:
res\drawable-hdpi-v4\bus_w.png:0: error: Resource entry bus_w is already defined.
res\drawable-hdpi-v4\bus_w.jpg:0: Originally defined here.
As you can see there are two files of name bus_w with different extensions on the same folder. I had already removed those files from the project and still getting the error, so I decided to check every single folder of the project that was reference in the compiler line in the error message. Finally found that there was a copy of the file bus_w.png in the folder app\build\intermediates\res\debug\drawable-mdpi-v4.
I just deleted it and voila, problem solved.
A simple Build > Rebuild project helped me
Did you try rename this file to other name? It seem one of your libraries have same resource.
I see that many devs(include me) had issue with ic_launcher too. I think you want to try mipmap instead drawable. So we will have something like this:
\res\mipmap-hdpi
\res\mipmap-mdpi
\res\mipmap-xhdpi
\res\mipmap-xxhdpi
Hope this help.
I have also encountered this error recently.Here is my solution that works,hope it will help you.
1.only keep 9 patch version image in the drawable-hdpi folder
2.make sure the code related to this problem in xml file remains the same: android:background="#drawable/msg_left"
instead of using the code:
android:background="#drawable/msg_left.9"
PS:My original image name is msg_left,and my 9 patch version image name is msg_left.9
I did the trick by moving the icon
drawable/ic_launcher
to
mipmap/ic_launcher
and it worked fine :)
In my case the problem was that I had more than one '.' in the filename. like:
a.png
a.bold.png
Solution was to rename to
a.png
a_bold.png
In our case, problem started occurring (error shows 'duplicate value for resource' in a library) when some other library was upgraded to it's latest version.
We just downgraded the version of the library that was upgraded.
Real pain was because that we have many dependencies which can be dynamically upgraded when there is a new version available in repositories. So my teammate had to go through all libs that can be dynamically upgraded and see if there is one that is recently upgraded, try to downgrade it and check if build goes fine. He identified many were upgraded on previous day. Downgrading one of them got the build back.
Conclusion we made is not to use Dynamic Versioning. Don't use dynamic versions for your dependencies.
This was the error by the way:
Task :app:generateDebugResources UP-TO-DATE
AGPBI: {"kind":"error","text":"error: duplicate value for resource \u0027attr/itemBackground\u0027 with config \u0027\u0027.","sources":[{"file":"/Users/unknownuser/.gradle/caches/transforms-1/files-1.1/singledateandtimepicker-1.2.2.aar/86ae3786d70c769e610c8a01d58aa638/res/values/values.xml","position":{"startLine":15,"startColumn":4,"startOffset":2427,"endColumn":48,"endOffset":2471}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource previously defined here.","sources":[{"file":"/Users/unknownuser/.gradle/caches/transforms-1/files-1.1/singledateandtimepicker-1.2.2.aar/86ae3786d70c769e610c8a01d58aa638/res/values/values.xml","position":{"startLine":15,"startColumn":4,"startOffset":2427,"endColumn":48,"endOffset":2471}}],"original":"","tool":"AAPT"}
Task :app:mergeDebugResources FAILED
Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
FAILURE: Build failed with an exception.

"Workbench has not been created yet" error in eclipse plugin programming

With my eclipse plugin launching, I got Root exception:java.lang.IllegalStateException: Workbench has not been created yet. error.
And it seems to cause side effect to make some bundle exception error. I don't think my code uses egit module.
org.osgi.framework.BundleException: Exception in org.eclipse.egit.ui.Activator.start() of bundle org.eclipse.egit.ui.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)
How can I remove this error? This is the code that accesses the workspace. I found this article - Debugging a failed Eclipse launch saying that it's race condition, but I'm not sure why I have race condition, and if so, how to remove it.
public void renameClassRefactor() throws CoreException {
// get the project information with ResourcesPlugin
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
// 1. The name of the project in the workspace
System.out.println(ResourcesPlugin.getWorkspace().toString());
java.io.File workspaceDirectory = root.getLocation().toFile();
System.out.println(workspaceDirectory.toString());
I struggled a lot for “Workbench has not been created yet” the complete day.
But I got the solution by the following steps.-
Go to the Run configuration -> Remove all the target platform jars.
Click on add required bundles.
Check the org.apache.felix.gogo.runtime, org.apache.felix.gogo.shell, org.eclipse.equinox.console, org.eclipse.osgi and your jar file.
The last and important step. Go to Setting-> check the checkbox of "Clear the configuration area before launching".
Run the OSGi application now.
Enjoy if it works for you as it worked for me.
Thanks
Referring to this site, I could add -clean parameter in Run Configuration to remove the error message.

Categories

Resources