I am using Jasper reports in my application for generating reports.
I have also provided the facility to download the reports in Pdf/Csv format.
But the problem I am facing is that, whenever I upload a new war file
(with or without the changes in the JRXML files used for designing the reports) I have to start/stop the tomcat server. Unless I do that, I am not able to generate the reports. There are no logs seen nothing happens and the
reports are not generated as well. As soon as I restart the server, everything starts working like a charm. Reports get generated and everything else is fine. Why is this so? Why do I have to restart the server every time I upload a new war file? And this is a random behaviour.
Its not always necessary to restart the server the moment new war file is uploaded, it may be required to restart the server after some time.
(But it has to be restarted once in the new war's lifetime)
Is there any bug in Jasper reports regarding this behaviour?
How can I avoid this server-restart issue?
You can configure reloadable contexts in server.xml but it only monitors /WEB-INF/classes/ and /WEB-INF/lib. If you want to re-deploy your webapp you can restart tomcat as you are doing or use tomcat manager
Related
I have a Java web app that I run on an Azure App Service instance. To deploy it, I use a Bitbucket repo with a .war file inside it. When I commit a new .war file to this repo, it is supposed to be deployed automagically by the service. However, more often than not, I have to either restart, re-deploy, or even upload the .war file via FTP for the deployment to be completed successfully.
I have a single Jetty instance residing in this service, hence my .war file is named ROOT.war. AFAIK, when uploaded to the service (whether via Bitbucket or FTP), this .war file should be unarchived into the same directory, which is /site/wwwroot/webapps. In my case, this doesn't happen. The web app works with the ROOT.war file sitting alone inside /site/wwwroot/webapps. And every once in a while, I get a ROOT folder under /site/wwwroot/webapps, with two default files index.jsp and background.png. I don't have the slightest idea what causes the ROOT folder to appear with these default files. The only clue I have is that it happened a couple of times after I changed an environment variable.
Also after the ROOT folder appears with the empty server files, the only way I can re-deploy the app is to manually delete this ROOT folder via FTP or the console provided in the portal, and only then my re-deploy request succeeds with my web app.
So, if it isn't clear enough, my question is what is going on here? I can't make anything out of the behaviors I'm facing. I feel like I'm using this Azure service blindly, and can't get to fix anything when something goes wrong. Are there any resources that may explain what happens in the background when a web app is deployed?
So, Azure API Apps are a PAAS, not IAAS service. You can access the PaaS platform by coming to yoursite.scm.azurewebsites.net, where you can browse the file system in CMD or Powershell, and you can see the running processes. This may feel like you are on a single VM, but you are not. The data you see here is replicated down into your API App instances. You can control how many instances you have through scaling your API App.
I have commonly seen your issue with deploying, then ROOT being empty(working internally to see this fixed...).
The best method that works every time for me, is to stop your API App, manually UNZIP your ROOT.war. Move the files into /ROOT/, then to start your API App.
You can simply place ROOT.war, and let the system unpack it when you turn it back on, but this can sometimes lead to that empty ROOT directory, then requiring another restart.
All of this has me moving to Spring-Boot instead. No unpacking required. Simply configure your web.config and drop the jar file.
https://learn.microsoft.com/en-us/azure/app-service-web/web-sites-java-custom-upload#springboot
I had the same problem. The solution is to call the endpoint after de deploy.
Stop the Azure App Service.
Deploy the ROOT.war artifact in the /webapps folder.
Start the Azure App Service.
Call the URL of the App Service once.
The four-step is very important and start the process that you mentioned before (the automagically deploy).
I lost a lot of time figuring out what was the problem.
I export my maven java project in Eclipse to War file.
On the server, I open the manager of tomact and add the war application, but when I run the application it seems the application isn't running (or some problem with the resources).
From the other hand, when I start the tomcat by the startup.bat in the tomcat folder and add the War to the webapps folder, it is working. But if I logoff the server , I cannot connect the application remotly. The server is shut down. Why?
What can be the problems?
Thanks!
Me
Why is your application not running? Well - if there's a specific reason for it (and the manager application works) you will see it in the logfile - e.g. tomcat's log/catalina.out. Check it or give us a snippet of the error messages in there if you don't understand them.
I like to recommend not to use the manager application, rather deploy through the OS or any other maintenance tool (e.g. scripted). This typically results in a better maintainable system. As it already works well for you when you just add your WAR file to the webapps directory, everything seems well. Introducing a manager application in production just provides another means to attack your site - and I frequently see those applications poorly maintained (and the passwords poorly chosen & protected)
When you start tomcat with startup.bat, it will run the server process in a console window. This console process will be shut down when you log out. In order to have tomcat running even when you're not logged in (and in order for it to start automatically), you'll have to install it as a service. There's plenty of information on the internet on how to do this - should be extremely easy to find.
Why do we use external tomcat server while working in the industry though there is support for the server in the Eclipse?
Previously I was using the server integrated with the eclipse itself. But now as a part of the industry I've started using the external tomcat server.
The reason we use external server during development is that the server integrated with Eclipse works most of the time but not all of the time. This you will notice when there are multiple number of web application being deployed as part of the development in your Eclipse and you start and stop Tomcat a number of times to refresh web applications in rapid succession. The problems that can happen are:
1) Source/WAR files updated but deployed application does not update
2) Tomcat throws exception during start within Eclipse
3) A web context becomes unavailable from within eclipse
all the above are not limitations of either eclipse or tomcat, since we change the deployables in rapid succession, sometimes the WAR files get corrupted while exporting or old remnants of previously deployed files remain within tomcat work/localhost directory.
In general this kind of errors become difficult to determine. the best way to avoid them is to have a separate tomcat and export the WAR to the webapp directory, even then it is good to clear the work/localhost directory from time to time.
I have a simple web application which lets the user upload local user data and then they can generate HTML reports from that uploaded data. Once the HTML is generated, I display a link to the report which they can click on to view in their browser or they can share the link with others.
The problem is that I am currently putting the "/Upload" folder in the "WEB-INF" folder because I don't want that folder data accessible to the outside world. I am then putting the "Reports" folder in the root directory of the web application. This work fine in that I can deploy the WAR file to the their server, the user can upload the files, and then request for HTML reports to be generated. The problem is that when I send them software updates in the WAR file it deletes everyone in the /MyWebApp directory including the /Upload and /Reports folder. So then the user has to re-upload the data and they loose any of their existing reports in the "/Reports" folder.
Now I did find an answer for the /Upload folder on StackOverflow with this discussion.
Where can I put an uploading folder so that when I deploy/undeploy the site in Tomcat that folder won't be affected
But I still don't know where to put my "/Reports" folder? I thought I would have to put it in the web application context directory as I am doing now in order for the Tomcat server to serve it up as a link (e.g.: http://example.com/MyWebApp/Reports/report01.html).
The other thing to note is that this application is running on Apache Tomcat only, I don't have the request going through an Apache server. We decided to just have it running on the users local server with Tomcat because it seems easier to deploy then trying to deploy and configure both to work together. Also, there are only 2-3 people using this application per server site and with that load Tomcat seems to be doing a great job handling everything on its own. So maybe that is making the solution more difficult?
Any hep with best practices for this would be greatly appreciated.
There should be no difference between the strategy you used for placing uploaded-files on the disk with placing reports on the disk: both are files that were generated by the webapp during its deployment (forget the fact that a client uploaded the file) and need to be protected in the same way.
If you are willing to upgrade to Tomcat 7, there is a new <Context> attribute, aliases, which will allow your webapp to serve content from that directory but not delete it when the webapp is undeployed.
I am using JSF2.0 and Glassfish v3.
I have a ValidatorMessage.properties file under WEB-INF>Classes folder of my project.
When I make any changes to messages in this file, through my project, its changes are not reflected.
I access this messages through <f:loadBundle var="msg" basename="ValidationMessages"/>
Are there any configurations to be made in Glassfish or my project side?
P.S.-> the same functionality works under Jetty 7.0.0pre3
Please comment if question is not clear..
There is no need to restart the server when you make change in a properties file.
I often do changes in my files for internationalization and i don't need to restart.
I don't know what IDE do you use, but i use eclipse and there i have an option when i double click on Glassfish application server to automatically publish when changes are detected(See image below). I think that is what you are looking for.
Also there is a podcast from oracle that mentions it(time 2.04)
http://www.youtube.com/watch?v=ppGqtOeHm-g&feature=related