wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Do I need OSGi or other technology? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Do I need OSGi or other technology?" Watch "Do I need OSGi or other technology?" New topic
Author

Do I need OSGi or other technology?

Jean Marcel Bacan
Greenhorn

Joined: Dec 04, 2012
Posts: 15
Hi guys, I need to develop an application that I cad add or remove jar or classes (Also need un interface to do that). Each one of these classes or jar will execute a different scheduled job.
My idea was an application that read these jars or execute servlets dynamically without know them. While studying OSGi(for a day) I've noticed that i need a container running but
I would like to use weblogic which is the default web server i use for other apps.

Do i really need OSGi?
A small web server that supports jee6 doesn't work?

Any suggestions?

Thanks



OCPJP 6
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2273
    
  28

What are you trying to do? call classes bundled in third party jars in your web application? or execute servlets from third parties.... inside your servlet?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
A "container" is OSGi's terms could be as simple as one class that you write yourself, or it could be something pre-made like Apache Karaf. But regardless, you can run it in any Java environment, including servlet containers or JEE servers. So the either/or situation that you're asking about really does not exist.

I wrote my own container that consisted of a few classes when I got into OSGi (using the Apache Felix implementation), but that was before Karaf came along. Nowadays I might use that instead of rolling my own; haven't had a chance to check it out in depth, though.

Some of the material linked in the http://www.coderanch.com/how-to/java/OSGiLinks should be interesting.


Ping & DNS - my free Android networking tools app
Jean Marcel Bacan
Greenhorn

Joined: Dec 04, 2012
Posts: 15
Thanks, I'm studying those links Ulf Dittmer.

What I'm trying to do is have an application running that reads a jar without know it, but starts when I deploy it.

I'm using these Felix with Pax to start a web console. But would be better use a "bundle manager" in my weblogic server.

So when another developer creates a jar with some task, that I and my "Web Console bundle manager" don't know what its, the task can be deployed and started by the Web Console.

Could make myself clear? English its not my native language so my explanation looks confuse.

Thanks for the help.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
Yes, it's clear. That's one of the main uses cases for OSGi.
Jean Marcel Bacan
Greenhorn

Joined: Dec 04, 2012
Posts: 15
There is a way that i can copy/paste a jar into some folder and my OSGI container (felix) load and start it?

Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
That's pretty much the way it works (or can be made to work, depending on the container).
Jean Marcel Bacan
Greenhorn

Joined: Dec 04, 2012
Posts: 15
I could make the Equinox in servlet container work, because we use weblogic. But worked with Felix container with jetty as a bundle, then i deployed the sample-http using the web interface.

There is a updated project or tutorial that I could use? i still prefer the Osgi in the servlet container, to use just weblogic.

Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
Um, tutorial for what? It sounds like you have successfully used the Felix HTTP stuff already ... ?
Jean Marcel Bacan
Greenhorn

Joined: Dec 04, 2012
Posts: 15
Yes I used with maven and could run the webapp and start my bundle.

Talking to my boss he wants something like this:

Deploy an webapp in Weblogic that starts Felix and not Equinox (as i did).
Use just one Servlet that is capable to list and execute any bundle that the name came in the request parameters.

I'm trying now to understand the Sling project, but look likes its too much for what I need, i just want to start felix with one WAR in my weblogic. After this i code a servlet that reads the avaiable bundles in a specific path.

Thanks for help.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
It sounds like you need the Apache Felix HTTP Service and the Apache Felix Web Console. Those pages both have instructions how to get started with them.

Or use Karaf: http://karaf.apache.org/manual/2.2.5/users-guide/web-applications.html
Jean Marcel Bacan
Greenhorn

Joined: Dec 04, 2012
Posts: 15
Exactly, i did the Servlet bridge sample and get the result:

<OSGi framework started>
*INFO * Failed to instantiate plugin org.apache.felix.webconsole.internal.compendium.ComponentsServlet. Reason: java.lang.NoClassDefFoundError: org.apache.felix.scr.ScrService
*INFO * Failed to instantiate plugin org.apache.felix.webconsole.internal.misc.ShellServlet. Reason: java.lang.NoClassDefFoundError: org.apache.felix.shell.ShellService
## [servlet1] Init with config [org.apache.felix.http.base.internal.handler.ServletConfigImpl@258792]
## [servlet2] Init with config [org.apache.felix.http.base.internal.handler.ServletConfigImpl@d32a52]
## [filter1] Init with config [org.apache.felix.http.base.internal.handler.FilterConfigImpl@1bcbe77]
## [filter2] Init with config [org.apache.felix.http.base.internal.handler.FilterConfigImpl@1bdc523]

webconsole is a bundle, but i don't know how to test it. My http://localhost:7001/bridge/ return 404.

Thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Do I need OSGi or other technology?
 
Similar Threads
OSGI usage in the ecosystem
Modular Java: Web Container Modules
Can I access an Eclipse Plug-in Jar from a normal Java Project
General Questions on OSGi
OSGi and Spring DM: Enterprise Beans, JEE Containers and WEB UI