PDA

View Full Version : Catalina and equinox...


mburbidg
May 16th, 2008, 04:15 PM
I gave up on trying to get pax-runner to work for me. I could not get it to find the artifacts at http://maven.springframework.org/osgi. I verified that it is something with pax-runner, because I was able to use maven to download the artifacts.

So now I'm on to try to get raw equinox to work. I'm just trying to get a hello world web application working with equinox and catalina. So first, I'm just trying to get catalina running within equinox using the catalina.osgi-5.5.23, and catalina.start.osgi-1.0. I downloaded these from the spring osgi repository.

I followed the instructions at http://www.eclipse.org/equinox/documents/quickstart.php to try and get this going. It seems like it should be simple.

I have a directory with the following layout:


root
configuration
config.ini
org.eclipse.equinox.common_3.3.0.v20070426.jar
org.eclipse.osgi_3.3.2.R33x_v20080105.jar
org.eclipse.update.configurator_3.2.101.R33x_v2007 0810
plugins
catalina.osgi-5.5.23-SNAPSHOT.jar
catalina.start.osgi-1.0-SNAPSHOT.jar


My config.ini contains the following:


eclipse.ignoreApp=true
osgi.clean=true
osgi.startLevel=6
osgi.bundles.defaultStartLevel=5

osgi.bundles=\
org.eclipse.equinox.common@2:start,\
org.eclipse.update.configurator@3:start


I start equinox using the following command:


java -jar org.eclipse.osgi_3.3.2.R33x_v20080105.jar -console


Equinox starts up fine and if I do a status it reports the following as you would expect:


id Bundle Location
State Bundle File Name
0 System Bundle
ACTIVE org.eclipse.osgi_3.3.2.R33x_v20080105
1 initial@reference:file:org.eclipse.equinox.common_ 3.3.0.v20070426.jar/
ACTIVE org.eclipse.equinox.common_3.3.0.v20070426
2 initial@reference:file:org.eclipse.update.configur ator_3.2.101.R33x_v20070810.jar/
ACTIVE org.eclipse.update.configurator_3.2.101.R33x_v2007 0810
3 update@plugins/catalina.osgi-5.5.23-SNAPSHOT.jar
INSTALLED org.springframework.osgi.catalina.osgi_5.5.23.SNAP SHOT
4 update@plugins/catalina.start.osgi-1.0-SNAPSHOT.jar
RESOLVED org.springframework.osgi.catalina.start.osgi_1.0.0 .SNAPSHOT


But if I execute the following command to start up the catalina.start.osgi bundle:


start org.springframework.osgi.catalina.start.osgi


I get the following exceptions, which indicate to me that somehow catalina.start.osgi is not able to find catalina.osgi.


org.osgi.framework.BundleException: The activator org.springframework.osgi.web.tomcat.internal.Activ ator for bundle org.springframework.osgi.catalina.start.osgi is invalid
at org.eclipse.osgi.framework.internal.core.AbstractB undle.loadBundleActivator(AbstractBundle.java:141)
at org.eclipse.osgi.framework.internal.core.BundleCon textImpl.start(BundleContextImpl.java:970)
at org.eclipse.osgi.framework.internal.core.BundleHos t.startWorker(BundleHost.java:346)
at org.eclipse.osgi.framework.internal.core.AbstractB undle.start(AbstractBundle.java:260)
at org.eclipse.osgi.framework.internal.core.AbstractB undle.start(AbstractBundle.java:252)
at org.eclipse.osgi.framework.internal.core.Framework CommandProvider._start(FrameworkCommandProvider.ja va:260)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.osgi.framework.internal.core.Framework CommandInterpreter.execute(FrameworkCommandInterpr eter.java:150)
at org.eclipse.osgi.framework.internal.core.Framework Console.docommand(FrameworkConsole.java:300)
at org.eclipse.osgi.framework.internal.core.Framework Console.console(FrameworkConsole.java:285)
at org.eclipse.osgi.framework.internal.core.Framework Console.run(FrameworkConsole.java:221)
at java.lang.Thread.run(Thread.java:613)
Caused by: java.lang.NoClassDefFoundError: org/apache/catalina/Container
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Cla ss.java:2357)
at java.lang.Class.getConstructor0(Class.java:2671)
at java.lang.Class.newInstance0(Class.java:321)
at java.lang.Class.newInstance(Class.java:303)
at org.eclipse.osgi.framework.internal.core.AbstractB undle.loadBundleActivator(AbstractBundle.java:136)
... 14 more
Nested Exception:
java.lang.NoClassDefFoundError: org/apache/catalina/Container
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Cla ss.java:2357)
at java.lang.Class.getConstructor0(Class.java:2671)
at java.lang.Class.newInstance0(Class.java:321)
at java.lang.Class.newInstance(Class.java:303)
at org.eclipse.osgi.framework.internal.core.AbstractB undle.loadBundleActivator(AbstractBundle.java:136)
at org.eclipse.osgi.framework.internal.core.BundleCon textImpl.start(BundleContextImpl.java:970)
at org.eclipse.osgi.framework.internal.core.BundleHos t.startWorker(BundleHost.java:346)
at org.eclipse.osgi.framework.internal.core.AbstractB undle.start(AbstractBundle.java:260)
at org.eclipse.osgi.framework.internal.core.AbstractB undle.start(AbstractBundle.java:252)
at org.eclipse.osgi.framework.internal.core.Framework CommandProvider._start(FrameworkCommandProvider.ja va:260)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.osgi.framework.internal.core.Framework CommandInterpreter.execute(FrameworkCommandInterpr eter.java:150)
at org.eclipse.osgi.framework.internal.core.Framework Console.docommand(FrameworkConsole.java:300)
at org.eclipse.osgi.framework.internal.core.Framework Console.console(FrameworkConsole.java:285)
at org.eclipse.osgi.framework.internal.core.Framework Console.run(FrameworkConsole.java:221)
at java.lang.Thread.run(Thread.java:613)
Nested Exception:
java.lang.NoClassDefFoundError: org/apache/catalina/Container
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Cla ss.java:2357)
at java.lang.Class.getConstructor0(Class.java:2671)
at java.lang.Class.newInstance0(Class.java:321)
at java.lang.Class.newInstance(Class.java:303)
at org.eclipse.osgi.framework.internal.core.AbstractB undle.loadBundleActivator(AbstractBundle.java:136)
at org.eclipse.osgi.framework.internal.core.BundleCon textImpl.start(BundleContextImpl.java:970)
at org.eclipse.osgi.framework.internal.core.BundleHos t.startWorker(BundleHost.java:346)
at org.eclipse.osgi.framework.internal.core.AbstractB undle.start(AbstractBundle.java:260)
at org.eclipse.osgi.framework.internal.core.AbstractB undle.start(AbstractBundle.java:252)
at org.eclipse.osgi.framework.internal.core.Framework CommandProvider._start(FrameworkCommandProvider.ja va:260)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.osgi.framework.internal.core.Framework CommandInterpreter.execute(FrameworkCommandInterpr eter.java:150)
at org.eclipse.osgi.framework.internal.core.Framework Console.docommand(FrameworkConsole.java:300)
at org.eclipse.osgi.framework.internal.core.Framework Console.console(FrameworkConsole.java:285)
at org.eclipse.osgi.framework.internal.core.Framework Console.run(FrameworkConsole.java:221)
at java.lang.Thread.run(Thread.java:613)



Now I'm expecting that when it is able to find it that there will be a lot of other dependencies that I will have to download, but I'm just trying to take it one step at a time.

Any clues as to why catalina.osgi is not found?

Thanks,
Michael-

oleg.zhurakousky
May 17th, 2008, 01:08 AM
Michael

Your startup bundle finds your catalina just fine. Your problem is you are missing few more dependencies.

catalina.osgi depends on servlet-api.osgi
and
both catalina.osgi and catalina.start.osgi depend on logging bundles
so basicly this is what you need:


Framework is launched.

id State Bundle
0 ACTIVE org.eclipse.osgi_3.4.0.v20080205
2 ACTIVE org.springframework.osgi.log4j.osgi_1.2.15.SNAPSHO T
3 ACTIVE org.springframework.osgi.catalina.start.osgi_1.0.0 .SNAPSHOT
6 ACTIVE org.springframework.osgi.servlet-api.osgi_2.5.0.SNAPSHOT
8 ACTIVE slf4j.api_1.4.3
9 ACTIVE jcl104.over.slf4j_1.4.3
11 ACTIVE slf4j.log4j12_1.4.3
12 ACTIVE org.springframework.osgi.catalina.osgi_5.5.23.SNAP SHOT


Let me know if you have more problems

mburbidg
May 17th, 2008, 11:16 AM
I was assuming that I would be able to see in the logs, what symbols were missing. I seems like I am now. Perhaps it was just because logging wasn't available. Anyway, thanks so much. I'm on my way now.

mburbidg
May 18th, 2008, 08:28 PM
As I said earlier, my first step is just to try and get catalina running inside equinox. It seems like I'm almost there. It is running, as is indicated by the following log messages from equinox.


INFO: Starting Apache Tomcat/5.5.23 ...
May 17, 2008 4:48:56 PM org.springframework.osgi.web.tomcat.internal.Activ ator createCatalinaServer
INFO: Using default XML configuration bundleresource://4/conf/default-server.xml
May 17, 2008 4:48:56 PM org.apache.catalina.startup.ClusterRuleSetFactory getClusterRuleSet
INFO: Unable to find a cluster rule set in the classpath. Will load the default rule set.
May 17, 2008 4:48:56 PM org.apache.catalina.startup.ClusterRuleSetFactory getClusterRuleSet
INFO: Unable to find a cluster rule set in the classpath. Will load the default rule set.
May 17, 2008 4:48:56 PM org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
May 17, 2008 4:48:56 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 13 ms
May 17, 2008 4:48:56 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
May 17, 2008 4:48:56 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.23
May 17, 2008 4:48:56 PM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
May 17, 2008 4:48:56 PM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
May 17, 2008 4:48:56 PM org.springframework.osgi.web.tomcat.internal.Activ ator$1 run
INFO: Succesfully started Apache Tomcat/5.5.23 @ Catalina:8080
May 17, 2008 4:48:56 PM org.springframework.osgi.web.tomcat.internal.Activ ator$1 run
INFO: Published Apache Tomcat/5.5.23 as an OSGi service


But when I try to hit localhost:8080 I get the following reply:


HTTP/1.1 400 No Host matches server name localhost
Server: Apache-Coyote/1.1
Transfer-Encoding: chunked
Date: Sat, 17 May 2008 23:49:06 GMT
Connection: close


This is different than if it is not running at all. (equinox shutdown) Then I get no reply. But in this case I did get a reply from catalina.

My understanding was that by default the osgi catalina bundle and the start bundle were set up by default so that they were listening on localhost:8080. Any ideas what may be wrong?

oleg.zhurakousky
May 19th, 2008, 02:49 PM
Could you unpack your catalina.start.osgi, go to config directory and post the contents of your default-server.xml file and .properties file.

mburbidg
May 19th, 2008, 03:32 PM
Here's the contents of default-server.xml


<Server port="8005" shutdown="SHUTDOWN">


<Service name="Catalina">
<Connector port="8080" />

<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost" unpackWARs="false" autoDeploy="false"
liveDeploy="false" deployOnStartup="false"
xmlValidation="false" xmlNamespaceAware="false"/>
</Engine>

</Service>
</Server>


Here's the contents of embedded-server-defaults.properties


# if no value is supplied, defaults will be applied

# default = the dir in which the java process is started
home =
# localhost name used (note that this can be different then localhost)
host = localhost
# if not specified, a random port will be used
port = 8080


Thanks,
Michael-

oleg.zhurakousky
May 19th, 2008, 03:42 PM
Mike

Sorry, I am in route, but will look into that later on tonight or tomorrow.
I thought I'll see something obvious, but I didn't. At this point it is past Spring DM and is Tomcat issue. I did a quick googling and seem like it is a pretty common error. Just do a google search on:

HTTP/1.1 400 No Host matches server name localhost


But as I said I'll look into that later on. If you find something, please post the solution here.
Cheers

Costin Leau
May 20th, 2008, 01:41 PM
Michael, adding to what Oleg already said, the Tomcat version is used in the nightly build and on my machine meaning on both linux and windows.
The default-server.xml is taken from the official Tomcat distribution and the parsing is done by Tomcat as well.
You could try turning logging on on Tomcat packages (see their docs) and see whether that shows anything new.

Cheers,

mburbidg
May 25th, 2008, 12:27 AM
I finally got both equinox and Knoplerfish working with Catalina. I'd be glad to share my barebones configuration of equinox and catalina. I've even included a fragment that is associated with the catalina start bundle that allows you to configure catalina. Just for the configuration, I've changed the default http port to 8090, using this fragment.

On to bigger and better things, getting my Spring application componentized and moved over to Spring-DM. Hopefully things will speed up a bit.

Thanks for all the help so far,
Michael-

Costin Leau
May 25th, 2008, 04:51 AM
Glad to hear this Michael. I'm curious to know what was the issue in your case and if there is anything that can be done to improve the existing documentation. By the way, there is already a tutorial in the works that hopefully will address most of the configuration issues you have encountered so far but never the less, feedback on the existing docs is important.

Cheers,

mburbidg
May 25th, 2008, 10:37 AM
Working with Knoplerfish really helped. The tools and documentation are much better than equinox. The main focus with the equinox docs and tools is writing Eclipse plug-ins. You're almost on your own if you just want to use equinox for server-side framework.

The problem really boiled down to getting the appropriate configuration file built with the minimal but complete set of osgi-ified set of libraries and bundles. What was really misleading and wasted a lot of my time, is that is seems like equinox sometimes reports that a class is not found for bundle x which depends on y, when it was really that bundle y depended on bundle z. I believe this was the case where I was getting this error:

java.lang.NoClassDefFoundError: org/apache/catalina/Container

The other thing was from the documentation or this forum I was under the impression that plugins/jcl104-over-slf4j-1.4.3.jar provided all that was needed for apache commons logging. But you actually need com.springsource.org.apache.commons.logging-1.1.1.jar also. In that case I should have just followed my gut rather than believed my interpretation of what I'd read.

Basically its tough learning so many new technologies all at once. I hadn't worked with pax-runner (which in the end I didn't use), maven, OSGi, eclipse, or knoplerfish. Its a bit overwhelming. I actually believe that tools like pax-runner and maven make learning technologies more difficult, because they hide details that a new comer really needs to understand. I think they great tools, but not for tutorials and learning. If I'm learning eclipse/Spring-DM, I would rather be given a working, barebones configuration/sample with nothing that hides the details.

Thanks,
Michael-