Apache Felix Bundle Repository - Calling from another bundle - apache

I have a simple test program which is designed to consume the Apache Felix Bundle Repository bundle service however I am having trouble configuring it through eclipse.
I am using the jar for the bundle (org.apache.felix.bundlerepository-1.4.0.jar) as an referenced library and have added it to the classpath in the manifest.
When I try to start my bundle it gives the error:
java.lang.ClassCastException: org.apache.felix.bundlerepository.RepositoryAdminImpl cannot be cast to org.apache.felix.bundlerepository.RepositoryAdmin
I can't add org.osgi.service.obr to the list of imported packages in my bundle (as it doesnt resolve) and I think this is the reason for the issue.
Any ideas?
Thanks

This was resolved by including the Apache Felix Bundle Repository bundle (org.apache.felix.bundlerepository-1.4.0.jar) in the eclipse/plugins folder which allowed me to reference the org.osgi.service.obr package in the list of imported packages in the manifest.

Related

How to load a dll in Karaf container?

I have a dll which provides a simple functionality (called HelloCpp.dll) and
I need to access to the content of this library from Karaf container via REST calls.
I created a simple maven bundle which provides the REST api and a class (HelloJNI) which loads HelloCpp.dll using: System.loadLibrary("HelloCpp");
I have also addressed this dll in my POM file using: <Bundle-NativeCode>HelloCpp.dll</Bundle-NativeCode>
I have coppied the dll in both project directory and also karaf/lib folder.
I can successfuly install the bundle and I don't receive any compilation error as well, but when I deploy my bundle into Karaf container and try to start bundle, I get this error message: No matching native libraries found.
Could you please help me to solve the problem? Maybe I don't address the dll correctly in the POM file.
Thanks in advance,
Mandana

Deploying file to WebLogic - Error: Unresolved Webapp Library references

I received this error on deploying the file to WebLogic.
Should I make any alteration to the Weblogic.xml file?
Error: Unresolved Webapp Library references for "ServletContext#8793091[app:casman-jsf-3 module:casman-jsf-3.5-SNAPSHOT.war path: spec-version:2.5]", defined in weblogic.xml [Extension-Name: jstl, Specification-Version: 1.1, exact-match: true], [Extension-Name: jsf-myfaces, Specification-Version: 1.1, exact-match: true]
To fix this, I had to take the following steps (I am developing using Eclipse and deploying to Weblogic 10.3.5):
REMOVE weblogic.xml from the /WebContent/WEB-INF/ directory
Add needed jars to your lib directory (/WEB-INF/lib/) including JSTL.jar
Add project libraries to your Deployment Descriptor
Install EAR or WAR to Weblogic
This resolved the issue.
the error is because some library referenced in the Weblogic.xml is not being accessed during deployment.
try to call all the referencing libraries through run (Windows OS). Like if you have some reference to a library called \systemlib\alllibs\lib1.jar, then go to run and try calling in the library file or see manually if you can access the file in the server.
If the file is present then for unix/linux server, check if there are no access rights issue on the system. like if the library was placed by the root user and the weblogic user(Application server) does not have rights to read or write on the library folder. Remove any such issues.
Lastly, since the error specifically says JSTL, therefore check if the JRE version and JSTL version are in sync.
If still the error is not resolved, then please share the weblogic.xml also
Do a deep search of "jsf" in your wlServer\common\deployable-libraries folder .
Find the library corresponding to that extension and install it into your server.
Re-deploye the application
It worked for me

Maven 2 - 'mvn test' does not find internal project plugin dependency

I have a multi-module maven project (maven 2.2.1).
One of the module is a maven plugin.
This plugin is bound to the compile phase of another module, and added as a direct dependency to trigger correct reactor ordering of module's building.
If I run 'mvn clean install' on the root module, with a fresh local repository, everything goes fine (build, test, install). (I precise that my project's artifacts are not deployed anywhere, only installed locally in my machine's local repo).
BUT if I delete my local repository, and perform 'mvn test', the plugin module is reported as missing ? Whereas, the build order is correct, the plugin module is built succesfully before the module using it ???
Is there any special treatment of maven module with 'maven-plugin' packaging ?
I don't understand why other project inter modules dependencies are resolved correctly and not this specific one !
The problem is that a Maven Plugin must be installed into the local repository first before you can use a plugin as a dependency (or better be part of the life-cycle).

Eclipse RCP: Dependencies correct (?) but get a NoClassDefFoundError

I have a RCP project where I cannot fix a NoClassDefFoundError: One plugin depends on another plugin. The plugin-dependencies are set in the manifest, packages exported, and there is no error at compile time. Both plugins are in the product dependencies and visible in the installation details of the product.
But when I run the application I get a java.lang.NoClassDefFoundError when the one plugin wants to use a class from the other plugin.
Any hints how to find the reason for this are greatly appreciated.
Thanks,
Michael
I found the problem: I created the plugin which could not be loaded from an existing Java project. And somehow I deleted the "." in the entry Bundle-classpath in the plugin manifest (the plugin has some jars which -> so lib/xyz.jar was in the Bundle-classpath entry but not the ".").
For the class-loader of the bundle the "." means to search for classes from the root path of the bundle (or something like that), so it could not find the classes. However, there were no errors in the IDE so it was hard to find.
Is the configuration for running the application correct i.e. all dependencies are also put in the running configuration?

Glassfishv3 not adding jars in ear to the classpath

I have been working on this problem for one whole day but in vain without any effective solution.
I have an ear file packaged with an ejb and a handful of jar files (including hibernate and the other dependent jar files).The ejb is stateless and enabled as a web service.
The ear file has been packaged using maven and has the below structure
ear->projectrelatedejb.jar
->hibernate.jar
->otherdependent. jar
->META-INF/application.xml
->META-INF/manifest.mf
The application.xml and manifest file are automatically generated by maven when I do a package.
When I deploy this ear file on glassfish it gets deployed with the ejb methods being accessible using web services. However when accessing the application (using soapui),
the ejb methods that perform some database functionality using hibernate throw java.lang.NoClassDefFoundError for the hibernate api during runtime.
It is obvious from the error that the hibernate jars are not on the classpath during runtime but since the jars are within the ear Glassfish should have
added it to the application classpath.
I tried various options like adding the classpath entries to the manifest.mf during the package (by using the element addClasspath with the maven-ear-plugin) which didn't do any good.Also with Glassfish we cannot add the dependent jars as modules to the application.xml unless the jars are application client jars
(Glassfish wouldn't deploy the ear file if the application.xml has the dependent jars declared as modules).
I also tried placing the jars in the lib directory within the ear (which isn't actually required) and with the manifest Class-Path header referencing the jars in the lib directory which also didn't fix the problem.
The quick and dirty fix which I can do to get this working is to place the hibernate and the other the dependent jars in Glassfish's lib directory.However,this is a bad practice
and I am somewhat reluctant to do it.
I would really appreciate if someone can provide me with a working solution to this problem.I have gone through the net looking for this problem
but couldn't find any solution.
Wondering if its a bug with glassfish or does glassfish need something special to reference the jars in an ear.
Thanks in advance.
I found a similar problem which is discussed here: http://www.tricoder.net/blog/?p=59.
Simply put, try putting the libraries in EAR/lib directory and according to JEE5 spec, glassfish will add them to class path automatically.
I used Server Library option to deploy application JARs and it worked for me.
Right click on your EAR-> Properties -> Libraries-> Add Library -> Create -> give name and change type in Library Type to Server Libraries then add JARs that should be deployed and confirm.
I work with NetBeans 7.0.1 and GlassFish server 3.1
When you say you added classpath entries to manifest.mf, which manifest.mf do you refer to? The one in ear-root/META-INF/manifest.mf ? Try adding a META-INF/MANIFEST.MF to your ejb module with Class-Path entries!