Using mysql JDBC in the OSGi framework - mysql

I have a huge problem with getting a connection to a Database within my OSGi Application. I searched for 3 days an couldn't find a good solution. Just not working and old stuff. I'm using Bndtools for creating my Bundles.
Can anyone please help I'am very desperate.
Thanks

The most probable cause of this error seems that the package of the class being used is not present in the Import-package directive of the bundle's manifest.mf.
In OSGi environment, each bundle has its own classloader. So, each class will be loaded only once during the application life span. Whenever a class is being used outside of a bundle, the package the class resides in needs to be present in the Export-package attribute of its jar's manifest.mf.
Any client bundle which requires this package/class, should add the entry in its Import-package attribute of its manifest.mf file.
If you are using maven, you can use maven-bundle-plugin. This plugin will take care of generating appropriate manifest import and export headers by scanning the dependencies present in your project's pom.xml.

Related

Json Simple dependency Issue

So I have been trying to import JSON Simple (https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple/1.1.1)
I am also using Visual Studio Code. So I have added the dependency in my pom.xml file, but it still wont find my imports. Do I have to add soemthing to my module-info? (fixed a different issue for me) I tried requires com.json.simple; or requires com.googlecode.json.simple; but I get the cannot be resolved to a module error. Also my project is a javafx Application, that implements server socket networks (JSON exchage).
Im at a complete los here on what to do...
Thanks for your help.
So after a lot of trial and error, i have finally fixed it. Instead of vs code I used IntelliJ and added the dependencies there. Its impotant to note, that after every import I had to restart intelliJ also make sure to press the icon as mentioned in this tutorial https://www.jetbrains.com/help/idea/work-with-maven-dependencies.html#maven_import_dependency.

Using CakePHP 3.0 plugin

I'm currently building a new CakePHP app with version 3.0.0-RC1, and trying to install and use the jasig/phpCAS plugin. Using this guide, I've run the following command from the command prompt: composer require jasig/phpcas
This correctly copies the jasig/phpcas files into the vendor directory of my app, but one of the other files that the guide says should be updated (vendor/cakephp-plugins.php) doesn't even exist.
I've had a tough time accessing the plugin. I want to be able to call its static methods, and I keep getting errors of the form: Error: Class 'App\Controller\phpCAS' not found. (The exact directory in the error changes depending on where I'm calling the method from.)
I don't know if this is due to not having the cakephp-plugins.php file, or if I'm not calling the plugin correctly. It's my understanding that if the plugin is loaded I should just be able to call static methods on it like this: phpCAS::methodName()
First of all jasig/phpcas is not a CakePHP plugin. And the vendor/cakephp-plugins.php file is created by the CakePHP plugin installer, so if you don't see such a file, you seem to have either not installed any plugins yet, or you are not using a recent version of the installer, as the creation of this file has been introduced just recently.
Regarding the error about the class not being found, you are missing the leading namespace separator (\phpCAS::methodName()) to access the class in the global namespace, respectively you are missing a proper import (use phpCAS;) that would make the class available in the current namespace.
In case you are not familiar with namespaces, you may want to start with: http://php.net/namespaces

Windows Runtime Component Add As Link With Different Namespace

I have been trying to create background tasks in my universal app solution. As separate Windows Runtime Component project is required to contain background tasks, I have add one to my solution. In the tasks I am accessing a class that resides in my shared project and in order to do so I use add as link. Although there seems to be no errors when I try to compile the project I get the following errors.
"winmdexp.exe" exited with code -1073741819.
Metadata file 'C:\...\BackgroundTasks.winmd' could not be found...
I believe it might be caused by the fact that the classes that I add as link doesn't have the same major namespace as background task project.
Does anyone know a solution to this problem.
Thanks in advance.
As stated in Creating Windows Runtime Components in C# and Visual Basic, all public types must have a root namespace that matches the assembly name. I believe by adding a class as a link to my Windows Runtime Component project, I broke the same root namespace restriction and as the project didn't compile successfully metadata file was not created.
In order to solve this problem at first I changed output type of my project to class library and it compiled without a problem. Unfortunately background tasks didn't run when I tried to trigger them from lifecycle events.
So in the end I moved the classes that was shared between my "Shared" and background tasks project into a class library project and this solved my problem.

Problems while trying to use components from another module in intellij idea AS3

i'am trying to use components from another module, but is not working.
Look what i have:
I have my project, its an app to convert files, and its working everything is ok. Now i want to change the interface... for that i cloned a github repository thats is a project with the components that i want to use, and imported it as a module. (should i import as a module or as a project?)
Everything great till now, but when i try to use the components from the module i cant find the classes or even the module...
Any suggestions?
You should add your imported sources as a new module (let's call it B), then you should add a dependency from your original module A to your module B in order to use its code.
See this page on how to configure module dependencies.

How do I package a log4j configuration file in a NetBeans Platorm application?

Packaging a log4j configuration file in a NetBeans Platform application apparently requires some thinking through. This is what I tried...
I put log4j.xml in src/main/resources/my/package/log4j.xml of some_netbeans_module. The package is a public module package (i.e. classes from this package are used from other packages). I rebuilt the module and confirmed that the file does, in fact, get packaged into the module.
In my classes I get an instance of the logger the way I always do:
static final Logger log = Logger.getLogger(ThisClass.class);
Every NetBeans Platform application has a my_app.conf file which makes it possible to set certain properties. This is where I set log4j.conf:
log4j.configuration="/my/package/log4j.xml"
Now, when I run the application, I see the following output:
[INFO] /home/me/my_app/application/target/my_app/bin/../etc/my_app.conf: 5:
log4j.configuration=/my/package/log4j.xml: not found
What is wrong with the above configuration?
In the my_app.conf file if you append the log4j.configuration property to the default_options property, like so:
default_options="...<other options> -J-Dlog4j.configuration=my/package/log4j.xml"
then this option will get passed to the JVM. Notice that the log4j property has -J-D appended to it. The -J is used by NetBeans to delineate JVM properties and the -D is used by the JVM to delineate a system property.
Also you can/should drop the quotes and the initial / as the quotes are not necessary and NetBeans will complain if you have the initial /
The other way to do this, and the way that I prefer since it doesn't require editing the .conf file, is to put the log4j.xml file into the default package. If you have other requirements that prevents you from doing this then remember that you must put the log4j.configuration property in the app's platform.properties file while your in dev mode and running the app inside of the IDE. Like so:
run.args.extra=-J-Dlog4j.configuration=my/package/log4j.xml
Edit: For questions regarding NetBeans Platform you might have better luck posting to the NetBeans Platform Users forum.