facebook

Web Application – Redeployment [Closed]

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #202459 Reply

    Yagiz Erkan
    Member

    Hi,

    I created a simple Web application with two JSPs and a servlet. I deploy them on Tomcat 5 (Exploded Archive). At first, I deployed the JSPs. Then I created a servlet and I deployed it as well. I could see Tomcat’s “INFO: restartContext” message in the console. Now when I make changes to the servlet or JSPs and when I use “Deploy J2EE project to Server…” it doesn’t redeploy, basically nothing happens…

    Does anyone have an idea why? Do I have to restart Tomcat when I make a change?

    Thanks, 😉

    My system:

    Windows 2000
    Eclipse 2.1.2
    MyEclipse 2.7 RC2
    Tomcat 5.0.16

    #202461 Reply

    Riyad Kalla
    Member

    Hmm no you shouldn’t need to restart each time. When you do make changes to any of the resources and reopen the deploy dialog, do you see the little mark next to the project indicating that there is infact a change? If you don’t, and you just see your project listed normally in the deployments list with no icon next to it, then I’d say for some reason its not picking up your changes. In which case open up: Window->Preferences->Workbench and make sure “Build resources on save” or however that 1st checkbox is worded, and try again. Did that help? Sometimes this gets turned off, we aren’t quite sure yet why but we think its tied into the shifts in the moon’s phase 🙂

    #202468 Reply

    Yagiz Erkan
    Member

    Hi Riyad,

    > do you see the little mark next to the project
    > indicating that there is infact a change?

    Only when the project deployment type is set to “Packaged Archive”.

    > In which case open up: Window->Preferences->Workbench
    > and make sure “Build resources on save” or however that
    > 1st checkbox is worded, and try again. Did that help?

    That option was active anyway. But to gave it a try, I disabled it and enabled it again. It didn’t change anything.

    I thought I found a workaround. It worked when the project’s deployed type was “Packaged Archive”. What I did was to remove the “Exploded Archive” deployment and to create a new “Packaged Archive” one and it worked perfectly. Only the first time though! The second time when I made a change, it didn’t redeploy (the popup appeared and disappeared immediately). The change icon was still there. And at this stage the project is impossible to redeploy because the “Redeploy” button is disabled (grayed out). I cannot even remove the deployment line because it gives an error asking me to do it manually. I stopped Tomcat. I checked the “webapps” directory and my web application exists as a WAR file and as a directory. I deleted them manually and I restarted Tomcat. At this stage my project didn’t exist because I just deleted it. In the deployment dialog the “Redeploy” is still grayed. I still can’t remove the deployment line (it gives the same error). When I try to add a new line of deployment the only server I can see is “JBoss 3”, “Tomcat 5” doesn’t appear there anymore. I have to restart Eclipse to be able to continue to work…

    I hope the description is detailed enough…

    I created some screen captures hoping that they help you to diagnose the problem:

    “Project Deployments” dialog – “Redeploy” button disabled:
    http://www.geocities.com/yagiz_erkan/images/MyEclipse/MyEclipse-RedeployGrayed.jpg

    Cannot remove the deployment line – error:
    http://www.geocities.com/yagiz_erkan/images/MyEclipse/MyEclipse-UndeployError.jpg

    Cannot create a new deployment – “Tomcat 5” disappeared from the “Server” list:
    http://www.geocities.com/yagiz_erkan/images/MyEclipse/MyEclipse-NewDeployment.jpg

    Thanks,

    #202469 Reply

    Riyad Kalla
    Member

    Are you trying to deploy a simple webapp (JSP/Servlet/Struts) or an EJB project? Also when your deployments get out of sync with the filesystem (like when you manually removed the file/directory) you need to restart Eclipse before you can continue using the deployment tool.

    Now as far as not being able to redeploy to Tomcat, that is indeed strange. I just tried your same steps here locally (Eclipse 2.1.2 GTK/ME 2.7RC2) and can’t reproduce that behavior. I’ll fire this off to Scott to see if he can help us out.

    #202471 Reply

    Yagiz Erkan
    Member

    It is a simple web app, with a JSP, an error JSP and a Hello World servlet…

    #202481 Reply

    Scott Anderson
    Participant

    Yagiz,

    To determine the problem I’m going to need to you provide all the information we ask for in the Posting Guidelines thread at the top of this forum, particularly the Eclipse log information. Once we have that, we should know how to get started.

    #202632 Reply

    Yagiz Erkan
    Member

    Hi Scott,

    Here is the requested information. I hope you’ll be able to help me and I hope it’s just my mistake :wink:. If the evaluation goes OK, we may buy around 20 seats…

    Thanks,

    What operating system and version are you running?
    Windows 2000

    What Eclipse version and build id are you using? (Help > About Eclipse Platform)
    Version: 2.1.2
    Build id: 200311030802

    – Was Eclipse freshly installed for MyEclipse?
    Yes

    – Are any other external plugins installed?
    No. I installed it to be able to evaluate MyEclipse. I have Eclipse 3.0 M6 installed on my machine as well.

    – How many plugins in the <eclipse>/plugins directory are like org.eclipse.pde.*
    org.eclipse.pde.build_2.1.0
    org.eclipse.pde.core_2.1.2
    org.eclipse.pde.doc.user_2.1.0
    org.eclipse.pde.runtime_2.1.0
    org.eclipse.pde.source_2.1.2
    org.eclipse.pde.ui_2.1.2
    org.eclipse.pde_2.1.0

    What MyEclipse version are you using? (Help > About Eclipse Platform > Features)
    2.6.200

    What JDK version are you using to run Eclipse? (java -version)
    1.4.2

    What JDK version are you using to launch your application server?
    1.4.2

    What steps did you take that resulted in the issue?
    I tried a lot of combinations. Reinstalling, using different deployment types, different changes in the servlet and JSP, adding new JSPs, recompiling the JSPs, etc.

    What application server are you using?
    Tomcat 5.0.16

    Are there any errors in the Eclipse log? (<workspace>/.metadata/.log)
    No. I cleared the log file before operating. The log file is empty.

    #202633 Reply

    Riyad Kalla
    Member

    yagiz,
    We have another person report on the forums that Tomcat was locking some of his JARs that are deployed as part of his app. The solution was for him to deploy a packaged WAR file so the container wouldn’t keep locking the resources and stopping the deployment tool from redeploying. However I saw your comment that you tried this, and after deploying the packaged WAR file, were no longer able to deploy which was odd because AFAIK Tomcat doesn’t lock the JAR except while it is expanding it.

    This is a long shot, but can you upgrade to Tomcat 5.0.18 and see if the problem goes away or improves? What are the settings on your app’s context? (reloadable, etc.). I wonder if too strict of settings will cause Tomcat to lock the project.

    #202634 Reply

    Yagiz Erkan
    Member

    Riyad,

    Thanks for the prompt answer. Unfortunately “reloadable” didn’t help either. I’ll try with Tomcat 5.0.18 and I’ll see…

    In the meantime I have more information:
    I tried to replace the modified Servlet class manually. And Tomcat picks it up correctly when I update the .class file with a new one in the expanded directory structure.
    I tried to modify the WAR file manually and replace it. And it worked again. Tomcat reloaded it successfully.

    However, with MyEclipse, it works only once. After that, the WAR file seems to be locked by MyEclipse (I cannot rename it for example). I don’t know if that’s the correct behavior but I don’t think so. Because that’s probably the reason why it works only once. The second time it’s trying to modify the file that it is blocking. It doesn’t even let me remove the deployment using the “Remove” button. Even at that stage, I can go back and update the WAR file’s content manually and it works. But not with MyEclipse.

    I hope this little piece of information will help…

    Thanks,

    #202635 Reply

    Riyad Kalla
    Member

    Yagiz yes it does help, thank you for being so detailed in your testing.

    When you click the redeploy button and nothing happens, have you tried checking the .log file at exactly the same time to see if anything is spit out to it? I like to keep the log file open with TextPad (or other good editor that will notice changes on disk) and then perform my action and see what is new in the file.

    Also keep us posted on the Tomcat 5.0.18 upgrade and if that fixes anything.

    Do you have a virus scanner running? I wonder if this would inadvertantly lock the files on read to scan then like when Eclipse tries to remove the directory….

    #202889 Reply

    Yagiz Erkan
    Member

    > Do you have a virus scanner running?

    Spot on!!! I think that was it because I installed a new version of the virus scanner and the problem doesn’t happen anymore… I’ll let you know if something else comes up…

    Thanks a lot for your help!

    _________________
    Yagiz

    #203340 Reply

    ❓ I am also seeing this problem with Tomcat 5 and exploded archive. However, if I run the Tomcat admin and look at the context after deployment, reloadable is set to false. After I set it to true, it seems to handle the deployment appropriately and changes to classes are deployed automatically. After I stop and restart the server, the property seems to stick.

    Is there some way to enable the property to be set to be true when the relationship is established between tomcat and ME — maybe through the preferences?

    #203342 Reply

    Riyad Kalla
    Member

    yagiz: hey that’s great! I’m sorry I missed your reply, not sure what happened.

    GSX: The initial defaults for new webapps is actually up to Tomcat to decide. So weather you are using ME or dropping a war manually into your tomcat dir, it will use its own defaults to unpack the webapp into.

    with that said, I can’t say I know where to set defaults for new apps in Tomcat. As far as ME changing it, that would required it to parse/change/write back out the server.xml (4.1) and <webapp>.xml (5.0) file which I don’t think is on the todo list only because most people will add a context, config it and then develop with that same context for weeks (months). I don’t think the need to create a new web context is frequent enough for people to really notice the lack of any extra functionality in this area.

    BUT, something I found works well is after I set my contex to reloadable; on Windows if you keep deploying as a WAR it will work best. But due to how Windows FS handles file locks, if you deploy as a exploded app, inevitably you will have Tomcat set as a reader to some of those files and Windows won’t allow you to delete that dir. You don’t notice this on Linux/Unix (Mac?) only because the file system allows for deferred actions so a delete will never fail, it will just get queued until all readers let go of the file.

    #203347 Reply

    Thanks for the quick feedback. Maybe if I can understand more of the internal workings …

    As it stands right now, each time I restart TomCat 5 from ME the redeploy property is set to false ( I checked the status through the tomcat admin). And as such, when I make a change to a java file and save it down, the source and “local” class are updated, but there is no affect on the working application. However, if I change the redeploy to true (using the tomcat admin), then all of this works like magic and changes in source code are reflected in the application quickly.

    I understand that I could bring up the admin and make this change each time that I start TomCat using ME, but that is silly and inconsistent with the rest of the product (from what I have seen). It sounds like I need to update the context for my application in Tomcat to ensure that reload=true. I thought that I would see something in the server.xml file about my application (as is done in other plugins), but all I see in there is information about my datasources – but nothing about my application.

    However, I was able to get the anticipated redeployment behavior by adding a line to the server.xml under the <engine defaultHost> element. If I understand the documents, this sets the default context for all web application on that host>. The line of code that I added is:

    <DefaultContext reloadable=”true”/>

    So the server.xml looks something like:

    
        ...
          <Engine defaultHost="localhost" name="Catalina">
                <DefaultContext reloadable="true"/>
                ...
           </Engine>
    

    Since I am just using Tomcat as a development server and have full control on the applications, there is no problem for me to set all applications to reload by default. Now, when I change a method and save it down, the class is auto-magically copied to TomCat whcih reloads the application. All is well with the world once again! 😀

    ❓ What I don’t understand is how, outside of making this global change to TomCat or making a <Context> for each web application, the automatic redeployment could have ever worked (where redeployment does not mean the redeployment button, but rather the ability to change a code and have the changed class be reflected in the running web application. If there is another way, please let me know so that I can use this feature correctly. Otherwise, this might be something to add to the FAQ or other documents (or if it is in there, please let me know the pointer because I didn’t see it).

    Thanks,
    James

    #203348 Reply

    Riyad Kalla
    Member

    James,
    Wow thanks for posting back with that solution, I think that’s a great bit of information!

    I’m sorry I don’t think I understood you before; I agree 100% that if you had to set the app to “Reloadable:true” every time you started Tomcat, I’d kill myself as well. I know that if you drop a war in, the app is deployed automatically and a non-persistent context is created for it. But in my experience (I don’t know the actual impl of this) when I’ve then loaded up Admin, and gone into that context and changed its stats (for example to turn on Naming, or Reloadable) then hit “Save” and “Commit Changes”, the context was permanent (atleast it seemed to be) after that for me. So between startups of Tomcat my settings stuck for that webapp.

    But as far as the default, out-of-the-box-hot-deploy from ME here is how I’ve seen it work:

    1) Exploded format: auto hotdeploy changes, works well and web container picks up changes. Major locking problem on Windows which causes a lot of subsequent redeploys to fail.

    2) WAR format: Almost always succeeds in deploying, but unless webapp itself is set to reloadable you don’t see any changes in it.

    Also in Tomcat Admin, in the base “Host” settings, there is a “Reloadable” Flag, I wonder if that would fix auto-redeploying the WARs or not? Admitedly I haven’t played around a whole lot with this

Viewing 15 posts - 1 through 15 (of 17 total)
Reply To: Web Application – Redeployment [Closed]

You must be logged in to post in the forum log in