Skip to main content

OSGi: Static resources not found after some days

8 replies [Last post]
jkraushaar
Offline
Joined: 2013-01-07

Hi,

I'm deploying an OSGi Web Application Bundle on GlassFish 3.1.2. The application works fine. After some days (in one case about 12 days, in another case sometime between 7 and 24 days) the web.xml can no longer be found (although it is still there). Other static resources in the WEB-INF directory are also concerned. Java classes can still be found. When I'm trying to load a static resource via the getResource() method of javax.servlet.ServletContext null is returned.

GlassFish server.log file shows no error or warning messages.

Has anyone an idea why this happens?

Jochen

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jkraushaar
Offline
Joined: 2013-01-07

Hi,

it seems that this is a configuration problem. GlassFish explodes some bundles to /tmp/osgiapp directories. Our system runs a tmpwatch cronjob, which deletes files after some days. Unfortunately also the WEB-INF directory is deleted, which leads to the described problems.

Currently I am testing two fixes:

1. Exclude /tmp/osgiapp directories from tmpwatch
2. Specify a different default temporary directory by setting java.io.tmpdir

Jochen

ss141213
Offline
Joined: 2005-03-30

Coincidentally someone contacted me directly a couple of weeks ago about
ability to reconfigure exploded dir location somewhere outside
java.io.tmpdir? They have the exact same problem with tmpdir being
regularly getting cleaned up by a cron job. May be someone from your
organisation only?

Thanks,
Sahoo
On Monday 21 January 2013 07:18 PM, forums@java.net wrote:
> Hi, it seems that this is a configuration problem. GlassFish explodes
> some
> bundles to /tmp/osgiapp directories. Our system runs a tmpwatch cronjob,
> which deletes files after some days. Unfortunately also the WEB-INF
> directory
> is deleted, which leads to the described problems. Currently I am
> testing two
> fixes: 1. Exclude /tmp/osgiapp directories from tmpwatch 2. Specify a
> different default temporary directory by setting java.io.tmpdir Jochen
>
> --
>
> [Message sent by forum member 'jkraushaar']
>
> View Post: http://forums.java.net/node/893652
>
>

jkraushaar
Offline
Joined: 2013-01-07

As far as I know, my team is the first one in our company to use OSGi together with GlassFish. So I don't think this request comes from our company. But on Linux systems (at least RHEL?) cronjobs cleaning the temporary directory are quite common. Someone using OSGi/GlassFish on such a system will hit on this someday.

Jochen

Oliver Fischer

Would be nice to configure this directory location. Could you raise an
JIRA isse for that to track it?

Oliver

On 22.01.2013 09:00, forums@java.net wrote:
> As far as I know, my team is the first one in our company to use OSGi
> together with GlassFish. So I don't think this request comes from our
> company. But on Linux systems (at least RHEL?) cronjobs cleaning the
> temporary directory are quite common. Someone using OSGi/GlassFish on
> such a
> system will hit on this someday. Jochen
>
> --
>
> [Message sent by forum member 'jkraushaar']
>
> View Post: http://forums.java.net/node/893652
>
>

jkraushaar
Offline
Joined: 2013-01-07
ss141213
Offline
Joined: 2005-03-30

ServletContext.getResource() method is never supposed to return you resources located directly under WEB-INF directory. That method is supposed to return the mapped resource for the given request path, so I am not surprised when it returns null for WEB-INF/web.xml. There is a ServletContext.getClassLoader() method which returns a classloader for the webapp which can return you resources from the classpath of the web app.

Sahoo

jkraushaar
Offline
Joined: 2013-01-07

Thanks for you reply, Sahoo.

My description was unclear. I don't want to fetch the web.xml but another static resource. I will try to move this static resource to another directory (unfortunately the ServletContext.getResource() call is part of a third-party framework, so I cannot influence it directly).

Do you have an idea why the call works for some time after restart of the server / redeployment and then no longer?

Jochen

ss141213
Offline
Joined: 2005-03-30

I would like to believe that if ServletContext.getResource returns a resource from WEB-INF/, then it's a bug. If you can file a bug with a test case, that will be great. In fact, in case of a WAB, ServletContext.getResource must not even return resources under OSGI-INF and OSGI-OPT dirs. We have specific tests in OSGi/Web Compliance Test Suite to test this.

Sahoo