JavaRush /Java Blog /Random EN /Overview of Application Servers and of course Tomcat
eGarmin
Level 41

Overview of Application Servers and of course Tomcat

Published in the Random EN group
Dear Javarashians, what do I want to consider in this article? I just want to make a short overview of that part of application servers that deserve attention at least because they are free and their source code is available. I will assume that your system is similar to mine. I have Windows 7 64 bit, in addition I have JDK 1.7 and JDK 1.8, and the JAVA_HOME environment variable refers to the latter of them. In my case, this means that the JAVA_HOME path is C:\Program Files\Java\jdk1.8.0_31. Overview of application servers and, of course, Tomcat - 1So that when you repeat what is described below, you have as few questions as possible like “why didn’t it work for me, maybe I’m doing something wrong?”, I will try to describe every action that I did on my machine. Begin…

Casting, i.e. selection

First we need to select application servers for our review. To do this, look at the Wikipedia article Comparison of application servers (English, because there is no other one). There is a sign with a bunch of application servers, but of interest to us are only those that, on the one hand, are open source, and on the other, fully support JavaEE, i.e. The Java EE compatibility column in this table must contain a line of type Full Platform . From this list, which contains both WildFly and JBoss , you can immediately throw out the latter, because it's just an old name and old versions of WildFly . As a result, we get the following list of servers that deserve our attention:
  1. Glassfish (not proprietary, but the one from the glassfish.java.net community , but which is supported by Oracle Corporation to such an extent that if you need a javaEE SDK from the Oracle website, then they will give you this application server, otherwise there is no other way)
  2. (Red Hat) WildFly (formerly JBoss)
  3. (Apache)Geronimo
  4. (Apache) Tomcat (this is just a servlet container, not an application server, but it is the standard on which, if the program is written correctly, it will definitely work. On other servers, the program may be written correctly in terms of JavaEE, but everything will work it will either be incorrect or not at all. I’m talking about Geronimo, the glitches of which can be discussed for a long time)
Now let's pump up these servers. Where it was possible to choose between 32 and 64-bit versions, I chose an archiver for my 64-bit system.

Installation

In terms of installation, everything is simple and for each of the selected servers, installation is simply unpacking the archive. For example, I created the AppServers folder on my desktop, where I began to unpack everything.

Settings

Let's start setting up servers by setting up the HTTP port on which it will work. Then we will register ourselves as the server administrator. Each server has its own configuration features. For Tomcat. We go to the folder with unpacked tomcat, then the conf folder , the server.xml file . We find the number 8080 (default http port) in this file and change it to whatever we want. I set it to 9713 . To register yourself as a server administrator, you need to open the tomcat-users.xml file while in the same folder . In it, before the closing tag </tomcat-users>, add the following tag <user username="egarmin" password="1" roles="manager-gui,manager-script,manager-status,manager-jmx"/> where in your I have assigned the maximum number of administrative rights (roles) to the roles. This will allow me to deploy applications both through the gui and through a remote connection. Now let's launch tomcat. Go to the folder with unpacked tomcat, then the bin folder and run the startup.bat file . Go to the browser at http://localhost:9713 . Everything should work and we will see the tiger. TomcatNow let's check if you have access to the admin panel. To do this, go to http://localhost:9713/manager , enter the selected login and password and gain access. Administrator in TomcatHOORAY! You can temporarily disable Tomcat by simply closing the console in which it is running. For Glassfish. Go to the folder with the unpacked glassfish , then to the glassfish subfolder , then to the domains subfolder , then to the domain1 folder . Go to the config folder and find the domain.xml file . There we also look for the number 8080 (this number is generally the default HTTP port for application servers and servlet containers) and change it to whatever we want. I set it to 9813 . Let's launch glassfish. Go to the folder with the unpacked glassfish, then to the glassfish subfolder , then to the bin folder . Run the startserv.bat file . In the browser, enter the address http://localhost:9813 . On the ugly page that appears with the title GlassFish Server, find the link to go to the Administration Console and click on it. First login to GlassFishNext, having got to the beautiful page of the administrative console built on JSF, click the Change Administrator Password Administrator in GlassFish item and enter the password we need for the admin user , then confirm it and click the Save button. Changing your password in GlassFishWhen you subsequently log in to the administrative console, you will need to enter the admin login and the specified password. Login to the GlassFish admin panel using a passwordNow you can temporarily disable Glassfish by simply closing the console in which it is running. For WildFly. Go to the folder with the unpacked wildfly . Next, go to the standalone folder , then the configuration folder , and in it the standalone.xml file . Next we proceed according to the established scheme. I set the port to 9913 . Let's start the server. To do this, let's go to the folder with the unpacked wildfly . Next, go to the bin folder and run the file standalone.bat . Open the browser and enter the address http://localhost:9913 . First login to WildFlyClick the Administration Console link to enter the admin console (in other words, the admin panel of the application server). But that was not the case, because... the screen pops up. First login to the WildFly admin panelThis screen tells us that the admin has not been created, and to create it we need to use the console utility add-user.bat . Well, if it’s necessary, it’s necessary. We return to the bin folder and run this utility. First, you will be asked to select the type of user we want to create. We need to select item (a) , which will mean that we need an admin. Then you are asked for the name of this user Username and password Password . The password cannot be empty, but one character is welcome. The utility will of course scold, but will swallow it if you answer yes to the question “Are you sure?” Next, confirm the password by re-entering the Re-enter Password request . Then there will be more questions, but we simply answer them all in the affirmative and exit the utility. Returning to the page above, find the Try Again link and click on it. Now, by entering the details of the newly created admin, you can get to the admin panel. Administrator in WildFlyWe shut down the server by closing the console window through which it was launched. For Geronimo. Go to the folder with unpacked geronimo . Next, go to the var subfolder , then to the config folder , and in it the config-substitutions.properties file . This file describes all the ports used by the application server in a convenient format, but the port replacement scheme is the same. I set the port to 10013 . Let's start the geronimo server . Let's go to the folder with unpacked geronimo , then to the bin subfolder and run the startup.bat file there . Go to the page http://localhost:10013. What do you think? Most likely, the page will not be there. Why? The thing is, the latest version of Geronimo (3.0) cannot work with the latest version of the JDK (1.8), so if you only have it or even have, say, the 7th version, but the JAVA_HOME environment variable still refers specifically to 8th, like mine, the application server will not start. Thus, for Geronimo to work, you must download JDK 1.7. Now let's say you installed the 7th JDK, but do not want to change the value of the JAVA_HOME variable (after all, other programs do not complain about it, which means they can work with the latest version of the JDK). What to do? I recommend opening the setjavaenv.bat file located in the same bin folder and looking for the line labeled :okJdkFileCheck . Then on the next line add an environment variable override. For example, like this: set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_75 This line is not there, so please write it yourself. If you have a 32-bit system, then there should be no more problems. Moreover, if you have a 64-bit system and you installed JDK 1.7 in the 64-bit configuration, then everything is fine for you too. Now let’s imagine that we decided to be perverted and install JDK 1.7 from the 32-bit line on a 64-bit system (I have, for example, Windows 7 64). What then? Then you will have to tinker some more, because in a 64-bit system there are two folders for installing programs: Program Files and Program Files (x86) and if you don’t change anything, the 32-bit JDK will go into the latter. What's so scary about that? Yes, it seems okay, however, if the JAVA_HOME variable has brackets in its path (x86), then Geronimo gets indigestion. Why? God knows, especially considering that according to the forums, this error should have been fixed in the 3rd version of Geronimo . But nothing like that. The main thing in this matter is not to pee-pee, if the Indians did not correct it, then we will correct it. There are two ways to do this, which I prefer to combine to be sure. Firstly, again go to the setjavaenv.bat file and find the already mentioned label :okJdkFileCheck . Under this label there is a line if "%JRE_HOME%" == "" if exist "%JAVA_HOME%\bin\javac.exe" (set JRE_HOME=%JAVA_HOME%\jre) else set JRE_HOME=%JAVA_HOME% in which to cure Geronimo It will be enough to put the substring JRE_HOME=%JAVA_HOME%\jre in quotes, i.e. replace the entire line with if "%JRE_HOME%" == "" if exist "%JAVA_HOME%\bin\javac.exe" (set "JRE_HOME=%JAVA_HOME%\jre") else set JRE_HOME=%JAVA_HOME% . Also, remember or be aware that folders like Program Files in Windows 7 have synonyms (for example, for the folder C:C:\Progra~2 ). Therefore, if you in the file setjavaenv.bat after the label :okJdkFileCheck set the following value of the variable JAVA_HOME set JAVA_HOME=C:\Progra~2\Java\jdk1.7.0_75 then you will also have a Geronimo server running a 32-bit JDK in a 64-bit x bit operating system. Something like this... Well, finally, you can launch Geronimo by calling startup.bat . Now there shouldn't be any problems. Go to the page http://localhost:10013 in the browser . At the top left, find the Console link and click on it. GeronimoYou need to enter your admin username and password. Let me tell you right away that this is the system user with the password manager (default values). Login to the Geronimo admin area using a passwordBy going to the console itself and following the menu items as in the picture below (select the Advanced radio button , then select Security > Users and Groups ), you can either change the password for the system user or create another admin user and delete this one. Changing your password in GeronimoYou can also stop the Geronimo server by simply closing the console window in which the server was running.

Conclusion

In this review, I basically just went through the installation and initial configuration of popular application servers and the Tomcat servlet container. With the exception of Geronimo, the rest of the servers were very friendly and hospitable to me. In the next post, I will continue to consider application servers and take the 3rd step towards considering web services, namely, I will show how to deploy the web service described in the first step into these servers. To do this, we will create a war archive of our web service, and I will clearly show that the set of third-party jars that must be included in this archive for the service to work correctly varies greatly from server to server.
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION