Real Introduction to Apache Karaf - apache-karaf

We are looking to use Karaf, but their introduction/quick start (main Karaf website) has almost nothing to say about deploying apps to the container - I know, amazing yet true. Anyone know of a useful introduction for someone completely new to Karaf? Thanks.

I guess you looked at the wrong places the, cause the user and developer dokumentation tells you that you either deploy your artefacts either by dropping in the deploy folder, by installing with osgi:install url, by adding/installing features and so forth. I really recommend RTFM, it's there. In case you still didn't find what your looking for ask the users mailing-list.
At this site you'll find the Karaf Online Documentation

A google for keywords: java, osgi bundle, activator
will turn up examples of how to code for Karaf. For example: http://www.javaworld.com/javaworld/jw-03-2008/jw-03-osgi1.html?page=2
Also, after learning the keywords (OSGI and bungle) I noticed netbeans has a project type of "OSGi Bundle". How nice.

Here are some useful links:
How to use Karaf console: http://karaf.apache.org/manual/latest/users-guide/console.html
Christian Schneider has some useful tutorials as well: http://www.liquid-reality.de/display/liquid/Karaf+Tutorials
Jean-Baptiste Onofre blog (search on Google)
Pay attention that Karaf 3 has slightly different shell commands, so make sure that you are pointing to the right Karaf or you learn how to translate Karaf 2.x commands to Karaf 3.

Related

How do I setup/edit Alfresco Source Code from the Github Repo

im completely new to working with open-source software and at the moment I am very lost. I understand that the source code is located in the Alfresco repo on Github(https://github.com/Alfresco). What I'm trying to do is aquring Alfresco Community source code and modify it for a project im working on. Do i download each repo from the links below, import it into an ide like eclipse and connect eclipse to the tomcat server? Also is this the correct repo(https://github.com/Alfresco/share)for Alfresco Share that will open in the browser when i connect it to the Tomcat server?
alfresco-remote-api https://github.com/Alfresco/alfresco-remote-api
alfresco-greenmail https://github.com/Alfresco/alfresco-greenmail
alfresco-file-transfer-receiver https://github.com/Alfresco/alfresco-file-transfer-receiver
alfresco-mbeans https://github.com/Alfresco/alfresco-mbeans
alfresco-mmt https://github.com/Alfresco/alfresco-mmt
alfresco-server-root https://github.com/Alfresco/alfresco-server-root
alfresco-data-model https://github.com/Alfresco/alfresco-data-model
alfresco-core https://github.com/Alfresco/alfresco-core
alfresco-xml-factory https://github.com/Alfresco/alfresco-xml-factory
alfresco-legacy-lucene https://github.com/Alfresco/alfresco-legacy-lucene
Any help would be appreciated.
Jimmy, welcome to the world of open source software, we're glad you're here.
These days, it is exceedingly rare to need to compile Alfresco or Alfresco Share from source.
Instead, the right thing to do is use a public extension point and simply extend the platform to meet your requirements. This will greatly simplify things when it comes time to upgrade, and you won't be forking a massive codebase (and maintaining that fork going forward).
You didn't mention what you are trying to change, but most common scenarios are covered by one or more of my tutorials so hopefully those will help.
If you look at those tutorials, you ask around the community a bit, and you still think you need to change a file that is distributed with the Alfresco source, please file an issue at https://issues.alfresco.com/ so that Alfresco knows about the needed improvement.

Is there a direct way to get a full ejb/servlet application example for glassfish

I have an application that is currently running on JBoss AS but does not work on Glassfish. I'm trying to work through the documentation here but I'm having trouble figuring out things like what the file structure of the application should be and what (if any) additional files are needed. This documentation also refers to examples but to get the examples you need to install Netbeans and access an update tool tied to the glassfish instance installed with Netbeans. When I do this the server won't start, the update tool won't run, and I can't get the examples. Is there an easy way to get these examples (e.g. a simple download)? I've found other examples such as this one, but they are also dependent upon Netbeans.
Is there a simple and complete ejb/servlet example for Glassfish that can be simply downloaded and does not depend upon Netbeans or other IDE?
The obvious example is the Java EE CargoTracker. It was written to show what a "real" application might look like with pure Java EE APIs so should work on both JBoss and GlassFish. You will need Maven installed to build and run it, but there are more complete details in the readme for the project. Note that some of the information is a little out of date (mostly links to java.net which has been sunset in favour of a GitHub site) but the application itself is still a good example of Java EE 7 APIs.
https://github.com/javaee/cargotracker
I found the examples on github here:
https://github.com/javaee/glassfish-samples
To get and build the examples you will need Git and Maven. These examples are small, complete, and concise. The example that was helpful for my particular problem was this example:
glassfish-samples\ws\javaee5\enterprise\servlet-stateless-ear
It demonstrated that I needed to change the structure of my project such that the servlet was in a .war file and not in a .jar file in the lib folder of my project.

Jboss Fuse 6.2, install custom features to profile in fabric

I was able to do what I'm goin to describe in Fuse 6.1 but now in Fuse 6.2 I get an exception and it is not working anymore.
By following a tutorial, I build a "multi module" project that has a features component in order to install all the needed bundles.
I'm working on a fabric container with a child container.
I create a new profile and then from hawtio console I try to add the feature repository. (BTW I have the same problem if I use the terminal console)
The feature repository is added correctly (that's what fuse says at least) but when I enter the page to add any feature I see this in the log:
org.eclipse.aether.resolution.ArtifactResolutionException: Could not
find artifact it.mytria.demo:esercizio1-feature:xml:features:1.0.0 in
karaf-default
(file:C:/servers/fuse/system/)
Of course, it is right, since I never installed the bundle in that folder, but I have it in my local .m2/repository
Now, the question is, has anyone ever installed a custom feature in Jboss 6.2 and can help me get out from this situation?
The only solution I found is to manually copy the feature and all the custom bundled indicated by the feature in the "/system" folder, but I never had to do this in Fuse 6.1 so I don't like this solution at all.
Other thing, there is a conf file in Fuse 6.2 that has changed from Fuse 6.1, C:\servers\fuse\etc\io.fabric8.maven.cfg and it is the only file I found pointing to the system folder... but I'm afraid that if I add the .m2 folder here then Fuse will try to search there any bundle even those that has to be really taken from system folder.
So far I haven't find any other difference in the config file about maven repository.
There is any good guy out there that know how to make this thing work?
Please, if I missed some important information, let me know, I'll try my best to complete the question.
Thank you very much.
I installed a clean JbossFuse 6.2.0. Then from the hawtio console I just add the repository to the profile using
mvn:it.mytria.demo/esercizio1-feature/1.0.0/xml/features
and it worked.
So... I have no idea what went wrong the first time. I made no changes to the projects code or pom configuration of the bundles.

Apache Karaf dependency on network

I am using Apache Karaf 2.3.0, and deploying my bundles as Activator bundles. At some place ver rarely I face a problem where my karaf does not start up the bundles. But I see that when i start the container on such boxes with the network(on my Linux box) brought down, it starts up. I am just a bit confused as to what is the dependency that Karaf is having on the network, that is stopping it from resoving all the bundles. From my application specific bundle code, I am not specifically using the network.
What is the dependency of Karaf on the network?
Karaf deploys bundles as maven artifacts, sometimes it will try to figure out to use the latest from the repository. I think there has been a fix for this behavior already. You should use the latest 2.3.9 instead of 2.3.0. There has been a lot of improvements regarding this topic.
EDIT - Question Answers:
1) Karaf sometimes tries to load the artifacts from the local maven repository and after that from the system folder. This is a regression that has been fixed.
2) Yes this issue has been fixed on all current versions.
3) I would always go for version 3.0.2 since this is in line with future enhancements. 2.4. was introduced to have OSGi 5 capabilities with supporting the "Older" feature set, especially the command syntax which has been changed with 3.0
4) yes and has been made default with 3.0.x and 2.3.x
Got it running. It was indeed maven i believe. resolv.conf file on my linux box had ip entries in it which probably made maven to look outside, but was not getting a proper response. Removed the mvn urls from the /etc/ file and restarted the karaf and it started.
But i am yet confused as to how this works on the other boxes... thanks Achim

Adobe CQ5 Setup in production

I am not a CQ guy. I have to use CQ5 for one of my project. I have a CAT and a production environment. I have following doubts-
I want to use author instance of my CAT only. Once I publish the content in CAT it should publish in Production also. Is it possible ?
Once I update the build of AdobeCQ in my production say new build, code changes etc- will my content be lost ?
I read somewhere about Content package in cq5. Can I separate content changes and code changes in one CQ5 environment ?
Thanks in advance.
To answer question 1...
This is not a recommended setup, but a common misconception for someone unfamiliar with AEM/CQ5. The "author" and "publish" instances should be part of the same environment. For example you should have a production author, probably behind your firewall, and production publish to serve pages to the public.
Your CAT environment should have the same thing. You want your testing environment to match as closely as possible to your production environment, including web server and dispatcher setup, to ensure quality.
Consider this. You can use one production publish instance, but it's a single point of failure. It's a general best practice to load balance across at least two. Two is sufficient for most websites. If you do this, you'd want to mimic the architecture in CAT.
To answer question 2...
If your code is written, built, and deployed correctly, it should not delete your content. Just make sure you are never deploying anything to /content (to avoid deleting content) and to /libs and most of /etc to avoid overriding platform functionality. AEM/CQ5 is a very open product, so you can do very bad things. But, if you know what not to do you are safe.
Code deployments should typically be done as part of a CRX Content Package, which brings me to...
To answer question 3...
The way we build and deploy code is to have Maven compile the Java, package everything up in a CRX Package, then deploy to the instance using the Package Manager REST API. Adobe provides a Maven Archetype that will facilitate this.
A CRX Package is a file system representation of your content repository, wrapped in what is effectively an annotated Zip file. Your compiled Java code is included in that file system representation, in a folder (to become node) named "config". That compiled Java is an OSGi bundle, which is an annotated JAR. When CRX Package Manager deploys all those nodes to the system, OSGi accepts the bundle, assuming it's valid. This is why you can do "hot" deployments of live, production AEM/CQ5 instances, with very little risk.
So...
This is a very high level answer to some very big topics. I encourage you to do a lot more research before you set this up. There are many good blog posts and documentation pages out there to help you get this set up according to best practice. Good luck!

Resources