Re: Tomcat 10.1.4 HTTP Status 404 and 500 Help
Mark, Thanks for your corrections. I have updated my internal "How to" guide that I created when I first used Tomcat to build my servlets and it appears that some of my deductions from that initial research and "getting it to work" were misguided. John On Wed, 11 Jan 2023, 09:28 Mark Thomas, wrote: > > > On 10/01/2023 22:34, John Barrow wrote: > > Hi Anthony, > > > > Not an expert, but have managed to deploy simple servlets. A couple of > > observations, not sure why using ROOT, you should have your own folder > for > > your application (e.g. myFirstApp\...). > > Not true. ROOT is an acceptable option here. > > > Also, I have found that the main app folder (e.g. myFirstApp) must start > > with a lowercase letter (I don't know reason for this but have it in my > > notes) otherwise the servlets won't be found when accessing them through > a > > browser. > > Also not true. You may be mixing the rules for Java package names with > those for context paths. > > > Finally, the default install for TomCat has several example servlets > > already written so check that they work first and then take the sources > and > > clone them, using them as a guide for your own servlets. > > > > John > > > > PS: Probably worth reviewing what file names you use (see your > webapps.xml > > file) when making public requests so as not to inadvertently offend > anyone. > > +1 > > Mark > > > > > On Tue, 10 Jan 2023, 18:59 Anthony Dell'Anno, > > wrote: > > > >> Good afternoon, > >> > >> I'm trying to run my first servlet on Tomcat, and am continually > >> getting an HTTP Status 404 (I've also gotten 500 previously, with the > root > >> cause being an apparent compiler mismatch (it would say that it's being > >> compiled by version 63.0, which is Java 19, but that the latest version > >> that was currently accepted was version 59.0, or Java 15), but then > after > >> upgrading to JDK 19, changing the JAVA_HOME variable and trying to run, > it > >> would still give me the same error)? > >> > >> I have my Servlet, called HelloWorldServlet, located in the > >> "C:\apache-tomcat-10.1.4\webapps\ROOT\WEB-INF\classes\" directory, with > the > >> web.xml file being located outside of the classes folder, directly > inside > >> of the WEB-INF folder. > >> > >> I've included both files. StackOverflow wasn't much help as of > yet, so > >> I'm hoping that the Tomcat Users community can help me solve this so > that I > >> can continue learning servlets. I'm working on building my own software > >> company. > >> > >> Any help is appreciated. > >> > >> Thank you very much, > >> > >> Anthony Dell'Anno > >> > >> - > >> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > >> For additional commands, e-mail: users-h...@tomcat.apache.org > > > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >
Re: Tomcat 10.1.4 HTTP Status 404 and 500 Help
Hi Anthony, Not an expert, but have managed to deploy simple servlets. A couple of observations, not sure why using ROOT, you should have your own folder for your application (e.g. myFirstApp\...). Also, I have found that the main app folder (e.g. myFirstApp) must start with a lowercase letter (I don't know reason for this but have it in my notes) otherwise the servlets won't be found when accessing them through a browser. Finally, the default install for TomCat has several example servlets already written so check that they work first and then take the sources and clone them, using them as a guide for your own servlets. John PS: Probably worth reviewing what file names you use (see your webapps.xml file) when making public requests so as not to inadvertently offend anyone. On Tue, 10 Jan 2023, 18:59 Anthony Dell'Anno, wrote: > Good afternoon, > > I'm trying to run my first servlet on Tomcat, and am continually > getting an HTTP Status 404 (I've also gotten 500 previously, with the root > cause being an apparent compiler mismatch (it would say that it's being > compiled by version 63.0, which is Java 19, but that the latest version > that was currently accepted was version 59.0, or Java 15), but then after > upgrading to JDK 19, changing the JAVA_HOME variable and trying to run, it > would still give me the same error)? > > I have my Servlet, called HelloWorldServlet, located in the > "C:\apache-tomcat-10.1.4\webapps\ROOT\WEB-INF\classes\" directory, with the > web.xml file being located outside of the classes folder, directly inside > of the WEB-INF folder. > > I've included both files. StackOverflow wasn't much help as of yet, so > I'm hoping that the Tomcat Users community can help me solve this so that I > can continue learning servlets. I'm working on building my own software > company. > > Any help is appreciated. > > Thank you very much, > > Anthony Dell'Anno > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Configure Tomcat development using NetBeans IDE
Mark, Just as a follow up to the two rogue test files tomcat\test\org\apache\coyote\http2\TestStream.java tomcat\test\util\TestCookieFilter.java I copied the util and trailers folders into the java folder and that didn't make any difference. Also I noticed that, for the TestStream.java source it mentions import trailers.ResponseTrailers; and when I hover over the exception it says that 'package trailers' doesn't exist, whereas there is a POJC in the trailers folder (ResponseTrailers.java). Both these points may be irrelevant or, in the case of the second point - package = java class as far as import goes, but I mention them just in case. John On Thu, 24 Feb 2022 at 15:13, John Barrow wrote: > > Mark, > > I have now got grep working (following a post from another member > indicating that built into git bash!) > > > ant download-test-compile > > This is useful to know as I didn't run the tests script until later. > > > ant download-validate > > This didn't report Checkstyle missing - probably as not needed for > actual development. Running Checkstyle using > > ant -Dexecute.validate=true validate > > did then update the libraries folder > > > I doubt you'll need a release build > > So do I by the sound of it - I will probably come back to the forum > when looking to commit anything for the first time but I assume that I > will just upload any changes that, once approved, will form part of > the next release. Of course I will be able to benefit from the newly > developed time-delay in the meantime :) > > I have passed on your observation "but NetBeans is not taking into > account the isELIgnored="true" page directive" to the NetBeans > community > > > I'd see if you can disable the JSP validation. If it makes you feel better, > > Eclipse's JSP validation has similar issues. > > That has no effect! We can drop the issues over JSP as the NetBeans > community has taken up that baton. > > > That is an abstract base class. You won't be able to run it. > > Trust me to pick that one! I have only ever written simple unit tests > so not needed to create any abstract classes in my testing, but I > should have spent more time looking into your source and then would > have spotted the 'abstract' keyword!! In a very weak defence, I tend > to use interfaces rather than abstract classes. Anyway, thanks for the > naming conventions, that will prove time-saving. For good measure, I > ran TestDefaultServlet and that ran the tests successfully. > > Thanks for the explanation of the dual 'bin' folders. > > > Yes, the Java compiler is smart enough to generate the byte code as if it > > was generated with Java 11 so you are fine to stick with Java 17 as long as > > the build version is 11. > > I have amended my project options to reflect this and rebuilt the > project to check everything still works - it does! > > > Ah. You need to add webapps/examples/WEB-INF/classes as a source folder. > > That should fix the two issues above. > > I must still be missing a link here, I have added that folder to the > list of elements. I also added it to the since, as > the project references files inside this folder, it seemed applicable > to include it. However, it didn't appear to make any difference - i.e. > NetBeans still couldn't tie the source back to those Java classes. > > I have checked that I have typed the paths correctly and I can see the > trailers.ResponseTrailers (& util.CookieFilter) file(s) in the > WEB-APP\classes and visible in the project folders (I assume as added > to ) to back-up paths are valid. NetBeans doesn't let me take > any action to try and find the file to resolve the [!], I assume > because it is a free form Ant project and so configuration is > 'read-only' once loaded (I would have options in Maven to locate the > missing resource). > > I have added my current project.xml and Trailers.ResponseTrailers.jpg > to the DropBox folder in case either of them helps. My only > observation is that, as I can't find a corresponding XSD file for > project.xml, there is another attribute I need to set to indicate that > these are class files in a different folder to the one the other > package files are in, but that seems unlikely. > > > I think you mean 8000 for remote debugging but otherwise great. If you can > > get this working, you are doing really well. > > I was using 8080 and appeared to be working although I have not used > it in anger yet. I had amended the catalina.bat line "set > JPDA_ADDRESS=localhost:8080, because I connect to Tomcat using > http://localhost:8080/examples. Your statement concerned me slightly > in that I now believe that I had made a wrong assumptio
Re: Configure Tomcat development using NetBeans IDE
Mark, I have now got grep working (following a post from another member indicating that built into git bash!) > ant download-test-compile This is useful to know as I didn't run the tests script until later. > ant download-validate This didn't report Checkstyle missing - probably as not needed for actual development. Running Checkstyle using ant -Dexecute.validate=true validate did then update the libraries folder > I doubt you'll need a release build So do I by the sound of it - I will probably come back to the forum when looking to commit anything for the first time but I assume that I will just upload any changes that, once approved, will form part of the next release. Of course I will be able to benefit from the newly developed time-delay in the meantime :) I have passed on your observation "but NetBeans is not taking into account the isELIgnored="true" page directive" to the NetBeans community > I'd see if you can disable the JSP validation. If it makes you feel better, > Eclipse's JSP validation has similar issues. That has no effect! We can drop the issues over JSP as the NetBeans community has taken up that baton. > That is an abstract base class. You won't be able to run it. Trust me to pick that one! I have only ever written simple unit tests so not needed to create any abstract classes in my testing, but I should have spent more time looking into your source and then would have spotted the 'abstract' keyword!! In a very weak defence, I tend to use interfaces rather than abstract classes. Anyway, thanks for the naming conventions, that will prove time-saving. For good measure, I ran TestDefaultServlet and that ran the tests successfully. Thanks for the explanation of the dual 'bin' folders. > Yes, the Java compiler is smart enough to generate the byte code as if it was > generated with Java 11 so you are fine to stick with Java 17 as long as the > build version is 11. I have amended my project options to reflect this and rebuilt the project to check everything still works - it does! > Ah. You need to add webapps/examples/WEB-INF/classes as a source folder. That > should fix the two issues above. I must still be missing a link here, I have added that folder to the list of elements. I also added it to the since, as the project references files inside this folder, it seemed applicable to include it. However, it didn't appear to make any difference - i.e. NetBeans still couldn't tie the source back to those Java classes. I have checked that I have typed the paths correctly and I can see the trailers.ResponseTrailers (& util.CookieFilter) file(s) in the WEB-APP\classes and visible in the project folders (I assume as added to ) to back-up paths are valid. NetBeans doesn't let me take any action to try and find the file to resolve the [!], I assume because it is a free form Ant project and so configuration is 'read-only' once loaded (I would have options in Maven to locate the missing resource). I have added my current project.xml and Trailers.ResponseTrailers.jpg to the DropBox folder in case either of them helps. My only observation is that, as I can't find a corresponding XSD file for project.xml, there is another attribute I need to set to indicate that these are class files in a different folder to the one the other package files are in, but that seems unlikely. > I think you mean 8000 for remote debugging but otherwise great. If you can > get this working, you are doing really well. I was using 8080 and appeared to be working although I have not used it in anger yet. I had amended the catalina.bat line "set JPDA_ADDRESS=localhost:8080, because I connect to Tomcat using http://localhost:8080/examples. Your statement concerned me slightly in that I now believe that I had made a wrong assumption. Anyway, I amended the catalina.bat back and set NetBeans remote debugging to the same and it worked as well so I will leave it at 8000. I couldn't find anything on the web re Port 8000 vs 8080 (apart from "use which one you want"), but I suspect that, ideally, the debugging communications should be using a different port to the application otherwise there may be conflicts but couldn't find anything to back up that hypothesis. > - Patch file in diff -u format attached to a BugZilla issue > - GitHub pull request > Happy to provide pointers for either approval if needed. Unfortunately,II will now probably have to wait a bit for that. I will soak the changes to the NetBeans configuration files while I explore Tomcat, once the webapps/examples/WEB-INF/classes issue is sorted and (hopefully) the NetBeans community has resolved the other exceptions. That way, if I discover another missing link, I can incorporate it and upload all the configuration changes at once to minimise confusion. However, I am away in a weeks time - 5th March (Snowboarding at last!), and have to catch up with some other chores / tasks before getting back on the laptop. Hopefully, we can get these last minor
RE: is too quick to respond
Christopher, > You will just change the implementation to answer the question "have any resources been modified, but not-too-recently?" OK > The check must be fast, otherwise it will hang-up other processes on the server. Don't introduce any new loops or stalls. Just return true or false as quickly as possible. The process will be repeated during the "next" check so you only have to decide not to reload "too early"? Not sure that I understand this point (re 'check must be fast'). I wasn't imagining affecting the initial trigger point at all (i.e. Tomcat has detected a change in one of the active files) so shouldn't affect the day-to-day performance. Once Tomcat has decided that a reload is required *and* the user has requested for Tomcat to do the reload (i.e. Context flag is defined to true), prior to actioning the reload, add the additional check (simple user-specified timer delay to allow the external application time to finish deployment, and then let Netbeans carry on. Your additional suggestion that the time-stamps of the amended files should remain consistent over that period also sounds sensible. Given that Tomcat can't implement the event model for reasons you have already explained, I am now thinking that the event that triggers the re-build won't contain details of what files have been amended, simply that there has been a change. Snapshotting all the files within the two folders, noting the timestamps and then polling again after the delay seems to be repeating what Tomcat is probably already doing to trigger the event in the first place. Now that I just about have a development environment I can explore and debug, I think I should spend some time around this class and learn when / why it's called and the calls it makes to do the reload. So far, I have had to imagine how the code is structured and so consider a solution based on that (possibly false hypothesis). Just to be clear from other questions, I have no intention in going anywhere near the 'rebuild' process - that is a black box as far as I am concerned. John PS: Nice suggestion about contacting IT for more cores - unfortunately I am now (recently) retired and so, I am the IT department and the Finance director (wife) hasn't approved the budget :)
Re: Configure Tomcat development using NetBeans IDE
Hi Greg, > You should not need to reload tomcat for code unless NetBeans cannot handle > hot reload. I don't believe that there is a problem with NetBeans, it updates the active code files in the WEB_APP/classes perfectly, but then as previously discussed in the other thread, there is no file locking (not possible) and as soon as multiple files need recompiling (in my case a listener and a class) we risk having an unstable deployment, albeit for a fraction of a second. Tomcat detects the first file change and that triggers the reload of the webapp. However, the listener class (in my case) is still being created / updated and causes Tomcat to crash (understandably so). Weirdly enough, I never had an issue until I upgraded to Tomcat 10, but I suspect that was a fluke of the project I was working on rather than the upgrade. I mainly create Java Servlets (brilliant API by the way) and so am installing many small individual class files. > I would stop and restart tomcat for method signature changes, new classes > etc. It's quick and stops reload issues. You are right, Tomcat is ridiculously fast to Start / Stop (2 mouse clicks for me, 5 seconds). In fact when I first installed Tomcat that is how I operated until I discovered reloadable - and I fall into that historic stereotypical old-school developer type labelled 'lazy', true in my case. I could now halve the number of keystrokes (and shave 5 seconds off my deploy) so now it was F11 (recompile), F5 (browser refresh). Of course, once you have been tempted by the serpent, it is so hard to have your candy taken away from you hence me spending a week attempting to install Tomcat and implement some protection for this scenario :) John On Wed, 23 Feb 2022 at 08:10, Greg Huber wrote: > > There have been lots of emails on this, sorry if I have missed something.. > > Although I don't use net beans, I use Eclipse with the venerable Sysdeo > Tomcat Plugin (modified), and from my experience set reloadable = > "false". I would stop and restart tomcat for method signature changes, > new classes etc. It's quick and stops reload issues. > > You should not need to reload tomcat for code unless, net beans cannot > handle hot reload. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Configure Tomcat development using NetBeans IDE
Hi, Firstly, this is actually a continuation of a previous thread (specifically the email from Make Thomas, dated 21/02/2022 08:10) discussing the specification for enhancing the reloading of webapps after changes to the deployed files. This thread is titled ‘ is too quick to respond’ and remains active with outstanding discussion points. However, in order to try and implement the suggested changes, I needed to create a development environment and so the thread quickly shifted into a bunch of configuration issues which took the thread off topic. Secondly, this email is quite long as I wanted to describe the steps I took to get to where I am now (briefly, nearly there, just can't fully test, unless all of them!). I have also included some suggestions for alterations to the NetBeans configuration files that I am happy to commit back to git if my understanding is correct./ deductions are correct although one of them appears to be an issue with the ant build and I am not confident enough to research this. There are a couple of attachments that, as before, I have placed in my shared Dropbox folder, accessed from https://www.dropbox.com/sh/2ewipogzr48qcxi/AAAf3Rqv6WoRO9hyMC0W7P2za?dl=0 Mark, your insightful email has proved invaluable and having spent a couple of days working through this, it has provided the catalyst for me to be able to start joining the dots to achieving a full development environment. So, responding to each of your suggestions has taken me on a massive learning curve, but Firstly, I started back with a blank piece of paper. > If your eventual aim is to provide a pull request to address this issue then > I'd recommend: > - Fork the Tomcat project in GitHub > - Checkout your clone As a life-long supporter of Subversion, this was my first foray into the world of git, but I believe, after a quick crash course, I have managed to have forked and cloned Tomcat onto my laptop! > This is where using a clone would speed things up as you'd be able to fetch > the update from Git. Therefore, you can now assume that I can speed things up :) I have built Tomcat using Ant. Ran the amended 'ant ide-netbeans' script (checked GitHub to see what changes had been made - the details of this change log request turned out to be very useful later!) > Hmm. You shouldn't see any warnings about modules. A handful of warnings > about deprecation are expected. If you still see these warnings then yes, > please provide a copy so we can take a look. Launched NetBeans and did a clean > deploy. The results are in my shared DropBox folder (along with everything else) called "Ant Clean and Build from Netbeans.txt" and it did actually look to have done a successful build if you believe the summary line! While I did get warnings about deprecated features as expected, I also had quite a number of other warnings that looked a bit concerning (which you asked me to submit to you) e.g. - WARN aQute.bnd.plugin.jpms.JPMSModuleInfoPlugin - Can't find a module name for imported package: jakarta.websocket At this point, I still had a lot of red [!] against the Tests folder, just as before and so the version amendment for jUnit didn't appear to work, although I verified that it is the latest jUnit v4 build from Mavens repository. As an aside, as I am sure you are aware, NetBeans didn't support any later versions of jUnit using the Ant framework as they believe that no-one should be using Ant anymore and should migrate to Maven / Gradle! So, rather than push back immediately, I thought I would spend some time yesterday trying to figure it out, given that you had (by your change) hinted which of the files might be related to my issue. Also, your reference to tomcat\res\ide-support\netbeans\README.txt was enlightening! Anyway, to cut a long investigation short, I found two environments that were out of sync. As far as I can tell, in nbproject\project.xml, the classpath just underneath the element output/classes:output/testclasses:${base.path}/junit-4.13.2/junit-4.13.2.jar:${base.path}/easymock-4.3/easymock-4.3.jar:${base.path}/objenesis-3.2/objenesis-3.2.jar:${base.path}/cglib-3.3.0/cglib-nodep-3.3.0.jar:${base.path}/hamcrest/hamcrest-2.2.jar should look more like output/classes:output/testclasses:${base.path}/junit-4.13.2/junit-4.13.2.jar:${base.path}/easymock-4.3/easymock-4.3.jar:${base.path}/objenesis-3.2/objenesis-3.2.jar:${base.path}/cglib-3.3.0/cglib-nodep-3.3.0.jar:${base.path}/hamcrest-2.2/hamcrest-2.2.jar:${base.path}/unboundid-ldapsdk-6.0.3/unboundid-ldapsdk-6.0.3.jar There was a typo in the hamcrest folder name (missing version) and some of the classes the test sources referred to were missing. I used the Maven repository to identify the latest versions and downloaded them. The reason that the jUnit classes weren't found is that they weren't being downloaded into the {base.path} folder as part of the 'ant' script, used to build Tomcat, but looks like only the jars
Re: is too quick to respond
Neil, > I think it's a bad idea to design a solution based on the file type. A > webapp can contain all kinds of files. Why is that in this instance when the focus is on deploying to these specific folders as defined by Tomcat? Taken from the Tomcat documentation... - WEB-INF/classes/ - This directory contains any Java class files (and associated resources) required for your application, including both servlet and non-servlet classes, that are not combined into JAR files. If your classes are organized into Java packages, you must reflect this in the directory hierarchy under WEB-INF/classes/. For example, a Java class named com.mycompany.mypackage.MyServlet would need to be stored in a file named WEB-INF/classes/com/mycompany/mypackage/MyServlet.class. - WEB-INF/lib/ - This directory contains JAR files that contain Java class files (and associated resources) required for your application, such as third party class libraries or JDBC drivers. So, while there may be additional resources I would have thought that it would be safe to assume that .war, .jar & .class suffixes contained Java classes / resources, raw (.class) or zipped (.war, .jar). Regarding checking the validity of a .war / .jar, there looks to be a good way of checking validity in the standard java.util.zip.ZipFile class which opens a file for reading and will return an exception if there is a ZIP format error. Of course, if we might expect someone to deploy a file with one of the "reserved" suffixes that does not conform then the file will never pass validation and so either would need to give up after a period of time and let the reload continue or raise an exception reporting that the file did not contain the expected type (i.e. a recognised zip file structure). Given that Tomcat is pretty well defined about what those two folders are for, I would have thought that we should be able to expect that users would confirm to only use the recognised suffixes for the purpose they are intended for and the benefits of a safe deployment outway the outside risk of users abusing the meaning of the suffixes. Of course, only those files with those two suffixes (jar / war) would have the additional validation applied, the rest would simply be subject to the timeout for non activity having expired. John Neil,> I think it's a bad idea to design a solution based on the file type. A webapp can contain all kinds of files.Why is that in this instance when the focus is on deploying to these specific folders as defined by Tomcat? WEB-INF/classes/ - This directory contains any Java class files (and associated resources) required for your application, including both servlet and non-servlet classes, that are not combined into JAR files. If your classes are organized into Java packages, you must reflect this in the directory hierarchy under WEB-INF/classes/. For example, a Java class named com.mycompany.mypackage.MyServlet would need to be stored in a file named WEB-INF/classes/com/mycompany/mypackage/MyServlet.class.WEB-INF/lib/ - This directory contains JAR files that contain Java class files (and associated resources) required for your application, such as third party class libraries or JDBC drivers.So, while there may be additional resources I would have thought that it would be safe to assume that .war, .jar & .class suffixes contained Java classes / resourses, raw (.class) or zipped (.war, .jar).Regarding checking the validity of a .war / .jar, there looks to be a good way of checking validity in the standard java.util.zip.ZipFile class which opens a file for reading and will return an exception if there is a ZIP format error.Of course, if we might expect someone to deploy a file with one of the "reserved" suffixes that does not conform then the file will never pass validation and so either would need to give up after a period of time and let the reload continue or raise an exception reporting that the file did not contain the expected type (i.e. a recognised zip file structure). Given that Tomcat is pretty well defined about what those two folders are for, I would have thought that we should be able to expect that users would confirm to only use the recognised suffixes for the purpose they are intended for and the benefits of a safe deployment outway the outside risk of users abusing the meaning of the suffixes.Of course, only those files with those two suffixes (jar / war) would have the additional validation applied, the rest would simply be subject to the timeout for non activity having expired.John Original message From: Neil Aggarwal Date: 20/02/2022 18:29 (GMT+00:00) To: Tomcat Users List Subject: Re: is too quick to respond I think it's a bad idea to design a solution based on the file type. A webapp can contain all kinds of files. On Sun, Feb 20, 2022, 12:16 PM Simon Matter wrote: > > I may be wrong but I thought .war files are zip files. Wouldn't it be > possible to just wait until the file has a consistent
Re: is too quick to respond
Simon,That's my understanding as well, just that they have to have a defined folder structure within the zip but can unzip with any utility program. When you say "consistent content", how would you determine that without actually 'suck and see' which would lead to having to interfere with Tomcats reload algorithms, not something I would be comfortable with. Is there a read-only method (e.g. isValidZip() in a Library that is available to Tomcat) that I could call to check this? I will know the file that has been changed / replaced and so know that it has a .war extension.John Original message From: Simon Matter Date: 20/02/2022 18:15 (GMT+00:00) To: Tomcat Users List Subject: Re: is too quick to respond > Not sure about Tomcat, but what IBM Liberty does is:>> It "will" try to redeploy the war when it detects a file change - and it> does fail naturally since the war isn't complete.>> BUT - it will keep trying since during the upload, the timestamp and file> size automatically keeps changing - so at the end, it will succeed in> deploying the whole war file.I may be wrong but I thought .war files are zip files. Wouldn't it bepossible to just wait until the file has a consistent content and thenextract it?Simon>> I wish they would have just monitored the file size for a configurable> "given" time. And lets say - if the file size or timestamp doesn't change> for -say - 15 seconds, then go ahead and do the deployment, but as what> was mentioned earlier, different OS(s) may handle this differently, but> the JAVA NIO API watchevents point you in the right direction in watching> a file/folder in a loop for a "create" or "modify" or "delete" event to> occur and fire off.>> thanks,> jason>> - Original Message -> From: "chris" > To: "users" > Sent: Sunday, February 20, 2022 9:22:17 AM> Subject: Re: is too quick to respond>> John,>> On 2/20/22 05:50, John Barrow wrote:>> Neil,>>>> Thanks for your useful feedback. I am still feeling my way as you can>> probably see from my earlier emails trying to setup a development>> environment.>>>> I did actually think of this but didn't put it in scope for a couple of>> reasons.>>>> Firstly, the Tomcat documentation for readloadable quotes>>>> "Set to true if you want Catalina to monitor classes in>> /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically>> reload the web application if a change is detected. This feature is>> very useful during application development, but it requires>> significant runtime overhead and is not recommended for use on>> deployed production applications. That's why the default setting for>> this attribute is false. You can use the Manager web application,>> however, to trigger reloads of deployed applications on demand.">>>> Therefore, I took it to mean that this flag was geared at development,>> not production which is what I assume when you would deploy a .war>> file. So Tomcat would be listening to specific changes in .classes and>> .jar files that had just been compiled and these are normally small in>> size. But then I suppose that a single .jar file may be so sized that>> Tomcat could react while the file was still being written to the disk.>> The patch you are currently working on should fix this aspect of the> overall problem you are trying to solve.>>> Secondly, I sort of assumed that since the feature was already in>> place and handles changes to single files that this check for>> completeness has already been implemented, but then as I can't get a>> development environment to run, I don't have enough skills to drill>> into the sources without it being interactive to help me explore and>> learn.>>>> However, it makes sense that your recommendation is implemented,>> although I was imagining setting the delay to (say) 500ms to ensure>> that whatever IDE had time to complete the copying of all the files as>> that is a small price to pay for automatic refresh. Also by resetting>> the timer after each event it would have to be quite a large upload>> for Tomcat to start reacting.>>>> Like you, I am not sure how to formally check that a file has>> completed its copy to the destination. The most common suggestion I>> hear is to try and change its name and then change it back again and>> capture the exception which will be raised if the file is locked. I>> wonder whether attempting to set an attribute (e.g.toggle read-only)>> would have the same effect (i.e. only allow if file wasn't
RE: is too quick to respond
Hi all, I have also uploaded the screenshots that I took within NetBeans illustrating some of my issues with getting Tomcat working within Netbeans. As mentioned previously, when I did my test project using Ant, it created a Libraries folder where I could and add JAR/Folder. This structure is not available for the imported Tomcat project after having run ant ide-netbeans. Not that I would expect to have to do this as I would have thought that all the relevant configuration settings would already be set up in the build.xml file, so I am missing a vital step somewhere. Finally, the failed tests zip is also there in case it was stripped out for anyone else that might be interested. John *From: *Christopher Schultz *Sent: *20 February 2022 14:22 *To: *users@tomcat.apache.org *Subject: *Re: is too quick to respond John, On 2/20/22 05:50, John Barrow wrote: > Neil, > > Thanks for your useful feedback. I am still feeling my way as you can > probably see from my earlier emails trying to setup a development > environment. > > I did actually think of this but didn't put it in scope for a couple of reasons. > > Firstly, the Tomcat documentation for readloadable quotes > > "Set to true if you want Catalina to monitor classes in > /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically > reload the web application if a change is detected. This feature is > very useful during application development, but it requires > significant runtime overhead and is not recommended for use on > deployed production applications. That's why the default setting for > this attribute is false. You can use the Manager web application, > however, to trigger reloads of deployed applications on demand." > > Therefore, I took it to mean that this flag was geared at development, > not production which is what I assume when you would deploy a .war > file. So Tomcat would be listening to specific changes in .classes and > .jar files that had just been compiled and these are normally small in > size. But then I suppose that a single .jar file may be so sized that > Tomcat could react while the file was still being written to the disk. The patch you are currently working on should fix this aspect of the overall problem you are trying to solve. > Secondly, I sort of assumed that since the feature was already in > place and handles changes to single files that this check for > completeness has already been implemented, but then as I can't get a > development environment to run, I don't have enough skills to drill > into the sources without it being interactive to help me explore and > learn. > > However, it makes sense that your recommendation is implemented, > although I was imagining setting the delay to (say) 500ms to ensure > that whatever IDE had time to complete the copying of all the files as > that is a small price to pay for automatic refresh. Also by resetting > the timer after each event it would have to be quite a large upload > for Tomcat to start reacting. > > Like you, I am not sure how to formally check that a file has > completed its copy to the destination. The most common suggestion I > hear is to try and change its name and then change it back again and > capture the exception which will be raised if the file is locked. I > wonder whether attempting to set an attribute (e.g.toggle read-only) > would have the same effect (i.e. only allow if file wasn't locked) and > be a little more elegant. I would have to try it. Don't do anything like that; it won't work on various environments. For example, Windows obtains exclusive file-locks for even sometimes read-only operations. But *NIX does /not/. So you may develop something that works on Windows but doesn't work at all anywhere else. You basically can't check to see if a file is "done uploading"" or whatever else may be happening. What you *can* do is check to see if any file in the list-of-files-to-be it *too recent* indicating that a compile/copy/upload/whatever may still be in progress. > I assume that Windows has a way of querying a file lock but not sure > (a) whether that is exposed via a Java API and (b) whether that would > apply to Unix as well (as I have only ever used Windows for > development). > >> How does Tomcat test if a file has been updated? It's just relative timestamps. Dive into the code Mark suggested and you'll find it. > Again, I don't know this yet (lack of IDE again), but I assumed that > it would be similar to the method I implemented in the attached source > code, i.e. Create a listener for events being triggered on file > changes to either /WEB-INF/classes/ and /WEB-INF/lib, as they are both > hard-coded file paths. I don't think your attachme
RE: is too quick to respond
Hi all, I will consolidate the comments from the last three emails to keep the thread from splitting too much. > Christopher: I don't think your attachment made it to the list. Maybe you can > host it somewhere else and then post a URL to the list? Attachments tend to > be stripped. I'm actually surprised your ZIP file made it through. Firstly, I wasn’t aware that text attachments would be stripped. I certainly didn’t get any notification although I did get plenty of notifications when I used Windows Mail to reply (no Plain Text support!) The URL for the sources is below which are held in my DropBox account. Hopefully the link below will allow access. Let me know if there are any issues. https://www.dropbox.com/sh/2ewipogzr48qcxi/AAAf3Rqv6WoRO9hyMC0W7P2za?dl=0 > Christopher: Don't do anything like that; it won't work in various > environments. For example, Windows obtains exclusive file-locks for even > sometimes read-only operations. But *NIX does /not/. So you may develop > something that works on Windows but doesn't work at all anywhere else. That was my understanding. When I was working, I remember there not being a comprehensive solution to this requirement and that Unix was very 'flexible' when handling files in flux, hence my query as I was not sure if something more recent had surfaced that I wasn't aware of. I believe that the 'wait a while' approach is (a) practical and (b) minimises conflicts with the way that Tomcat is operating. It is also flexible in that, if you know that you are refreshing large files then giving (say) a minute for the upload to work before Tomcat reloads is reasonable whereas if developing small Servlets then a few microseconds is probably all that is needed so the administrator can tune to the environment. > Christopher: The patch you are currently working on should fix this aspect of > the overall problem you are trying to solve. Thanks for the vote of confidence - hopefully now that you can see / run the sample app, that confidence will remain! > Christopher: It's just relative timestamps. Dive into the code Mark suggested > and you'll find it. That surprises me. I can't wait to dive in once I can get my IDE working. Is Tomcat polling the folder every 'x' microseconds then? That may explain the caution in the Tomcat documentation in that it puts a strain on the server. You will see from the sources that I have uploaded to DropBox, that I mimicked an event model that seemed to work quite well, however I am not sure which model would be more efficient and less intrusive on Tomcat's operation. > Jason: but the JAVA NIO API watchevents point you in the right direction in > watching a file/folder in a loop for a "create" or "modify" or "delete" event > to occur and fire off. As you should now be able to see from my DropBox source files, that is the approach I took although I wasn't looking to implement that, simply mock-up what I thought that Tomcat was already doing to detect the need for a reload. > I wish they would have just monitored the file size for a configurable > "given" time. And lets say - if the file size or timestamp doesn't change > for -say - 15 seconds, then go ahead and do the deployment. That would be easy enough to add in as a fail-safe and while not perfect as it makes assumptions on external factors, we can at least be sure that if either the timestamp or file size has been amended then it is still in flux whilst not offering any guarantees if they are identical. As I get an event for each file/folder that has been amended, I could then add another loop to check stability of these two attributes (say over 10 ms intervals, or add a further parameter to be user configurable) before starting the final 'waitForQuiet' timer prior to notifying Tomcat to start the reload. It is also a read-only query and so has no side-effects as it appears that users have a need to auto-reload after refreshing a larger .war file. Thoughts? Enjoy your evening. John From: Christopher Schultz Sent: 20 February 2022 14:22 To: users@tomcat.apache.org Subject: Re: is too quick to respond John, On 2/20/22 05:50, John Barrow wrote: > Neil, > > Thanks for your useful feedback. I am still feeling my way as you can > probably see from my earlier emails trying to setup a development > environment. > > I did actually think of this but didn't put it in scope for a couple of > reasons. > > Firstly, the Tomcat documentation for readloadable quotes > > "Set to true if you want Catalina to monitor classes in > /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically > reload the web application if a change is detected. This feature is > very useful during application development, but it requires > significant runtime overhead and is not recommended for use on > deployed production a
Re: is too quick to respond
Neil, Thanks for your useful feedback. I am still feeling my way as you can probably see from my earlier emails trying to setup a development environment. I did actually think of this but didn't put it in scope for a couple of reasons. Firstly, the Tomcat documentation for readloadable quotes "Set to true if you want Catalina to monitor classes in /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically reload the web application if a change is detected. This feature is very useful during application development, but it requires significant runtime overhead and is not recommended for use on deployed production applications. That's why the default setting for this attribute is false. You can use the Manager web application, however, to trigger reloads of deployed applications on demand." Therefore, I took it to mean that this flag was geared at development, not production which is what I assume when you would deploy a .war file. So Tomcat would be listening to specific changes in .classes and .jar files that had just been compiled and these are normally small in size. But then I suppose that a single .jar file may be so sized that Tomcat could react while the file was still being written to the disk. Secondly, I sort of assumed that since the feature was already in place and handles changes to single files that this check for completeness has already been implemented, but then as I can't get a development environment to run, I don't have enough skills to drill into the sources without it being interactive to help me explore and learn. However, it makes sense that your recommendation is implemented, although I was imagining setting the delay to (say) 500ms to ensure that whatever IDE had time to complete the copying of all the files as that is a small price to pay for automatic refresh. Also by resetting the timer after each event it would have to be quite a large upload for Tomcat to start reacting. Like you, I am not sure how to formally check that a file has completed its copy to the destination. The most common suggestion I hear is to try and change its name and then change it back again and capture the exception which will be raised if the file is locked. I wonder whether attempting to set an attribute (e.g.toggle read-only) would have the same effect (i.e. only allow if file wasn't locked) and be a little more elegant. I would have to try it. I assume that Windows has a way of querying a file lock but not sure (a) whether that is exposed via a Java API and (b) whether that would apply to Unix as well (as I have only ever used Windows for development). > How does Tomcat test if a file has been updated? Again, I don't know this yet (lack of IDE again), but I assumed that it would be similar to the method I implemented in the attached source code, i.e. Create a listener for events being triggered on file changes to either /WEB-INF/classes/ and /WEB-INF/lib, as they are both hard-coded file paths. As an aside, I should have mentioned, for anyone interested in this thread and in case not obvious from the source, but to see the sample source code in action, you need to add, modify, rename or delete files within the specified directory in a File Explorer. John On Sun, 20 Feb 2022 at 00:04, Neil Aggarwal wrote: > > John: > > > If anyone has a moment, can you have a quick look and see if what I am > > proposing seems acceptable. > > Thinking about when a large file (Such as a war file) is being uploaded > to the server, we don't want Tomcat to reload it until after the file has > completed upload and is fully formed. > > How does Tomcat test if a file has been updated? > I assume it uses File.lastModified() or something similar. > > Does anyone know the detailed nuts and bolts of how that works? > Does last modified keep changing as the file is uploading or is it just > changed at the start of the upload? Is the behavior the same or different > across platforms? > > These questions should be taken into account when designing the solution. > > Thank you, > Neil > > -- > Neil Aggarwal, (972) 834-1565, http://www.propfinancing.com > We offer 30 year loans on single family houses! > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: is too quick to respond
Hi, While we continue the investigation into why I can't get Tomcat to run within NetBeans, I thought that I would create a mockup of the functionality that I would look to implement to protect the reloading of the webapp until the files have been rebuilt. I have mimicked the expected Tomcat listener for changes to a folder structure but of course that will already exist within Tomcat and so will only be looking to react to the existing events that are being triggered. If anyone has a moment, can you have a quick look and see if what I am proposing seems acceptable. The source is pretty short. To run this, once compiled, you just need to create a blank folder (or reference an existing one) and then amend the three constants, specifically to reference your folder! static final String folderToWatch = "C:\\Community\\MonitorFolder"; static final int timeToWatchSeconds = 30; // How long to listen for changes to files in the folder static final int timeForQuietMilliseconds = 5000; // How long to wait with no activity before triggering reload (list directory files in my example) The only minor observation is that if the period to listen for changes expires prior to the period of no activity then the 'reload' task (print the files in the directory) won't be triggered but as that would (guessing now) only be when Tomcat was shut down then it would be irrelevant anyway. Thanks John On Fri, 18 Feb 2022 at 17:03, Christopher Schultz wrote: > > John, > > On 2/18/22 10:50, John Barrow wrote: > >>> Would you be interested in looking at the existing algorithm to see if > >>> it would be updated in this way? > > > >> WebappLoader.backgroundProcess() would be a good place to start. > > > > I am sort of interested in looking at this. > > Awesome! > > > I have only been playing > > with Java for about 6 months, having been a Pascal developer most of > > my life (40 odd years). Therefore, I think that I could at least ‘give > > it a look’, if I can get Tomcat installed locally. > > > > However, I appreciate that I could be well out of my depth and there > > are too many unknowns / barriers in order to be of any use. > > > > It is the installation process that I am having issues with. I think > > it is down to lack of experience / knowledge / familiarity with > > commercial strength application. > > > > I use Netbeans 12.6 (Apache loyalty!) on Windows 10 for all my Java > > development using JDK 17. > > > > Unfortunately, I am only ‘sort-of’ familiar with Maven and have never > > touched Ant so I am flying a bit blind here, but that shouldn’t matter > > if it all works as I don't need to touch the build process. > > > > I downloaded the ‘main’ branch from GitHub > > (https://github.com/apache/tomcat) and unzipped it into its own > > folder, again with Ant (apache-ant-1.9.16). > > > > I have managed to get Ant to build it using instructions in > > BUILDING.txt. While it says that Tomcat built successfully, scrolling > > up, I got lots of warnings saying ‘can’t find a module etc so not sure > > if doing something wrong. I can send the results as an attachment if > > that would be useful. > > > > I can also get it to build in Netbeans (I first had to set Project > > > Properties > Java Sources to Source Level 17 which may be a bit of a > > guess as Netbeans complained about default value of 1.7). The java > > files in Netbeans don’t highlight any exceptions, just warnings. > > > > I appear to have issues with the other two folders > > ‘C:\Community\Tomcat\tomcat-main\webapps\docs\appdev\sample\src\mypackage’ > > and ‘C:\Community\Tomcat\tomcat-main\test’ as they don’t seem to be > > able to locate the dependencies (HelloWorld is -e.g. import > > jakarta.servlet.http.HttpServlet & tests is -e.g. import > > org.junit.Assert). In Maven, I would add a dependency to the pom.xml > > file, but not sure what to do in Ant as I would expect the > > configuration to already be set up. > > Try this: > > 1. Close the project in NetBeans > 2. On the command-line, go to the directory where your Tomcat git > checkout is > 3. Run "ant ide-netbeans" > 4. Open the project again in Netbeans > > See if that improves anything. That ant target configures Netbeans in a > way that should be "helpful". I don't use Netbeans myself, but the > equivalent for Eclipse (ide-eclipse) sets up the build-path and lots of > other goodies. > > > I also ran the ‘ant test’, took about 90 minutes and failed a number > > of tests (which I thought was surprising as I would expect sources in > > the repository to pass all the te
Re: is too quick to respond
Hi, I have re-run the Tomcat tests using 4 cores (all my machine has!) and time came down to 35m 33s. Not bad. I have written my own ‘grep’ to review the output directory and I think that the number of failures has come down now using all the cores so some may have been timing issues The 5 that are reported are C:\Community\Tomcat\tomcat-main\output\build\logs\TEST-jakarta.servlet.http.TestHttpServletDoHeadValidWrite513.NIO.txt Tests run: 1152, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 57.275 sec C:\Community\Tomcat\tomcat-main\output\build\logs\TEST-org.apache.coyote.http2.TestStreamProcessor.NIO.txt Tests run: 9, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 4.282 sec C:\Community\Tomcat\tomcat-main\output\build\logs\TEST-org.apache.coyote.http2.TestStreamProcessor.NIO2.txt Tests run: 9, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 4.008 sec C:\Community\Tomcat\tomcat-main\output\build\logs\TEST-org.apache.jasper.runtime.TestJspRuntimeLibrary.NIO.txt Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 3.813 sec C:\Community\Tomcat\tomcat-main\output\build\logs\TEST-org.apache.jasper.runtime.TestJspRuntimeLibrary.NIO2.txt Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 4.242 sec I have attached the 5 txt files as listed above for review (if needed). The first one may still be a timing issue, but I am not in a position to judge! John On Fri, 18 Feb 2022 at 18:16, Mark Thomas wrote: > > > On 18/02/2022 18:01, John Barrow wrote: > >> Do you have a list of the tests which fail? Do you know how to get that > >> list? > > > > Yes, although I am on Windows, not UNIX and so I don't have access to > > grep. I did a simple search within logs for 'FAILED' and it came up > > with about 20 or so. The list of test results has been cleared now > > (probably when I next built Tomcat) and so I will need to run them > > again but will try using the threads at the same time and then send > > you the results in a separate email. > > If you haven't cleared out the results from the logs directory you can do: > > ant test-status > > Mark > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > <> - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: is too quick to respond
HI, As a completely 'left-field' thought and apologies if this next statement is completely naive, if I started a clean Maven project, copied across all the sources for Tomcat and then use NetBeans to add dependencies as required, could that work? I am willing to give it a try as I don't need to deploy my development version of Tomcat, I just need to be able to run it within NetBeans. Once I have finished any changes, I can export the amended sources to the downloaded copy from github, re-apply the changes (they will always be minor!) and then use the ant build script from the CMD to deploy the finished version so I can test it in place of the release version I am currently using for my other web development. Which brings me back to a question raised earlier, confirmation of which source file it is that launches Tomcat to display the CMD like monitor as there are 15 "main" entry points within the Tomcat sources. I am assuming that it is the one in Tomcat.java, which interestingly has the comment /** * Main executable method for use with a Maven packager. * @param args the command line arguments * @throws Exception if an error occurs */ public static void main(String[] args) throws Exception { indicating that perhaps Tomcat has been built using Maven! John - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: is too quick to respond
Hi, As mentioned in my last email, I have built a simple ‘Hello World’ Ant project in NetBeans, referencing an external library (GSON in my case) and the project properties looks quite different for the generated Ant project against the one that was created for Tomcat. The attached screenshot illustrates the differences (ignore the other unopened projects!) The 'Hello world' Ant project (source file attached) was created using the tools built into NetBeans so I - Created Java Application with Ant - Project name: HelloWorldAnt - Wrote the attached class - NetBeans flags up that com.google.gson library (jar) not found - Projects > HelloWorldAnt > Libraries - Locate gson-2.9.0.jar and open it - Library is added to the libaries folder within the project (as per screenshot) - Run project - compiles successfully and exports myLog to JSON in c:\Work\UserLogins.json (reproduced below). - I can also add breakpoints and step through the code during execution. The file structure for this simple Ant project looks a lot more complex than the one I am used to for Maven (see below). I am struggling to compare the two structures (HelloWorldAnt & Tomcat) as they look so different. While, I have not included any of the files in the directory structure listed below, happy to or upload the folder to DropBox. However, I think the exercise was more to determine that the Tomcat folder structure isn't as NetBeans would expect it for development to take place. Going to re-run the Tomcat tests and see if I can get a list of the failures in a suitable format. John Directory / File structure for created HelloWorldAnt project C:\Development\Work\HelloWorldAnt\build C:\Development\Work\HelloWorldAnt\build.xml C:\Development\Work\HelloWorldAnt\manifest.mf C:\Development\Work\HelloWorldAnt\nbproject C:\Development\Work\HelloWorldAnt\src C:\Development\Work\HelloWorldAnt\test C:\Development\Work\HelloWorldAnt\build\classes C:\Development\Work\HelloWorldAnt\build\classes\.netbeans_automatic_build C:\Development\Work\HelloWorldAnt\build\classes\.netbeans_update_resources C:\Development\Work\HelloWorldAnt\build\classes\helloworldant C:\Development\Work\HelloWorldAnt\build\classes\helloworldant\HelloWorldAnt.class C:\Development\Work\HelloWorldAnt\build\classes\helloworldant\HelloWorldAnt.rs C:\Development\Work\HelloWorldAnt\build\classes\helloworldant\TransactionLog$LocalDateSerializer.class C:\Development\Work\HelloWorldAnt\build\classes\helloworldant\TransactionLog$Transaction.class C:\Development\Work\HelloWorldAnt\build\classes\helloworldant\TransactionLog.class C:\Development\Work\HelloWorldAnt\nbproject\build-impl.xml C:\Development\Work\HelloWorldAnt\nbproject\genfiles.properties C:\Development\Work\HelloWorldAnt\nbproject\private C:\Development\Work\HelloWorldAnt\nbproject\project.properties C:\Development\Work\HelloWorldAnt\nbproject\project.xml C:\Development\Work\HelloWorldAnt\nbproject\private\private.properties C:\Development\Work\HelloWorldAnt\nbproject\private\private.xml C:\Development\Work\HelloWorldAnt\src\helloworldant C:\Development\Work\HelloWorldAnt\src\helloworldant\HelloWorldAnt.java gson (taken from my Maven .m2\repository) is referenced in project.properties in the following snippet excludes= file.reference.gson-2.9.0.jar=C:\\Users\\John\\.m2\\repository\\com\\google\\code\\gson\\gson\\2.9.0\\gson-2.9.0.jar includes=** jar.compress=false javac.classpath=\ ${file.reference.gson-2.9.0.jar} c:\Work\UserLogins.json file - { "KP": { "reference": "KP", "name": "Kevin Peters", "loggedIn": "2022-02-18" }, "MS": { "reference": "MS", "name": "Mike Smith", "loggedIn": "2022-02-18" }, "JB": { "reference": "JB", "name": "John Barrow", "loggedIn": "2022-02-18" } } From: Mark Thomas Sent: 18 February 2022 18:16 To: users@tomcat.apache.org Subject: Re: is too quick to respond On 18/02/2022 18:01, John Barrow wrote: >> Do you have a list of the tests which fail? Do you know how to get that list? > > Yes, although I am on Windows, not UNIX and so I don't have access to > grep. I did a simple search within logs for 'FAILED' and it came up > with about 20 or so. The list of test results has been cleared now > (probably when I next built Tomcat) and so I will need to run them > again but will try using the threads at the same time and then send > you the results in a separate email. If you haven't cleared out the results from the logs directory you can do: ant test-status Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: is too quick to respond
Mark,I checked the logs folder and it was empty and so I am assuming that Any is clearing it each time I build Tomcat.John Original message From: Mark Thomas Date: 18/02/2022 18:16 (GMT+00:00) To: users@tomcat.apache.org Subject: Re: is too quick to respond On 18/02/2022 18:01, John Barrow wrote:>> Do you have a list of the tests which fail? Do you know how to get that list?> > Yes, although I am on Windows, not UNIX and so I don't have access to> grep. I did a simple search within logs for 'FAILED' and it came up> with about 20 or so. The list of test results has been cleared now> (probably when I next built Tomcat) and so I will need to run them> again but will try using the threads at the same time and then send> you the results in a separate email.If you haven't cleared out the results from the logs directory you can do:ant test-statusMark-To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.orgFor additional commands, e-mail: users-h...@tomcat.apache.org
Re: is too quick to respond
Hi, > 3. Run "ant ide-netbeans" Apologies, I should have made that point clear, I have already run that otherwise Netbeans wouldn't recognise the project at all - i.e. I couldn't open it. In that respect, it was helpful, as in I could now compile and navigate the source files. > The "deploy" target is probably the one you want, or maybe "compile". Perhaps I am expecting a different outcome. The 'clean' + 'deploy' is what happens when I 'Clean and build main project' in Netbeans speak (checking the Projects properties dialog confirms this, see attached screenshot). What I was expecting 'Run project' to do, was locate the source with the "public static void main(final String[] args)" method in it and run the application, hopefully bringing up the Netbeans console window in a CMD like window (similar to running the .bat file %CATALINA_HOME%\bin\startup.bat). In Maven, this is what happens automatically when I 'Run project', I don't believe that I ever configured anything to execute a project from within Netbeans. The only slight variance is if NetBeans finds multiple main() methods, in which case you get a popup allowing you to select the appropriate starting point. So, perhaps, an alternative question would be, how do you go about making an amendment in Eclipse within the Tomcat sources (e.g. add a System.out.println() statement to log a field to the Eclipse 'console window' and then run Tomcat to see the effect. Also how do you run the Eclipse debugger on the Tomcat application? > Do you have a list of the tests which fail? Do you know how to get that list? Yes, although I am on Windows, not UNIX and so I don't have access to grep. I did a simple search within logs for 'FAILED' and it came up with about 20 or so. The list of test results has been cleared now (probably when I next built Tomcat) and so I will need to run them again but will try using the threads at the same time and then send you the results in a separate email. > If you can run the unit tests, then they are compiling and you should be able > to build a binary release (ant deploy) without a problem. I ran the tests from a CMD prompt rather than in NetBeans. NetBeans is telling me that it can't find the resources. A quick Google seems to imply that there should be a project.xml as well as a build.xml but then as I don't know Ant, I am not sure what to expect. I will attempt to create a simple 'Hello World' project in NetBeans using Ant to see what I get so I have a simple project to refer to as a base when trying to relate Tomcat. Without this, I couldn't review or extend the tests that form part of Tomcat as any attempt to run them within Netbeans tells me that the packages don't exist. Is there anyone else in the group that is successfully developing Tomcat using Netbeans? On Fri, 18 Feb 2022 at 17:03, Christopher Schultz wrote: > > John, > > On 2/18/22 10:50, John Barrow wrote: > >>> Would you be interested in looking at the existing algorithm to see if > >>> it would be updated in this way? > > > >> WebappLoader.backgroundProcess() would be a good place to start. > > > > I am sort of interested in looking at this. > > Awesome! > > > I have only been playing > > with Java for about 6 months, having been a Pascal developer most of > > my life (40 odd years). Therefore, I think that I could at least ‘give > > it a look’, if I can get Tomcat installed locally. > > > > However, I appreciate that I could be well out of my depth and there > > are too many unknowns / barriers in order to be of any use. > > > > It is the installation process that I am having issues with. I think > > it is down to lack of experience / knowledge / familiarity with > > commercial strength application. > > > > I use Netbeans 12.6 (Apache loyalty!) on Windows 10 for all my Java > > development using JDK 17. > > > > Unfortunately, I am only ‘sort-of’ familiar with Maven and have never > > touched Ant so I am flying a bit blind here, but that shouldn’t matter > > if it all works as I don't need to touch the build process. > > > > I downloaded the ‘main’ branch from GitHub > > (https://github.com/apache/tomcat) and unzipped it into its own > > folder, again with Ant (apache-ant-1.9.16). > > > > I have managed to get Ant to build it using instructions in > > BUILDING.txt. While it says that Tomcat built successfully, scrolling > > up, I got lots of warnings saying ‘can’t find a module etc so not sure > > if doing something wrong. I can send the results as an attachment if > > that would be useful. > > > > I can also get it to build in Netbeans (I first had to set Project > > > Properties > Java Sources to Source Level 17 which may be a bit of a
RE: is too quick to respond
Hi Mark / Christopher, Firstly, thanks for confirming my analysis on what is happening. >> Would you be interested in looking at the existing algorithm to see if >> it would be updated in this way? > WebappLoader.backgroundProcess() would be a good place to start. I am sort of interested in looking at this. I have only been playing with Java for about 6 months, having been a Pascal developer most of my life (40 odd years). Therefore, I think that I could at least ‘give it a look’, if I can get Tomcat installed locally. However, I appreciate that I could be well out of my depth and there are too many unknowns / barriers in order to be of any use. It is the installation process that I am having issues with. I think it is down to lack of experience / knowledge / familiarity with commercial strength application. I use Netbeans 12.6 (Apache loyalty!) on Windows 10 for all my Java development using JDK 17. Unfortunately, I am only ‘sort-of’ familiar with Maven and have never touched Ant so I am flying a bit blind here, but that shouldn’t matter if it all works as I don't need to touch the build process. I downloaded the ‘main’ branch from GitHub (https://github.com/apache/tomcat) and unzipped it into its own folder, again with Ant (apache-ant-1.9.16). I have managed to get Ant to build it using instructions in BUILDING.txt. While it says that Tomcat built successfully, scrolling up, I got lots of warnings saying ‘can’t find a module etc so not sure if doing something wrong. I can send the results as an attachment if that would be useful. I can also get it to build in Netbeans (I first had to set Project > Properties > Java Sources to Source Level 17 which may be a bit of a guess as Netbeans complained about default value of 1.7). The java files in Netbeans don’t highlight any exceptions, just warnings. I appear to have issues with the other two folders ‘C:\Community\Tomcat\tomcat-main\webapps\docs\appdev\sample\src\mypackage’ and ‘C:\Community\Tomcat\tomcat-main\test’ as they don’t seem to be able to locate the dependencies (HelloWorld is -e.g. import jakarta.servlet.http.HttpServlet & tests is -e.g. import org.junit.Assert). In Maven, I would add a dependency to the pom.xml file, but not sure what to do in Ant as I would expect the configuration to already be set up. I also ran the ‘ant test’, took about 90 minutes and failed a number of tests (which I thought was surprising as I would expect sources in the repository to pass all the tests. I can provide examples if useful as it may indicate that I have done something wrong. I read through the ‘RUNNING.txt’ file, but that assumes a binary to start, rather than following on from BUILDING Tomcat and so I couldn’t relate that to what I was trying to achieve. However, if I launch Tomcat from within Netbeans (F6), I get a dialog which I don’t understand - probably due to my lack of familiarity with Ant. Again, I can include a screenshot if that would help. [Run – Tomcat 8.0] No build target is associated with Run action. The free-form project requires a target Representing the Run action to invoke in Your Ant script. Select the target to invoke. [Dropdown with lots of tasks v] Is there an alternative document I should be reviewing to get me to actually run Tomcat from within Netbeans? I need to be able to run the locally built version of Tomcat so that, as a starting point, I can add some System.out.print() messages around the relevant routines (which I have located – thanks Mark). Of course I am assuming that it is possible to develop Tomcat from within Netbeans. While I would enjoy the challenge of reviewing the existing sources and attempting to incorporate a delay, I may waste more peoples time trying to get off the starting blocks. If that is the case, then I can raise a bug for future inclusion although it will be a pain-in-the-neck having to keep shutting down Tomcat after each compile! John From: Mark Thomas Sent: 17 February 2022 21:47 To: users@tomcat.apache.org Subject: Re: is too quick to respond On 17/02/2022 19:50, Christopher Schultz wrote: > This kind of thing could happen due to a number of different reasons, > such as a slow disk or network share, etc. and ought to be > protected-against. > > I haven't looked at the code, but I would imagine it periodically reads > all relevant files looking for anything that's been updated, but > immediately acts the first time is finds someting worth triggering a > reload. It does. The periodic check is triggered by the background process. > It might make more sense to modify that logic so that *all* files are > checked, but we cancel the reload if there are any files that are "too > new". This would allow us to avoid a reload if some kind of copy is in > progress. So we are looking for "anything newer than > last_reload_timestamp but not if we find anything older than NOW - 10 > seconds". Yes. We do something similar when checking for an update WAR file.
is too quick to respond
Hi, I am now running Tomcat version 10.0.16 having just upgraded from 9.0.41. As a developer, I make use of the META-INF\context.xml feature to detect changes within the classes folder WEB-INF\classes by However, since moving to Tomcat 10.0.16, the reload keeps crashing Tomcat due to the fact that Netbeans is recompiling multiple files and as soon as the first file is completed, I believe that Tomcat triggers its reload process and then fails as one of the listener classes is still in the process of being rebuilt by Netbeans and so Tomcat can’t access it for that split second to install the listener. If I shut down Tomcat and re-open it again, all is well as Netbeans has then had time to finish the re-compile. If I make a change within the implementation of (say) one of the listeners, so that Netbeans only has to re-compile that one .class file, then Tomcat reloads the application perfectly. Therefore, I was looking for the ability to add a delay to force Tomcat, on having detected a change in one of the files, to wait a moment to let Netbeans finish its job. I have researched the relevant help files and read through https://tomcat.apache.org/tomcat-8.0-doc/config/context.html and can’t see any additional attribute that might handle this scenario. If there isn’t an option, is it valid to raise it in the Bug Database? I have searched the existing list and can’t see any previous mention of it. For some reason, I didn’t experience this while using Tomcat 9.0.41, but it may have been slower to react to the .class files being change and so did not have an issue with the files not being available while they were being recompiled. The relevant part of the log is as below 17-Feb-2022 14:47:54.861 SEVERE [Catalina-utility-2] org.apache.catalina.core.StandardContext.listenerStart Error configuring application listener of class [Listener.DataDictionary] java.lang.ClassNotFoundException: Listener.DataDictionary at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1444) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1252) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:535) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:516) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:150) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4640) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5179) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3781) at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:268) at org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:5562) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1365) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1369) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1369) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1347) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.base/java.lang.Thread.run(Thread.java:833) 17-Feb-2022 14:47:54.861 SEVERE [Catalina-utility-2] org.apache.catalina.core.StandardContext.listenerStart Skipped installing application listeners due to previous error(s) Thanks in advance and here’s hoping to not have to have to keep Stopping & Starting Tomcat for every development change. John