PDA

View Full Version : Claims ContextPathStrategy is missing


ulsa
May 9th, 2008, 03:39 AM
I get a strange error message when starting spring-osgi-web-extender. It claims ContextPathStrategy is not available, or rather that it actually is exported from spring-osgi-web, but not imported by spring-osgi-web-extender:


[FelixStartLevel] INFO org.springframework.osgi.web.extender.internal.act ivator.WarLoaderListener - Starting [org.springframework.bundle.osgi.web.extender] bundle v.[1.1.0.m2]
[FelixStartLevel] ERROR System Bundle - Error starting file:/Users/ulrik/Source/testing-osgi/myapplication/runner/bundles/org.springframework.bundle.osgi.web.extender_1.1.0 .m2.jar
org.osgi.framework.BundleException: Activator start error.
at org.apache.felix.framework.Felix._startBundle(Feli x.java:1629)
at org.apache.felix.framework.Felix.startBundle(Felix .java:1519)
at org.apache.felix.framework.Felix.setFrameworkStart Level(Felix.java:1104)
at org.apache.felix.framework.StartLevelImpl.run(Star tLevelImpl.java:258)
at java.lang.Thread.run(Thread.java:637)
Caused by: java.lang.NoClassDefFoundError: org/springframework/osgi/web/deployer/ContextPathStrategy
at org.springframework.osgi.web.extender.internal.act ivator.WarLoaderListener.start(WarLoaderListener.j ava:243)
at org.apache.felix.framework.util.SecureAction.start Activator(SecureAction.java:589)
at org.apache.felix.framework.Felix._startBundle(Feli x.java:1585)
... 4 more
Caused by: java.lang.ClassNotFoundException: *** Class 'org.springframework.osgi.web.deployer.ContextPath Strategy' was not found because bundle 3 does not import 'org.springframework.osgi.web.deployer' even though bundle 15 does export it. To resolve this issue, add an import for 'org.springframework.osgi.web.deployer' to bundle 3. ***
at org.apache.felix.framework.searchpolicy.R4SearchPo licyCore.findClass(R4SearchPolicyCore.java:195)
at org.apache.felix.framework.searchpolicy.R4SearchPo licy.findClass(R4SearchPolicy.java:45)
at org.apache.felix.framework.searchpolicy.ContentCla ssLoader.loadClass(ContentClassLoader.java:109)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:374)
... 7 more
Caused by: java.lang.ClassNotFoundException: org.springframework.osgi.web.deployer.ContextPathS trategy
at org.apache.felix.framework.searchpolicy.R4SearchPo licyCore.findClassOrResource(R4SearchPolicyCore.ja va:483)
at org.apache.felix.framework.searchpolicy.R4SearchPo licyCore.findClass(R4SearchPolicyCore.java:186)
... 11 more


Looking at the versions, I see that indeed 1.1.0-m2 is used:


[ 3] [Resolved ] [ 5] spring-osgi-web-extender (1.1.0.m2)
...
[ 15] [Active ] [ 5] spring-osgi-web (1.1.0.m2)


Checking the manifest for spring-osgi-web-extender reveals that the package actually is imported:


% unzip -p ~/.m2/repository/org/springframework/osgi/spring-osgi-web-extender/1.1.0-m2/spring-osgi-web-extender-1.1.0-m2.jar META-INF/MANIFEST.MF
Import-Package: ...,org.springframework.osgi.web.deployer;resoluti on:=optional;
version="1.1.0.m2",...
...
Bundle-Version: 1.1.0.m2


Here is the complete bundle listing:


ID State Level Name
[ 0] [Active ] [ 0] System Bundle (1.0.3)
[ 1] [Active ] [ 5] jcl104-over-slf4j (1.4.3)
[ 2] [Active ] [ 5] catalina.start.osgi (1.0.0.SNAPSHOT)
[ 3] [Resolved ] [ 5] spring-osgi-web-extender (1.1.0.m2)
[ 4] [Active ] [ 1] spring-beans (2.5.4)
[ 5] [Active ] [ 1] spring-osgi-io (1.1.0.m2)
[ 6] [Active ] [ 1] aopalliance.osgi (1.0.0.SNAPSHOT)
[ 7] [Active ] [ 5] spring-web (2.5.4)
[ 8] [Active ] [ 1] spring-core (2.5.4)
[ 9] [Active ] [ 5] spring-webmvc (2.5.4)
[ 10] [Active ] [ 1] spring-osgi-extender (1.1.0.m2)
[ 11] [Active ] [ 5] slf4j-api (1.4.3)
[ 12] [Active ] [ 1] spring-aop (2.5.4)
[ 13] [Active ] [ 5] spring-test (2.5.4)
[ 14] [Active ] [ 5] catalina.osgi (6.0.16.SNAPSHOT)
[ 15] [Active ] [ 5] spring-osgi-web (1.1.0.m2)
[ 16] [Active ] [ 1] spring-osgi-core (1.1.0.m2)
[ 17] [Active ] [ 1] spring-context (2.5.4)
[ 18] [Active ] [ 5] slf4j-log4j12 (1.4.3)
[ 19] [Active ] [ 5] backport-util-concurrent.osgi (3.1.0.SNAPSHOT)
[ 20] [Active ] [ 5] se.jayway.labs.spring.osgi.service (1.0.0.SNAPSHOT)
[ 21] [Active ] [ 5] se.jayway.labs.spring.osgi.web (1.0.0.SNAPSHOT)
[ 22] [Active ] [ 5] javax.servlet.api 2.4 [osgi] (2.4)
[ 23] [Active ] [ 1] osgi.compendium (4.0.1)
[ 24] [Active ] [ 1] OPS4J - Pax Logging API (1.1.0)
[ 25] [Active ] [ 1] OPS4J - Pax Logging Service (1.1.0)
[ 26] [Active ] [ 1] spring-context-support (2.5.4)
[ 27] [Active ] [ 1] asm.osgi (2.2.3.SNAPSHOT)
[ 28] [Active ] [ 1] backport-util-concurrent.osgi (3.0.0.SNAPSHOT)
[ 29] [Active ] [ 1] cglib-nodep.osgi (2.1.3.SNAPSHOT)
[ 30] [Active ] [ 1] spring-osgi-annotation (1.1.0.m2)
[ 31] [Active ] [ 1] Apache Felix Shell Service (1.0.0)
[ 32] [Active ] [ 1] Apache Felix Shell TUI (1.0.0)

Costin Leau
May 12th, 2008, 03:28 AM
Ulrik, try using Knoplfish or Equinox - Felix doesn't support fragments and thus what you are trying to do simply doesn't work.

ulsa
May 14th, 2008, 05:39 PM
Thanks for that info. So Felix doesn't support fragments, I had totally missed that.

Now, using Equinox (with Pax Runner), I ran into the same "colon in URL problem" as Craig did a while ago.


MalformedObjectNameException: Invalid character ':' in value part of property


Anybody care to post a working ContextPathStrategy for a URL like this?


/initial@reference:file:com.example.app.web_1.0.0.S NAPSHOT

Costin Leau
May 15th, 2008, 03:20 AM
I tried using the link you posted but it doesn't seem to work.
What version of Spring-DM are you using? The nightly build at least fixes the problem by escaping the characters.
Additionally, S2AP's Web-ContextPath header is supported for specifying the context path.

ulsa
May 15th, 2008, 08:34 AM
Sorry, made a thread link, should've been a post link. It works now.

Like Craig, I use 1.1-m2. I know that S2AP has a fix, but I'm determined to get my stuff working in plain Spring DM first. It's just a simple Spring MVC bundle and a service bundle, so I'm pretty frustrated I can't get it to work.

Costin Leau
May 15th, 2008, 08:57 AM
I meant that Web-ContextPath, available in S2AP's is also supported by Spring-DM through the nightly build.
You can get it from the S3 repo - if that's not an option then I suggest you look at your bundle location (since that one is used by 1.1.0-m2) or create your own ContextPathStrategy.
More information is available at :
http://static.springframework.org/osgi/docs/current/reference/html/web.html#web:configuration

ulsa
May 19th, 2008, 06:03 PM
I checked again and this time I did see the note about Felix and fragments in the docs, but it's not in the FAQ.

The Web-ContextPath works fine.

However, the colon problem remains even if I use rc1-SNAPSHOT:


INFO: Error registering ctx with jmx StandardEngine[Catalina].StandardHost[127.0.0.1].StandardContext[
/initial@reference:file:se.jayway.labs.spring.osgi. web_1.0.0.SNAPSHOT] null javax.management.MalformedObjectNameException: Invalid character ':' in value part of property
javax.management.MalformedObjectNameException: Invalid character ':' in value part of property
at javax.management.ObjectName.construct(ObjectName.j ava:529)
at javax.management.ObjectName.<init>(ObjectName.java:1304)
at org.apache.catalina.core.StandardContext.createObj ectName(StandardContext.java:5173)
at org.apache.catalina.core.StandardContext.preRegist erJMX(StandardContext.java:5182)
at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4095)
at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:525)
at org.springframework.osgi.web.deployer.tomcat.Tomca tWarDeployer.startCatalinaContext(TomcatWarDeploye r.java:144)
at org.springframework.osgi.web.deployer.tomcat.Tomca tWarDeployer.startDeployment(TomcatWarDeployer.jav a:133)
at org.springframework.osgi.web.deployer.support.Abst ractWarDeployer.deploy(AbstractWarDeployer.java:93 )
at org.springframework.osgi.web.extender.internal.act ivator.WarLoaderListener$DeploymentManager$DeployT ask.run(WarLoaderListener.java:185)
at org.springframework.scheduling.timer.DelegatingTim erTask.run(DelegatingTimerTask.java:66)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)

Costin Leau
May 20th, 2008, 04:31 AM
The error suggests that the name contains a colon which is invalid to the JMX exporter. What the name that you are trying to use, the Web-ContextPath or the location?
Can you turn on logging and see what context path Spring-DM is trying to use (in rc1)?

Thanks,

ulsa
May 20th, 2008, 05:32 AM
I'm using the bundle location. If I use the Web-ContextPath, it works fine.

After showing a few stack traces from the JMX-related error, the following is logged:


[Timer-1] INFO org.springframework.osgi.web.deployer.tomcat.Tomca tWarDeployer -
Successfully deployed bundle [se.jayway.labs.spring.osgi.web (se.jayway.labs.spring.osgi.web)]
at [/initial%40reference%3Afile%3Ase.jayway.labs.spring .osgi.web_1.0.0.SNAPSHOT]
on server org.apache.catalina.startup.Embedded/1.0


It hasn't been "successfully deployed" though, since Catalina failed due to the JMX problem.

Costin Leau
May 20th, 2008, 05:59 AM
Ulrik, for the time being I suggest you use the Web-ContextPath - it seems that in your case the bundle location is referred to by Eclipse (hence the initial:reference:file) so the location becomes useless.
Do you know if the bundles are expanded or not? I would assume the former.

ulsa
May 20th, 2008, 06:40 AM
I use 'mvn pax:provision', so I guess every bundle is run from it's jar in the repo.


...
25 ACTIVE se.jayway.labs.spring.osgi.web_1.0.0.SNAPSHOT

osgi> b 25
initial@reference:file:se.jayway.labs.spring.osgi. web_1.0.0.SNAPSHOT.jar/ [25]
Id=25, Status=ACTIVE Data Root=/private/tmp/t/myapp/runner/equinox/org.eclipse.osgi/bundles/25/data

Costin Leau
May 20th, 2008, 01:43 PM
Ulrik, I've raised an issue to follow this problem since it seems fairly common - I hope to have a fix by tomorrow (but don't quote me on that one).
see http://jira.springframework.org/browse/OSGI-496

Costin Leau
May 21st, 2008, 04:00 AM
Ulrik, I've added a fix in the trunk. It would be swell if you could try it out in your scenario - the project unit tests are passing.

ulsa
May 21st, 2008, 12:25 PM
It's a bit hard to say whether my trunk snapshots or the repo snapshots are being used. I think I'll wait for the nightly build.

ulsa
May 21st, 2008, 01:18 PM
I have tested the trunk now (changed to my own version identifier to be sure), and the error remains. Same stack trace as previously posted.

Costin Leau
May 22nd, 2008, 06:48 AM
That's strange - I've enabled logging and I get this transformation:

Bundle location [jar:http@file:url:/somePath/bundle.jar] resulted in context path [bundle]


For some reason I don't currently have access to SourceForge so I cannot commit the implementation with logging but once I can, I'll let you know.

Costin Leau
May 22nd, 2008, 07:01 AM
Just ran your bundle location and I get the following:

No Web-ContextPath found; falling back to bundle location...
Bundle location [initial@reference:file:se.jayway.labs.spring.osgi./web_1.0.0.SNAPSHOT] resulted in context path [web_1.0.0]
Detected context path [web_1.0.0]
Encoding context path [web_1.0.0] to [web_1.0.0]

Hope this helps,

Costin Leau
May 22nd, 2008, 07:09 AM
I just realized that the previous example had an extra / and remove it triggered out the problem you faced. I've fixed it and will commit it once I get access to SourceForge :).
Cheers,

Costin Leau
May 26th, 2008, 06:57 AM
Ulrik, I've committed the fix (it's available in any build after 785) and will be included in the next nightly build. (http://build.springframework.org/browse/OSGI-TRUNK)
Let me know how this works for you.
Cheers,

ulsa
May 28th, 2008, 06:15 AM
I had to wait a day for another snapshot build for some reason, but now it works. Thanks a lot.

It would be cool if the Bamboo build number was in the manifest. There's already a header "Built-By: bamboo", so I guess it's doable.

Costin Leau
May 28th, 2008, 06:55 AM
I wasn't aware of it - it's bnd that creates the manifest header but I'll look it up and see whether we can add the snapshot number to it.
I'm glad things are working for you - I'll keep you updated in case I manage to do something about the build numbering.

Costin Leau
May 29th, 2008, 04:57 PM
Ulsa, I've addressed this issue. All the builds from the build server now contain two extra headers:
Build-Plan:
Build-Version:

Hope this helps,

ulsa
May 30th, 2008, 06:23 AM
Actually, it seems to be Build-Number, not Build-Version. Anyway, very useful; thanks a lot.

Costin Leau
May 30th, 2008, 10:55 AM
Right, Build-Number. Sorry about that...