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.
Related
I am coding my basic servlet programs in notepad but every time I make changes in my java file and after compiling it, I need to restart my tomcat apache to see that changes on browser. Is there any solution for this as I have to work on project and will need changes frequently.
I have tried making service automatic from services manager.
The changes made in Servlet/Java code will not reflect itself, we have to re-compile the Java code and again deploy the application to the Tomcat server. Only after these work server will be able to get the modified values.
If you don't want to do it manually then you can set reloadable="true" in the context.xml file. Now Catalina (tomcat server) will 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.
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.
I am trying to deploy a JSP/servlet onto a server. Not tomcat but on a real web domain. This is my first time doing so and so far I exported it into a war file and placed the file onto the server. Nothing happened which is why I am here. All the google searches seem to concentrate on Tomcat which I have already ran the project on. Advice?
Ok, let's get really basic. You want to see the compiled JSP in a browser, through some public URL, right?
First, find a place to host your application. You can try Digital Ocean (starts at $5/mo), EATJ (free version available), Amazon AWS (free trial available), OpenShift (free gears available), your own computer with dynamic DNS, or many other options available through Google.
Next, you packed your compiled code to a war file. That war file needs to be unpacked (deployed) using some software.
There are numerous ways to handle this (Tomcat, Jetty, Glassfish, etc.). They all have their pros and cons. Pick one and learn the very basics. Tomcat doesn't require a separate web server but you can set one up with it if you like. At this stage, I would keep it simple and not do that yet.
Lastly, set up GoDaddy (or whomever you used to get your URL) to point to the IP address of that server. If your server is running and enough time has passed for the changes to propagate, you should see your page.
There are plenty other J2EE server for example, JBoss and Glassfish. Each one has it's own way to deploy your war files. For example, Glassfish is throught a web administration console (https://docs.oracle.com/cd/E19798-01/821-1757/6nmni99aj/index.html) and in JBoss you need to deploy the war file in a specific directory (http://docs.jboss.org/jbossweb/3.0.x/deployer-howto.html).
It depends on which J2EE server you are using.
Now if you want to get your own server and configure it:
Get the server or VPS
Install JAVA
Install Apache
Install a J2EE server (I prefer glassfish)
Configure glassfish with apache (http://www.codefactorycr.com/glassfish-behind-apache.html) to use apache in front of glassfish
You may want to block the ports 4848 and 8080 used by glassfish
Deploy your webapp
Have fun!!!
PS: I'm assuming you have root access to the server
Easy Apache Tomcat 7 install after,
Run Code via SSH:
/usr/local/cpanel/scripts/addservlets2 --domain=domain.com
For Linux.
We have two separate web projects for our application
One for Spring REST services
Other for AngularJS, the front end of the application.
We have been using eclipse for development of both and also for running those locally on tomcat server.
It is a great deal of pain to view updates to JavaScript and CSS part of the second project from eclipse, because it requires restart or publish of the tomcat server every time which takes a long time.
So I wanted to use eclipse for development of REST and front-end development editor like Brackets for development of AngularJS/JavaScript and CSS. But then they run on different ports causing Cross Site requests errors, and I don't want to write any CORS filter like this for this purpose.
Is there any better way to get these tools work together ?
Spring Tool Suite (STS) uses the pivotal tc server will automatically deploy resources without redeploying the application. Download it and give it a go, STS is just eclipse anyway with different branding. Maybe you can just download it, copy the pivotal server folder to your eclipse folder and add it to your servers view in your eclipse version. One thing I have noticed is that the application must be running under a context for this to work, deploying to root does not automatically deploy resources for some reason (at least this was the case when I was using the previous vfabric server about a year ago).
So I'm really new to the Java webstack world, and had a question on the most efficient solution to my problem. Some background information first; I'm running Tomcat on a Lubuntu 14.04 server listening on Port 80, developing on a separate Windows computer in Spring Tool Suite (developing Spring applications obviously). Currently, whenever I want to test something, I...
1) Export the project as a WAR file from Spring Tool Suite
2) Undeploy the old WAR file from the server from the Tomcat manager webapp
3) Deploy the new WAR file that I just got from Spring Tool Suite (which takes ~15 seconds)
Is there any faster way to do this? Normally, I wouldn't be opposed to just developing on localhost. However, I'm going to be doing a group project, so we would all need access to the same SQL server, which would be the one hosted on the Lubuntu 14.04 server.
How can I solve this issue?
Most IDEs have the ability to deploy to server for both development and production purposes.
Those that don't have this ability inbuilt, ususally have a add-on that enables this.
You can also use build tools such as maven or gradle to undertake these actions.
Since you raised a good point of working with others it is important that all are across the deployment process and that the process is standardised to ensure no weird issues/bugs pop up.