The Source for Java Technology Collaboration

Home » java.net Forums » GlassFish » GlassFish

Thread: EAR Redeploy fails: Cannot delete existing directory

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 12 - Last Post: Dec 14, 2006 1:59 PM by: bouteill
bouteill

Posts: 97
EAR Redeploy fails: Cannot delete existing directory
Posted: Jul 3, 2006 4:23 PM
  Click to reply to this thread Reply

Hello,
I recently installed SJSAS 9.0 PE and I'm having problems redeploying my EAR application:

undeploy --interactive=true --secure=false --passwordfile /home/cyril/p4/braveheart/main/deploy/dev/sjsas/admin-password --terse=false --user admin --target server --host localhost --echo=true --cascade=false --port 4848 BraveheartApp
Command undeploy executed successfully.
deploy --secure=false --user admin --terse=false --target server --echo=true --upload=true --port 4848 --interactive=true --passwordfile /home/cyril/p4/braveheart/main/deploy/dev/sjsas/admin-password --availabilityenabled=false --enabled=true --generatermistubs=false --host localhost --precompilejsp=false --force=true --verify=true --name BraveheartApp dist/braveheart.ear
CLI171 Command deploy failed : Deploying application in domain failed; Cannot delete existing directory /p4/braveheart/main/deploy/dev/sjsas/applications/j2ee-apps/BraveheartApp, possibly due to one or more open files or streams; these may interfere with later deployment attempts so you may need to manually delete this directory and/or restart the server to release the open files

If I delete this directly manually, then it complains about .../generated/jsp/j2ee-apps/BraveheartApp.
If I delete the domain's generated directory manually as well, then I get this error:

deploy --secure=false --user admin --terse=false --target server --echo=true --upload=true --port 4848 --interactive=true --passwordfile /home/cyril/p4/braveheart/main/deploy/dev/sjsas/admin-password --availabilityenabled=false --enabled=true --generatermistubs=false --host localhost --precompilejsp=false --force=true --verify=true --name BraveheartApp dist/braveheart.ear
CLI171 Command deploy failed : Deployment of application failed - null

So this fails without error message and then the admin UI stops responding with Access Denied:
HTTP 403 error. Access to the Administrative UI has been denied.
Your user permissions do not allow you to view or edit data in this area. If you need access, contact the system administrator. Otherwise close the browser, open it again and try logging in with a different user id/password.

Same thing happen if I drive the undeploy/deploy from Admin UI.
Any idea?

ss141213

Posts: 499
Re: EAR Redeploy fails: Cannot delete existing directory
Posted: Jul 3, 2006 5:04 PM   in response to: bouteill
  Click to reply to this thread Reply

Are you using JSF? Check if your bug is similar to what is reported at https://glassfish.dev.java.net/issues/show_bug.cgi?id=354

Sahoo

bouteill

Posts: 97
Re: EAR Redeploy fails: Cannot delete existing directory
Posted: Jul 3, 2006 5:06 PM   in response to: ss141213
  Click to reply to this thread Reply

No JSF. It's a plain vanilla EAR with a simple web app and an index.jsp. Nothing fancy there.

tjquinn

Posts: 618
Re: EAR Redeploy fails: Cannot delete existing directory
Posted: Jul 10, 2006 5:42 AM   in response to: bouteill
  Click to reply to this thread Reply

Hi.

There are a few reasons why this type of file locking may occur on Windows: GlassFish itself may open but not close a JAR file, the application may cause a JAR to be opened, or a third-party library may use its own class loader to get a resource. There is behavior in java.net.URLClassLoader that can trigger this sort of locking.

The first step is to find out what code is actually opening the JAR file. Shortly I hope to describe a technique that helps with this part.

Or, before that, if you are willing to share your application with me I can try to reproduce the problem on a system here and find out which code is opening the JAR file. If this works for you, feel free to send me e-mail either attaching the application EAR file or pointing me to a link from which I can retrive it.

- Tim

bouteill

Posts: 97
Re: EAR Redeploy fails: Cannot delete existing directory
Posted: Jul 10, 2006 9:14 AM   in response to: tjquinn
  Click to reply to this thread Reply

Hello Tim,
I emailed you my ear file but it's really pretty small/new/vanilla stuff and I don't have any JAR/URL code in there. Are you looking for code opening a JAR file in the app server or the deployed app?
Also, FYI, I'm running Linux.
Let me know what you find!
Thanks,

tjquinn

Posts: 618
Re: EAR Redeploy fails: Cannot delete existing directory
Posted: Jul 10, 2006 9:46 AM   in response to: bouteill
  Click to reply to this thread Reply

I'll look for the e-mail with the app.

Thanks for pointing out that the problem is on Linux. That means this is a different sort of issue.

Once I get your app and have a chance to try it I'll post here what I've found.

- Tim

bouteill

Posts: 97
Re: EAR Redeploy fails: Cannot delete existing directory
Posted: Jul 26, 2006 10:43 AM   in response to: tjquinn
  Click to reply to this thread Reply

Hi Tim, did you get a chance to investigate my redeployment problem on linux?

hzhang_jn

Posts: 147
Re: EAR Redeploy fails: Cannot delete existing directory
Posted: Jul 27, 2006 6:23 AM   in response to: bouteill
  Click to reply to this thread Reply

Hi,
Tim is on vacation this week. He will inform you about status next week.

bouteill

Posts: 97
Re: EAR Redeploy fails: Cannot delete existing directory
Posted: Sep 28, 2006 3:13 PM   in response to: bouteill
  Click to reply to this thread Reply

For everyone's benefit:
After debugging this with Sun support we found the problem to be a unix soft link defined upstream of glassfish install.
Apparently Glassfish undeploy logic is having reservations about deleting linked paths, so it just doesn't do it.
The fix is to edit glassfish-home/config/asenv.conf to hardcode absolute/unlinked paths only.
No shell variables allowed.
No known work-around...

tjquinn

Posts: 618
Re: EAR Redeploy fails: Cannot delete existing directory
Posted: Sep 28, 2006 5:19 PM   in response to: bouteill
  Click to reply to this thread Reply

Thanks to Cyril for posting the update and for his patience in chasing this down.

To give an example of what Cyril referred to...

Suppose a real directory exists at /home/tim/here. Create a link /here that points to /home/tim/here. Install the app server and use /here/myplace as the installation directory.

The installation will succeed. Deployment will succeed. Attempts at redeploying or undeploying will fail for a well-intentioned reason that's been implemented in an overly-cautious way, which we're taking steps to address.

Basically, during undeployment or redeployment, GlassFish cleans up some directories it created during deployment. A user could conceivably create a link within the directory GlassFish created to a separate area. To guard against deleting files in that other area, GlassFish refuses to remove files for which the absolute path and the canonical path do not match, and they do not for files that are accessed via links. A more likely scenario is if the user creates a link under the domain.

This logic works fine for that situation. When the link is "upstream" from where GlassFish was installed, on the other hand, the logic is overprotective. While there would be no harm in removing the files GF wants to remove, it does not do so because - as before - the absolute and canonical paths are different.

We are working on enhancing the file deletion logic to do the right thing, regardless of where the link may be - or even in the case where there is both an upstream and a downstream link.

In the meantime, we do not recommend hand-editing asenv.conf. You can avoid the problem by not installing into a path that includes a link. The same comment applies for creating a domain and specifying the domain directory...don't use a directory with an upstream link.

- Tim

bouteill

Posts: 97
Re: EAR Redeploy fails: Cannot delete existing directory
Posted: Sep 29, 2006 8:46 AM   in response to: tjquinn
  Click to reply to this thread Reply

One thing I'm still not clear on though, and which I'd like to get someone's opinion about is: how does the linked path to AS_HOME affect the path to my domain/applications directory which is in a totally different branch?
My domain/bin/startenv script passes -Dcom.sun.aas.instanceRoot="$INSTANCE_ROOT" to glassfish VM resolving as an absoluted unlinked path. I've not been able to get an answer from Sun, and I'm at loss what asenv.conf:AS_HOME has to do with this...
any idea?

tjquinn

Posts: 618
Re: EAR Redeploy fails: Cannot delete existing directory
Posted: Oct 12, 2006 8:30 AM   in response to: bouteill
  Click to reply to this thread Reply

I'm late in noting that this problem has been fixed as of build 21.

- Tim

bouteill

Posts: 97
Re: EAR Redeploy fails: Cannot delete existing directory
Posted: Dec 14, 2006 1:59 PM   in response to: tjquinn
  Click to reply to this thread Reply

b21 is for v2, not production-supported v1.
For google points and Karma for the next person running into this issue, I did end up getting a patch from Sun for v1:
BUG ID : 6475894
PRODUCT : SJAS 9.0_01




 XML java.net RSS