Hi,
Based on the discussion we had on telconf yesterday, I want to briefly
explain the problem with the static resources property. Two properties
"web.alias" and "web.static.url" are configurable through felix console.
According to the current implementation Static root url must begin with
a "/". All ftl files invokes "it.staticRootUrl" which calls the
"getStaticRootUrl()" function of BaseStanbolResource. This function
returns directly the "web.static.url" property (e.g. "/static"). When
the browser sees a link starting with a "/", it searches it under the
root context. So, if you deploy the war file under "/stanbol", the
static resources are actually deployed under "/stanbol/static/" but the
browser looks under "/static".
We tried to correct it by appending the full context path in front of
the "web.static.url" in the "getStaticRootUrl()" function. This worked
fine when the "web.alias" is "/". Fabian noticed that using a different
"web.alias" breaks down the execution because in this case the browser
looks under "/stanbol/static" for the static resources (because of our
appending base uri in front of static root url), but these static
resources are still deployed under "/static".
In the end, to solve this problem we chose to append the "web.alias" in
front of the static rool url where the static resources are registered
(in JerseyEndPoint). IMO static resources should have already been
deployed considering "web.alias". Then, my previous commit would be
working fine. As another option, we could remove the leading "/"
character while returning from "getStaticRootUrl()", however this time
subpages (e.g. /entityhub/entity) cannot access to static resources
because browser looks under "/entityhub/static" for static resources.
So, IMO returning full URIs of static resources in "getStaticRootUrl()"
would work for each case. It also wouldn't require configuration of
another property. I will update the code accordingly, if there is no
objection.
Best,
Suat
On 10/19/2011 03:39 PM, Rupert Westenthaler wrote:
Hi
Maybe there is already some Environment parameter that provides the WAR_ALIAS.
In general I think that the "ALIAS_PROPERTY" should be ignored if Stanbol is
deployed as WAR file, because the naming of the WAR file already provides the
functionality intended by this property.
best
Rupert
On 19.10.2011, at 13:19, Fabian Christ wrote:
Hi,
what about adding a new configuration property like WAR_ALIAS or
DEPLOY_ALIAS that is empty by default. This property can be concatenated at
the beginning of the resource path in BaseStanbolResource. In a WAR
environment this variable needs to be configured to be the WAR name where
Stanbol is deployed.
Any other ideas?
Best,
- Fabian
Am Mittwoch, 19. Oktober 2011 schrieb Suat Gonul :
Hi,
I have a problem with the location of deployed static resources. I am
trying the deploy the WAR file, generated after building the full-war
launcher, on the Tomcat6. With default configurations of JerseyEndpoint
static (ALIAS_PROPERTY=/, STATIC_RESOURCES_URL_ROOT_**PROPERTY=/static)
and having 'stanbol' as war name, static resources are deployed under
http://localhost:8080/stanbol/ e.g http://localhost:8080/stanbol/**
static/home/style/stanbol.css<http://localhost:8080/stanbol/static/home/style/stanbol.css>.
But in this case, this resource is searched under
http://localhost:8080/static/**home/style/stanbol.css<http://localhost:8080/static/home/style/stanbol.css>as
its href is /static/home/style/stanbol.
**css.
When I update JerseyEndpoint configuration such that ALIAS_PROPERTY=/ and
STATIC_RESOURCES_URL_ROOT_**PROPERTY=/stanbol/static, this time the
resource is deployed under http://localhost:8080/stanbol/**
stanbol/static/home/style/**stanbol.css<http://localhost:8080/stanbol/stanbol/static/home/style/stanbol.css>but
it is searched under
http://localhost:8080/stanbol/**static/home/style/stanbol.css<http://localhost:8080/stanbol/static/home/style/stanbol.css>
.
As far as I understand, there won't be any problem if hrefs of static
resources wouldn't start with a /. However, aliases should be started with a
/ when registering resources to http service.
Therefore, the only solution we produced is to attach ALIAS_PROPERTY at the
beginning of the resource aliases while registering and returning full URL
of static resources in the BaseStanbolResource as previously done.
Do you have any other suggestion to solve this problem in a better way?
Thanks in advance,
Suat
On 10/18/2011 04:03 PM, Fabian Christ wrote:
Hi,
I would like to vote -1 for this commit because this change seems to be
the
wrong solution and it breaks Stanbol instances which run on another alias
for static resources.
The addressed problem is that the method getStaticRootURL returns by
default
a wrong value when Stanbol is deployed in a WAR context. But changing the
return value by adding the base URI string at the beginning is not
correct.
The alias and static root resource alias (STATIC_RESOURCES_ROOT_URL) of
Stanbol should be configured correctly when running in a WAR context. Then
this problem would not occur.
I'm not sure about the procedure now. I think as soon as a committer votes
-1 for a commit the commit has to be reverted in first place. Should I do
that?
Best,
- Fabian
Am Montag, 17. Oktober 2011 schrieb :
Author: suat
Date: Mon Oct 17 11:17:26 2011
New Revision: 1185105
URL:
http://svn.apache.org/viewvc?**rev=1185105&view=rev<http://svn.apache.org/viewvc?rev=1185105&view=rev>
Log:
STANBOL-348:
-Updated getStaticRootURL so that it returns the full URL of static
resources. This change is done as static resources are deployed under the
context of war file (e.g under
http://localhost:8080/stanbol/**static/home/style/stanbol.css<http://localhost:8080/stanbol/static/home/style/stanbol.css>instead
of
http://localhost:8090/static/**home/style/stanbol.css<http://localhost:8090/static/home/style/stanbol.css>
).
Modified:
incubator/stanbol/trunk/**commons/web/base/src/main/**
java/org/apache/stanbol/**commons/web/base/resource/**
BaseStanbolResource.java
Modified:
incubator/stanbol/trunk/**commons/web/base/src/main/**
java/org/apache/stanbol/**commons/web/base/resource/**
BaseStanbolResource.java
URL:
http://svn.apache.org/viewvc/**incubator/stanbol/trunk/**
commons/web/base/src/main/**java/org/apache/stanbol/**
commons/web/base/resource/**BaseStanbolResource.java?rev=**
1185105&r1=1185104&r2=1185105&**view=diff<http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/resource/BaseStanbolResource.java?rev=1185105&r1=1185104&r2=1185105&view=diff>
==============================**==============================**
==================
---
incubator/stanbol/trunk/**commons/web/base/src/main/**
java/org/apache/stanbol/**commons/web/base/resource/**
BaseStanbolResource.java
(original)
+++
incubator/stanbol/trunk/**commons/web/base/src/main/**
java/org/apache/stanbol/**commons/web/base/resource/**
BaseStanbolResource.java
Mon Oct 17 11:17:26 2011
@@ -111,7 +111,8 @@ public class BaseStanbolResource {
}
public String getStaticRootUrl() {
- return (String)
servletContext.getAttribute(**STATIC_RESOURCES_ROOT_URL);
+ String baseURIStr = uriInfo.getBaseUri().toString(**);
+ return baseURIStr.substring(0, baseURIStr.length()-1) + (String)
servletContext.getAttribute(**STATIC_RESOURCES_ROOT_URL);
}
@SuppressWarnings("unchecked")
--
Fabian
http://twitter.com/fctwitt