Apache Felix HTTP service HttpServiceImpl.isNameValid does not match OSGi R4.2 spec?

2010-11-08 Thread Misha Koshelev
Dear All:

Thank you all for your help and patience with me.

I am working on the following OpenMRS ticket:
http://tickets.openmrs.org/browse/TRUNK-1596

I am trying to use Apache Felix instead of Spring DM Web Extender.

I have had some problems with JSP support, and am trying to use the
Equinox JSP bundle:
http://www.eclipse.org/equinox/server/jsp_support.php
with Felix, specifically using the bridge sample in 2.0.4. I have
double checked code in trunk.

I _am_ successful with Equinox servlet bridge, see:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=329706

However, this example:
http://prdownloads.sourceforge.net/sse-examples/org.eclipse.equinox.jsp.examples-proj.zip?download

contains the following lines in org.eclipse.equinox.jsp.examples.Activator:

HttpContext commonContext = new
BundleEntryHttpContext(context.getBundle(), "/web"); //$NON-NLS-1$
httpService.registerResources("/jsp-examples", 
"/",
commonContext); //$NON-NLS-1$ //$NON-NLS-2$

Servlet adaptedJspServlet = new 
ContextPathServletAdaptor(new
JspServlet(context.getBundle(), "/web"), "/jsp-examples");
//$NON-NLS-1$//$NON-NLS-2$

httpService.registerServlet("/jsp-examples/*.jsp",
adaptedJspServlet, null, commonContext); //$NON-NLS-1$

Felix bridge complains:

java.lang.IllegalArgumentException: Malformed resource name [/]
at 
org.apache.felix.http.base.internal.service.HttpServiceImpl.registerResources(HttpServiceImpl.java:105)
at 
org.eclipse.equinox.jsp.examples.Activator$HttpServiceTracker.addingService(Activator.java:38)
at 
org.osgi.util.tracker.ServiceTracker$Tracked.trackAdding(ServiceTracker.java:1030)

The relevant code, in trunk, is, from
http://svn.apache.org/repos/asf/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceImpl.java


 public void registerResources(String alias, String name, HttpContext context)
throws NamespaceException
{
if (!isNameValid(name)) {
throw new IllegalArgumentException( "Malformed resource
name [" + name + "]");
}
...

and


private boolean isNameValid(String name)
{
if (name == null) {
return false;
}

if (name.endsWith( "/" )) {
return false;
}

return true;
}

However, the R4.2 enterprise spec from
http://www.osgi.org/Download/File?url=/download/r4v42/r4.enterprise.pdf
on page 48 clearly states:

The name parameter must also not end with slash (’/’) with the
exception that a name of the form “/” is used to denote the root of
the bundle.

Should isNameValid not read, similar to isAliasValid, in the same file:

private boolean isNameValid(String name)
{
if (name == null) {
return false;
}

if (!name.equals("/") && ( !name.startsWith("/") ||
name.endsWith("/"))) {
return false;
}

return true;
}

???

Thank you

Yours
Misha


JSP support: works in bridged Equinox HTTP service, _not_ in bridged Felix; _exact_ same bundles

2010-11-08 Thread Misha Koshelev
Dear All:

Sorry to bother... I have included detailed instructions here:
http://tickets.openmrs.org/browse/TRUNK-1596?focusedCommentId=163216&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_163216

but the gist is that using JSP support that exists for Equinox container:
http://www.eclipse.org/equinox/server/jsp_support.php

I _am_ able to get JSPs to function properly in Equinox servlet
bridge, but _not_ in Felix.

We (OpenMRS) like Felix as it is, in fact, quite Maven friendly,
whereis Equinox does not seem to be :(

The only thing that I am doing that may be somewhat non-kosher is the line:
sed -i 
"s/javax.servlet;javax.servlet.http;version=2.5/javax.servlet;javax.servlet.http;javax.servlet.resources;version=2.5/"
WEB-INF/framework.properties

As otherwise javax.servlet.resources is not found. This seems to be a
bunch of DTD files in javax.servlet, but is not present (from what I
can tell) _either_ in my Equinox or Felix setup.

Clearly, the pages _are_ being served correctly, and the _only_ quirk
is that JSP expression fail to be evaluated at all in Felix but _not_
in Equinox.

Additionally, taglibs are not loaded at all.

My WEB-INF/bundles folder:

WEB-INF/bundles/org.eclipse.equinox.http.helper-1.0.0.jar
WEB-INF/bundles/org.eclipse.equinox.jsp.examples_1.0.0.jar
WEB-INF/bundles/org.apache.felix.http.samples.filter.jar
WEB-INF/bundles/com.springsource.javax.el-1.0.0.jar
WEB-INF/bundles/com.springsource.org.apache.taglibs.standard-1.1.2.jar
WEB-INF/bundles/org.eclipse.equinox.jsp.jasper_1.0.0.v20070607.jar
WEB-INF/bundles/org.springframework.osgi.jasper.osgi_5.5.23.SNAPSHOT.jar
WEB-INF/bundles/com.springsource.javax.servlet.jsp.jstl-1.1.2.jar
WEB-INF/bundles/com.springsource.org.apache.commons.el-1.0.0.jar
WEB-INF/bundles/org.apache.felix.webconsole.jar
WEB-INF/bundles/org.apache.felix.http.bridge.jar
WEB-INF/bundles/com.springsource.javax.servlet.jsp-2.1.0.jar
WEB-INF/bundles/com.springsource.org.apache.commons.logging-1.0.4.jar

otherwise, besides changing framework.properties and the bundle
additions, completely unmodified from default 2.0.4 bridge example.

Any thoughts?

Thank you
Misha

p.s. I have not investigated, but I could not quickly find a way to
use the embedded "web console" feature, and see the errors below. I
doubt this would be helpful (all packages are clearly resolved and
installed as the JSP example package works - at least to my
understanding), but it would be nice to have _proof_ of this:
[INFO] Started bridged http service
2010-11-08 19:27:39.847:WARN:felix-bridge:OSGi framework startednull
*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
#

p.p.s. Same exact results on trunk.

Here are slightly modified instructions for trunk.

cd /tmp
rm -rf felix > /dev/null 2>&1
mkdir felix
cd felix
svn checkout http://svn.apache.org/repos/asf/felix/trunk/http/ -q
cd http
mvn clean install -DskipTests
mkdir tmp
cp samples/bridge/target/org.apache.felix.http.samples.bridge-2.0.5-SNAPSHOT.war
tmp
cd tmp
jar xvf org.apache.felix.http.samples.bridge-2.0.5-SNAPSHOT.war
sed -i 
"s/javax.servlet;javax.servlet.http;version=2.5/javax.servlet;javax.servlet.http;javax.servlet.resources;version=2.5/"
WEB-INF/framework.properties
cd WEB-INF/bundles
wget 
http://repository.springsource.com/ivy/bundles/external/javax.el/com.springsource.javax.el/1.0.0/com.springsource.javax.el-1.0.0.jar
wget 
http://repository.springsource.com/ivy/bundles/external/javax.servlet/com.springsource.javax.servlet.jsp/2.1.0/com.springsource.javax.servlet.jsp-2.1.0.jar
wget 
http://repository.springsource.com/ivy/bundles/external/javax.servlet/com.springsource.javax.servlet.jsp.jstl/1.1.2/com.springsource.javax.servlet.jsp.jstl-1.1.2.jar
wget 
http://repository.springsource.com/ivy/bundles/external/org.apache.commons/com.springsource.org.apache.commons.el/1.0.0/com.springsource.org.apache.commons.el-1.0.0.jar
wget 
http://repository.springsource.com/ivy/bundles/external/org.apache.commons/com.springsource.org.apache.commons.logging/1.0.4/com.springsource.org.apache.commons.logging-1.0.4.jar
wget 
http://repository.springsource.com/ivy/bundles/external/org.apache.taglibs/com.springsource.org.apache.taglibs.standard/1.1.2/com.springsource.org.apache.taglibs.standard-1.1.2.jar
wget 
http://mirrors.ibiblio.org/pub/mirrors/maven2/org/eclipse/equinox/jsp/jasper/1.0.0-v20070607/jasper-1.0.0-v20070607.jar
-O org.eclipse.equinox.jsp.jasper_1.0.0.v20070607.jar
wget 
http://maven.springframework.org/osgi/org/springframework/osgi/jasper.osgi/5.5.23-SNAPSHOT/jasper.osgi-5.5.23-20080229.204604-1.jar
-O org.springframework.osgi.jasper.osgi_5.5.23.SNAPSHOT.jar
wget 
http://dist.wso2.org/maven2/org/eclipse/equinox/org.eclips

Re: Apache Felix HTTP service HttpServiceImpl.isNameValid does not match OSGi R4.2 spec?

2010-11-09 Thread Misha Koshelev
Hi Felix

Done
https://issues.apache.org/jira/browse/FELIX-2691

Fyi, I have attached another proposed patch here.

Per my other email wrt JSP issues
http://www.mail-archive.com/dev@felix.apache.org/msg19852.html

it looks like we will have to use Equinox HTTP Service :( unless you
have some other suggestions...

However, I hope the bug and proposed patch are helpful. We will gladly
revisit Felix Http Service if some kind of JSP support is feasible
(through Equinox JSP or otherwise).

Thank you
Misha

On Tue, Nov 9, 2010 at 3:13 AM, Felix Meschberger  wrote:
> Hi Misha,
>
> This in fact looks like a bug. Do you mind filing a JIRA issue at
> https://issues.apache.org/jira/browse/FELIX. Thanks alot.
>
> Regards
> Felix
>
> Am Montag, den 08.11.2010, 16:24 -0600 schrieb Misha Koshelev:
>> Dear All:
>>
>> Thank you all for your help and patience with me.
>>
>> I am working on the following OpenMRS ticket:
>> http://tickets.openmrs.org/browse/TRUNK-1596
>>
>> I am trying to use Apache Felix instead of Spring DM Web Extender.
>>
>> I have had some problems with JSP support, and am trying to use the
>> Equinox JSP bundle:
>> http://www.eclipse.org/equinox/server/jsp_support.php
>> with Felix, specifically using the bridge sample in 2.0.4. I have
>> double checked code in trunk.
>>
>> I _am_ successful with Equinox servlet bridge, see:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=329706
>>
>> However, this example:
>> http://prdownloads.sourceforge.net/sse-examples/org.eclipse.equinox.jsp.examples-proj.zip?download
>>
>> contains the following lines in org.eclipse.equinox.jsp.examples.Activator:
>>
>>                               HttpContext commonContext = new
>> BundleEntryHttpContext(context.getBundle(), "/web"); //$NON-NLS-1$
>>                               httpService.registerResources("/jsp-examples", 
>> "/",
>> commonContext); //$NON-NLS-1$ //$NON-NLS-2$
>>
>>                               Servlet adaptedJspServlet = new 
>> ContextPathServletAdaptor(new
>> JspServlet(context.getBundle(), "/web"), "/jsp-examples");
>> //$NON-NLS-1$//$NON-NLS-2$
>>                               
>> httpService.registerServlet("/jsp-examples/*.jsp",
>> adaptedJspServlet, null, commonContext); //$NON-NLS-1$
>>
>> Felix bridge complains:
>>
>> java.lang.IllegalArgumentException: Malformed resource name [/]
>>       at 
>> org.apache.felix.http.base.internal.service.HttpServiceImpl.registerResources(HttpServiceImpl.java:105)
>>       at 
>> org.eclipse.equinox.jsp.examples.Activator$HttpServiceTracker.addingService(Activator.java:38)
>>       at 
>> org.osgi.util.tracker.ServiceTracker$Tracked.trackAdding(ServiceTracker.java:1030)
>>
>> The relevant code, in trunk, is, from
>> http://svn.apache.org/repos/asf/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceImpl.java
>>
>>
>>  public void registerResources(String alias, String name, HttpContext 
>> context)
>>         throws NamespaceException
>>     {
>>         if (!isNameValid(name)) {
>>             throw new IllegalArgumentException( "Malformed resource
>> name [" + name + "]");
>>         }
>> ...
>>
>> and
>>
>>
>> private boolean isNameValid(String name)
>>     {
>>         if (name == null) {
>>             return false;
>>         }
>>
>>         if (name.endsWith( "/" )) {
>>             return false;
>>         }
>>
>>         return true;
>>     }
>>
>> However, the R4.2 enterprise spec from
>> http://www.osgi.org/Download/File?url=/download/r4v42/r4.enterprise.pdf
>> on page 48 clearly states:
>>
>> The name parameter must also not end with slash (’/’) with the
>> exception that a name of the form “/” is used to denote the root of
>> the bundle.
>>
>> Should isNameValid not read, similar to isAliasValid, in the same file:
>>
>>     private boolean isNameValid(String name)
>>     {
>>         if (name == null) {
>>             return false;
>>         }
>>
>>         if (!name.equals("/") && ( !name.startsWith("/") ||
>> name.endsWith("/"))) {
>>             return false;
>>         }
>>
>>         return true;
>>     }
>>
>> ???
>>
>> Thank you
>>
>> Yours
>> Misha
>
>
>
Index: samples/bridge/src/main/webapp/WEB-INF/framework.properties
===
--- samples/bridge/src/main/webapp/WEB-INF/framework.properties	(revision 1033153)
+++ samples/bridge/src/main/webapp/WEB-INF/framework.properties	(working copy)
@@ -159,4 +159,4 @@
  org.xml.sax,\
  org.xml.sax.ext,\
  org.xml.sax.helpers,\
- javax.servlet;javax.servlet.http;version=2.5
+ javax.servlet;javax.servlet.http;javax.servlet.resources;version=2.5


Re: JSP support: works in bridged Equinox HTTP service, _not_ in bridged Felix; _exact_ same bundles

2010-11-12 Thread Misha Koshelev
Hi Karl:

Thank you for your helpful comment.

I seem to have a working Equinox implementation atm, so I'll that be for now :)

However, your statement about the pax bundles piqued my curiosity?

Did you mean that you used:
http://mvnrepository.com/artifact/org.ops4j.pax.web/pax-web-jsp/0.8.0
or something similar inside the Apache Felix _servlet bridge_???

It seems like you were able to get additional features besides a plain
vanilla HTTP Service (at least JSP support), which would be quite
interesting...

I only ask because I know Pax Web itself does not have a servlet
_bridge_ mode per my understanding (or at the very least does not have
a servlet bridge mode that provides advantages over a traditional HTTP
Service):
http://lists.ops4j.org/pipermail/general/2010q4/004794.html

"Hi Misha,

I think your assessment is correct about http services. Pax web won't
bring you any advantages if you want to operate in a bridged mode.
...
-Andreas"

(and penultimate comment here:
http://forum.springsource.org/archive/index.php/t-55655.html)


On Tue, Nov 9, 2010 at 2:12 PM, Karl Pauls  wrote:
> I don't know enough about your set-up (i.e., the bundles you use). I
> had success with the pax bundles at one point of time so you might
> consider using their bundles for jsp. Otherwise, a typical problem in
> this area is that equinox is setting the context classloader for
> bundles by itself while felix doesn't do that. You might want to try
> to set it to the classloader of your bundle. Did you get any error/log
> messages btw?
>
> regards,
>
> Karl
>
> On Tue, Nov 9, 2010 at 2:53 AM, Misha Koshelev  wrote:
>> Dear All:
>>
>> Sorry to bother... I have included detailed instructions here:
>> http://tickets.openmrs.org/browse/TRUNK-1596?focusedCommentId=163216&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_163216
>>
>> but the gist is that using JSP support that exists for Equinox container:
>> http://www.eclipse.org/equinox/server/jsp_support.php
>>
>> I _am_ able to get JSPs to function properly in Equinox servlet
>> bridge, but _not_ in Felix.
>>
>> We (OpenMRS) like Felix as it is, in fact, quite Maven friendly,
>> whereis Equinox does not seem to be :(
>>
>> The only thing that I am doing that may be somewhat non-kosher is the line:
>> sed -i 
>> "s/javax.servlet;javax.servlet.http;version=2.5/javax.servlet;javax.servlet.http;javax.servlet.resources;version=2.5/"
>> WEB-INF/framework.properties
>>
>> As otherwise javax.servlet.resources is not found. This seems to be a
>> bunch of DTD files in javax.servlet, but is not present (from what I
>> can tell) _either_ in my Equinox or Felix setup.
>>
>> Clearly, the pages _are_ being served correctly, and the _only_ quirk
>> is that JSP expression fail to be evaluated at all in Felix but _not_
>> in Equinox.
>>
>> Additionally, taglibs are not loaded at all.
>>
>> My WEB-INF/bundles folder:
>>
>> WEB-INF/bundles/org.eclipse.equinox.http.helper-1.0.0.jar
>> WEB-INF/bundles/org.eclipse.equinox.jsp.examples_1.0.0.jar
>> WEB-INF/bundles/org.apache.felix.http.samples.filter.jar
>> WEB-INF/bundles/com.springsource.javax.el-1.0.0.jar
>> WEB-INF/bundles/com.springsource.org.apache.taglibs.standard-1.1.2.jar
>> WEB-INF/bundles/org.eclipse.equinox.jsp.jasper_1.0.0.v20070607.jar
>> WEB-INF/bundles/org.springframework.osgi.jasper.osgi_5.5.23.SNAPSHOT.jar
>> WEB-INF/bundles/com.springsource.javax.servlet.jsp.jstl-1.1.2.jar
>> WEB-INF/bundles/com.springsource.org.apache.commons.el-1.0.0.jar
>> WEB-INF/bundles/org.apache.felix.webconsole.jar
>> WEB-INF/bundles/org.apache.felix.http.bridge.jar
>> WEB-INF/bundles/com.springsource.javax.servlet.jsp-2.1.0.jar
>> WEB-INF/bundles/com.springsource.org.apache.commons.logging-1.0.4.jar
>>
>> otherwise, besides changing framework.properties and the bundle
>> additions, completely unmodified from default 2.0.4 bridge example.
>>
>> Any thoughts?
>>
>> Thank you
>> Misha
>>
>> p.s. I have not investigated, but I could not quickly find a way to
>> use the embedded "web console" feature, and see the errors below. I
>> doubt this would be helpful (all packages are clearly resolved and
>> installed as the JSP example package works - at least to my
>> understanding), but it would be nice to have _proof_ of this:
>> [INFO] Started bridged http service
>> 2010-11-08 19:27:39.847:WARN:felix-bridge:OSGi framework startednull
>> *INFO * Failed to instantiate plugin
>> org.apache.felix.webconsole.internal.compendium.ComponentsServlet.
>> Reason: java.lang.NoClassDef

[jira] Created: (FELIX-2691) Apache Felix HTTP service HttpServiceImpl.isNameValid does not match OSGi R4.2 spec?

2010-11-09 Thread Misha Koshelev (JIRA)
Apache Felix HTTP service HttpServiceImpl.isNameValid does not match OSGi R4.2 
spec?


 Key: FELIX-2691
 URL: https://issues.apache.org/jira/browse/FELIX-2691
 Project: Felix
  Issue Type: Bug
  Components: HTTP Service
Affects Versions: http-2.0.4
 Environment: Not relevant
Reporter: Misha Koshelev


Filing bug per:
http://www.mail-archive.com/dev@felix.apache.org/msg19853.html

The R4.2 enterprise spec from
http://www.osgi.org/Download/File?url=/download/r4v42/r4.enterprise.pdf
on page 48 clearly states:

The name parameter must also not end with slash ('/') with the
exception that a name of the form "/" is used to denote the root of
the bundle.


The relevant code, in trunk, is, from
http://svn.apache.org/repos/asf/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceImpl.java


 public void registerResources(String alias, String name, HttpContext context)
throws NamespaceException
{
if (!isNameValid(name)) {
throw new IllegalArgumentException( "Malformed resource
name [" + name + "]");
}
...

and


private boolean isNameValid(String name)
{
if (name == null) {
return false;
}

if (name.endsWith( "/" )) {
return false;
}

return true;
}




-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Updated: (FELIX-2691) Apache Felix HTTP service HttpServiceImpl.isNameValid does not match OSGi R4.2 spec?

2010-11-09 Thread Misha Koshelev (JIRA)

 [ 
https://issues.apache.org/jira/browse/FELIX-2691?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Misha Koshelev updated FELIX-2691:
--

Attachment: FELIX-2691-HttpServiceImpl-isNameValid-comply-OSGI-R42.patch

Here is relevant text from spec:

102.10.3.2
org.osgi.service.http
public void registerResources( String alias, String name, HttpContext context ) 
throws
NamespaceException
alias name in the URI namespace at which the resources are registered
name the base name of the resources that will be registered
context the HttpContext object for the registered resources, or null if a 
default HttpContext is to be created and
used.
Registers resources into the URI namespace.
The alias is the name in the URI namespace of the Http Service at which the 
registration will be
mapped. An alias must begin with slash ('/') and must not end with slash ('/'), 
with the exception that
an alias of the form "/" is used to denote the root alias. The name parameter 
must also not end with
slash ('/') with the exception that a name of the form "/" is used to denote 
the root of the bundle. See
the specification text for details on how HTTP requests are mapped to servlet 
and resource registra-
tions.


> Apache Felix HTTP service HttpServiceImpl.isNameValid does not match OSGi 
> R4.2 spec?
> 
>
> Key: FELIX-2691
> URL: https://issues.apache.org/jira/browse/FELIX-2691
> Project: Felix
>  Issue Type: Bug
>  Components: HTTP Service
>Affects Versions: http-2.0.4
> Environment: Not relevant
>Reporter: Misha Koshelev
> Attachments: 
> FELIX-2691-HttpServiceImpl-isNameValid-comply-OSGI-R42.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> Filing bug per:
> http://www.mail-archive.com/dev@felix.apache.org/msg19853.html
> The R4.2 enterprise spec from
> http://www.osgi.org/Download/File?url=/download/r4v42/r4.enterprise.pdf
> on page 48 clearly states:
> The name parameter must also not end with slash ('/') with the
> exception that a name of the form "/" is used to denote the root of
> the bundle.
> The relevant code, in trunk, is, from
> http://svn.apache.org/repos/asf/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceImpl.java
>  public void registerResources(String alias, String name, HttpContext context)
> throws NamespaceException
> {
> if (!isNameValid(name)) {
> throw new IllegalArgumentException( "Malformed resource
> name [" + name + "]");
> }
> ...
> and
> private boolean isNameValid(String name)
> {
> if (name == null) {
> return false;
> }
> if (name.endsWith( "/" )) {
> return false;
> }
> return true;
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.