Eclipse Java EE+TOMCAT Issues and Apache integrated Tomcat

Source: Internet
Author: User
Tags tomcat server ultraedit apache tomcat microsoft iis
some issues with Tomcat 5x/6x in the Eclipse Java EE IDE (configuration, publish-related)

has always been the use of myeclipse, because the copyright is involved in the "Learning and Exchange" under the name of the use of myeclipse. But in real business development, the team takes into account the cost of the project and the needs of the project (efficiency or functionality), so that eclipse should be sufficient for some small and medium-sized projects, which is easier to say than the MyEclipse integrated IDE, but performance can be a factor to consider, So it's also a good option to use eclipse for development.

When you use a myeclipse developer to develop a Web project with Eclipse, you suddenly get used to it, and the Javaweb project becomes dynamic/static Web projects, After installing the Sysdeo Tomcatplugin, there are Tomcat Project. People are not used to it. In fact, from this you can understand the reason for the myeclipse charges: to be convenient, please spend money.

Here no longer boil over.

Recently used the Eclipse Java EE IDE +tomcat 5.5 development and deployment of a few small projects, some of the experience to share, many of them are on the Internet to check the text, but also solve a lot of problems, thanks to the help of netizens.

1. Deployment of WEB Project

Prerequisite: (1) The installation configuration good TOMCAT, environment variable, tomcat_home

(2) Configure the Eclipse IDE's installed JREs

(3) Make sure TOMCAT can run normally (%tomcat_home%/bin/startup.bat)

Build a simple Web project (such as Dynamic Web project), simply write, add a JSP, and so on, and how to publish it. Accustomed to open the Eclipse sever view, but there is nothing inside, right click on the new-->server, according to normal steps to establish. Once built, you will see the server's project in Project view and have your own configuration file. (There's a problem here, later.)

Then it's normal practice to run the project in Tomcat. Console inside display after normal startup, open the browser, enter the Tomcat home address test Tomcat ran without, such as Http://localhost:8080/, the result is 404, very surprising, and then check the Tomcat console, No problem. Trying to check the WebApp directory of%tomcat_home%, WebApp's root directory is resource-free, but the work directory does not have the items that have just been released. What's going on. A resource that attempts to access the Test project, such as Http://localhost:8080/Test/index.jsp, can be accessed normally. That's why.

It turns out that if you use the server and Tomcat created by Eclipse to publish a Web project, the default publishing path is not the original Tomcat installation path, but the road strength that eclipse sets itself, and the server's own configuration file. That is, the configuration file for the legend on the right above, so the related configuration is set here and the Tomcat settings will not take effect.

The server publishing path is: workplace\.metadata\.plugins\org.eclipse.wst.server.core\tmpx

Here workplace is the workplace of Eclipse, where X is named from 0, that is, when multiple services are configured

Ps. Explain just the input Http://localhost:8080/report 404 and access to project resources can be: Everyone knows Http://localhost:8080/this address the last "/" represents the root resource inside Tomcat's WebApp, The associated admin interface is inside the manager, which is tomcat default. But when the eclipse's server publishes the Tomcat Web project, it is equivalent to using a copy of Tomcat, which is handled in its own configuration when used, and all the information is replicated to workplace itself, but we find This replica tomcat (that is, the related configuration file behind the above figure) Web.xml and root directory (workplace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\ Wtpwebapps\root) will find that Web.xml is configured with <WELCOME-FILE-LIST>, but there are no resources in the root directory, so package 404 is normal. If you need it to display the TOMCAT homepage, it's OK to copy all the docs,manager,root directories to%tomcat_home% 's webapp.

Of course, it is also possible to modify this publishing directory. Double-click the configured Tomcat or right key-->open in the server view, and in the Overview tab you will see the configuration of the project, such as port, path, name, and so on, in server location This is the launch path for this tomcat container, modified as needed, and the default is the address of the workplace that was just mentioned. There is a problem here, when Tomcat has loaded the project can not be modified, you have to clean the tomcat, before you can modify.

This article is original, own experience, welcome to discuss study.

If you want to reprint, please indicate the source address. Thank you. cnblogs.com/lzsu1989

Tomcat Startup--Warning: [Setpropertiesrule]

2010-8-20 21:41:03 Org.apache.catalina.core.AprLifecycleListener Init
Serious: an incompatible version 1.1.9 of the APR based Apache Tomcat Native Library are installed, while Tomcat requires Versio N 1.1.17
2010-8-20 21:41:05 Org.apache.tomcat.util.digester.SetPropertiesRule begin
Warning: [Setpropertiesrule]{server/service/engine/host/context} Setting ' source ' to ' org.eclipse.jst.jee.server : WebDemo1 ' did not find a matching property.
2010-8-20 21:41:06 Org.apache.coyote.http11.Http11Protocol Init
Info: Initializing Coyote http/1.1 on http-8080
2010-8-20 21:41:06 Org.apache.catalina.startup.Catalina Load
Info: Initialization processed in 5730 ms
2010-8-20 21:41:07 org.apache.catalina.core.StandardService Start
Info: Starting service Catalina
2010-8-20 21:41:07 org.apache.catalina.core.StandardEngine Start
Info: Starting Servlet engine:apache tomcat/6.0.26
2010-8-20 21:41:10 Org.apache.coyote.http11.Http11Protocol Start
Info: Starting Coyote http/1.1 on http-8080
2010-8-20 21:41:11 org.apache.jk.common.ChannelSocket Init
Info: jk:ajp13 Listening on/0.0.0.0:8009
2010-8-20 21:41:12 Org.apache.jk.server.JkMain Start
Info: Jk running id=0 time=0/968 config=null
2010-8-20 21:41:12 Org.apache.catalina.startup.Catalina Start
Info: Server Startup in 5414 MS
2010-8-20 21:43:31 Org.apache.catalina.core.StandardContext Reload
Info: Reloading This context has started

Solution:

Double-click Tomcat v6.0 Server at localhost to open the Tomcat v6.0 Server at Localhost-config dialog box

1. On the server Option option, check the public moudle context to spareate XML files

2. Reboot Tomcat after this warning: [Setpropertiesrule] There is no

Apache Integrated Tomcat

First, starting from the general framework of Java EE Project

This is a universal web that is the B/S project architecture, which consists of:

Üweb Server

Üapp Server

Üdb Server

Consisting of three major parts, of which:

²web Server

Outside of the corporate firewall, this firewall, you can think of as a Cisco router, and then opened on the Cisco router two ports are: 80 and 443.

Port 80: For normal HTTP access

Port 443: For HTTPS access, that is, if you enter an address such as https://xxx.xxx.xx in IE, the default

This is the port of 443.

Webserver specializes in:

For parsing HTML, JS (JavaScript), CSS, jpg/gif and other picture format files, TXT,

VBSCRIPT, PHP and Everything "static" page content.

²app Server

Within the enterprise firewall, the connection between it and the Web server must be and must be an internal IP connection.

External IP: That is, the Internet IP address, our Web server will generally have an internal IP an external IP, so here, our app server does not have any external IP, only the internal IP, so I'm here to say app server and web Server can only be connected in the form of internal IP.

For example, we use Tomcat, its port is 8080, then this IP address on the 8080 port can only be accessed by any internal IP, the external Internet is not accessible, this is done for security.

App server resolves any of our "dynamic" Web pages that require a Java compiler to parse, but app server itself can parse any static web pages.

So let's think about this:

We let the Web server, which is responsible for parsing static Web pages, parse HTML and so on, and let app server specifically parse anything that requires a Java compiler to parse, and let them "two" do their respective roles. The benefits of this:

1 for app Server "decompression", but also improve the performance

2 do not have to expose 8080 of this port on the Internet, but also very safe, must be our app server but have our code, even if the compiled code is easy to "decompile", which is very unsafe.

3) Lay the groundwork for further "cluster expansion" in the future

²db Server

Let's say we're using Oracle, and it needs to connect to app server through 1521. So this 1521 is called a database connection port, and if you expose it to the Internet, it's a bit dangerous. Even if our passwords are complex, it is only a matter of time before a smart hacker can break your password.

So we're putting our DB server in the same firewall as app server. Any DB connection and management can only be accessed through intranet, within the corporate enterprise, that is the truth.

Second, the hands to the structure

 

2.1 Oracle data plus installation and configuration

DB (Oracle) I'm ready for you. The connection information is:

IP:

10.225.10x.xx

Port:

1521

Username/password:

xxx/xxx

Sid:

Jcoedb1

URL:

Jdbc:oracle:thin:@10.225.10x.xx:1521:xxx

So, according to the above framework, we can throw a list of the following to NSS or the relevant network management department, let them open the corresponding port:

Web Server

Foreign IP:xxx.xxx.xxx.xxx
Internal Ip:10.225.xxx.xxx

Open 80 and 443 ports to the Internet

App Server

Internal Ip:10.225.xxx.xxx

only for 10.225. Segment of the IP open 8080,8009 and other ports,

Db Server

Internal Ip:10.225.xxx.xxx

Open 1521 ports only for 10.225-segment IP

Installation of 2.2 APP server

Directly decompression tomcat to your local such as: D:\tomcat, my side of the directory called TOMCAT2, everyone at will, the best name can be as simple as possible d:\tomcat or c:\tomcat on the line, do not put too "deep."

Installation of 2.3 Web server

Here we will install the Apache for Win 2.2.x, which will occupy your machine's 80 and 443 ports. So if you have any program on your machine that occupies your 80 and 443 ports, you must turn it off, for example:

We have Microsoft IIS, which is also a webserver, so please turn it off:

Controlpanel->administrative Tools->service, locate the IISAdmin and, close it all down and set the startup mode to: manual so that you don't have to manually close it after each reboot.

Then use Netstat–ano to find any program that is still taking up 80 ports and turn it off.

2.4 Start installing Apache Http Server

We will install this version of Apache HTTP server as the Web Server we have been using for the future


server name Here you want to fill in the real name of your own server, can not use me this, this servername such as: shnlap93.cts.com only can I use, this name is the global unique, and your IP.


Select All Installation


After loading you will have one more such icon, click on the icon, which has to control the Apache HTTP server to start, stop and restart operation options. At the same time in your "services" panel, you can also find such a service item, it started by default when the system started, we change it to "manual", because in the future we will install IBM Http Server for practice.

After loading, in the premise of Apache2.2 start, open an IE input http://localhost, you will get such a page, it shows that your Apache installation is successful.


2.5 Apache Configuration

The person who learns Java, must be this Apache configuration, otherwise how you simulate environment, build environment and architecture environment. The light will coding is not enough, you will always only be a code farmer ... Hey, heh. A lot of people find that the back of Java can not learn, the key factor is: configuration.

You will be equipped with the environment, then you can simulate any client side, the developer's environment.

You will be equipped with the environment, your code will be online in the future to run successfully.

You will be equipped with the environment, so the whole technical core of the project is you.

Following my tutorial, you will be installing and running hundreds of different software and configurations, making you smell a stink.

Are you ready for this?

Of course, don't be afraid, because my configuration is the actual operation of the environment, so some things on the internet you can not go to see, because a lot of people are in the online copy, copy, and sometimes not verified, will let you go a lot of detours end up with a bug day world, see my tutorial.

The Apache configuration focuses on the httpd.conf file, which is located in your installation directory, such as:

D:\tools\httpd\conf\

We open it with UltraEdit or related text editing tools to see its contents:

First find the following line:

#ServerName

We can get the following line of content:

#ServerName shnlap93.cts.com:80

This is our hostname, we can remove the front "#" and change it to:

ServerName 10.225.106.35:80

Save and save, before restarting your Apache2.2, let's test our Apache configuration file for correct:


If you click Test Configuration, the black screen flashed over, indicating that your changes are correct, otherwise this black screen will stay in the current state, and tell you that your configuration changes are wrong, where.

Restart your Apache.


Find the following line:

DocumentRoot

You will be sending out a line of content like this:

DocumentRoot "D:/tools/httpd/htdocs"

This is called DocumentRoot, which is Webroot, that is: Publish a directory, any project published in this directory will be loaded into the standard Web project when the Apache service is turned on, so let's start by positioning the Webroot into our own publishing directory.

DocumentRoot "D:/www"

We changed it to the WWW directory in D, and then we put a index.html file in the directory, which reads:

Restart our Apache service to test:


Hey, what have we got. No access, why.

Find the following paragraph:

<directory/>

Options FollowSymLinks

AllowOverride None

Order Deny,allow

deny from all

</Directory>

See, No.

Now, change this "deny from" to "Allow Fromall".

<directory/>

Options FollowSymLinks

AllowOverride None

Order Deny,allow

allow from all

</Directory>

Restart your Apache service after you have finished modifying


Ok, our Apache publishing directory has been successfully changed to the D:\www directory, let's do an experiment:

We enter in IE browser: http://localhost/css/, what we see.


This is also good, users if it is a beginner hacker can know what files on our server, which directories can even directly see our file content, how to do.

Find the line below.

Options followsymlinks Indexes

Take it off and change it to the bottom.

#Options followsymlinks Indexes

Options None

Don't worry, look down, and

Options Indexes FollowSymLinks

Another one, and then get rid of it.

#Options Indexes FollowSymLinks

Options None

Restart your Apache service after these two changes are completed

Open a new IE again, input: http://localhost/css/, we see the following interface:


Well, Apache's basic configuration is complete:

1 Basic Security Configuration, directory access is not allowed

2) Change the Webroot to another physical directory without using Apache's own Webroot directory

2.6 Integrating Apache with Tomcat

Apache (Web Server) is responsible for processing HTML static content;

Tomcat (App Server) is responsible for handling dynamic content;

In fact, this is a framework, the following is the principle

1 Apache is equipped with a module called MOD_JK

2 Apache is responsible for resolving any static Web content through 80 ports

3 Any unresolved content, use the expression to tell mod_jk, let mod_jk distributed to the relevant app server to explain.

Through the above text description we can know:

1 We need to install a mod_jk in Apache first.

2 We need to write a point expression in httpd.conf

below to implement.

1 the mod_jk-1.2.31-httpd-2.2.3.so manual copy into our Apache installation directory modules directory, the file's full name: Mod_ Jk-1.2.31-httpd-2.2.3.so, you can get from the ftp "/javaarchitect/mod_jk/" directory, because this file is I use C + + in the local recompile, the online download is src is the source code, Save the time for everyone to compile, and some other online downloads of mod_jk.so are not available.

2 with UltraEdit open httpd.conf file, run to the end of the file to add the following lines:

LoadModule Jk_module modules/mod_jk-1.2.31-httpd-2.2.3.so

Jkworkersfile conf/workers.properties

Jklogfile Logs/mod_jk.log

<virtualhost *>

ServerAdmin localhost

DocumentRoot d:/www/

ServerName localhost

DirectoryIndex index.html index.htm index.jsp index.action

ErrorLog Logs/shsc-error_log.txt

Customlog Logs/shsc-access_log.txt Common

Jkmount/*web-inf ajp13

Jkmount/*j_spring_security_check ajp13

Jkmount/*.action ajp13

jkmount/servlet/* ajp13

Jkmount/*.jsp ajp13

Jkmount/*.do ajp13

Jkmount/*.action ajp13

Jkmount/*fckeditor/editor/filemanager/connectors/*.* ajp13

jkmount/fckeditor/editor/filemanager/connectors/* ajp13

</VirtualHost>

The key is the two sentences:

LoadModule Jk_module modules/mod_jk-1.2.31-httpd-2.2.3.so

Jkworkersfile conf/workers.properties

Represent:

Üapache loads an additional plug-in to connect Tomcat.

The configuration parameters of the connection are described in a workers.properties file in the/conf directory of the Apache installation directory, and MOD_JK is typically connected using the AJP13 protocol, using Tomcat's 8009 port.

3) The contents of the Worker.properties document are as follows:

Workers.tomcat_home=d:/tomcat2

workers.java_home=c:/jdk1.6.32

ps=/

Worker.list=ajp13

worker.ajp13.port=8009

Worker.ajp13.host=localhost

Worker.ajp13.type=ajp13

4 tells us Apache, which is to be given to Tomcat to resolve, in addition to the Apache itself to resolve :

<virtualhost *>

ServerAdmin localhost

DocumentRoot d:/www/

ServerName localhost

DirectoryIndex index.html index.htm index.jsp index.action

ErrorLog Logs/shsc-error_log.txt

Customlog Logs/shsc-access_log.txt Common

Jkmount/*web-inf ajp13

Jkmount/*j_spring_security_check ajp13

Jkmount/*.action ajp13

jkmount/servlet/* ajp13

Jkmount/*.jsp ajp13

Jkmount/*.do ajp13

Jkmount/*.action ajp13

Jkmount/*fckeditor/editor/filemanager/connectors/*.* ajp13

jkmount/fckeditor/editor/filemanager/connectors/* ajp13

</VirtualHost>

As you can see, all/servlet/* are parsed by Tomcat, all JSP,. Do,. Action is resolved by Tomcat.

There is also a special/fckeditor, this is a blog editor we use, because it is a servlet, so also need to give Tomcat analysis.

5)/cbbs the project to the WebApps directory of Tomcat

6) will/cbbs also manually copy a copy to the D:/www directory

7 Delete D:/www/cbbs/web-inf This directory, hey, because the d:/www under the things are resolved by Apache, all the Web-inf under the Java, we only need to be in Tomcat under the can, is not.

8 Restart Tomcat, restart Apache, direct input in IE: Http://localhost/cbbs, use SALLY/ABCDEFG login, operation, all successful

Oh...yeah, Tomcat+apache one step to fix.

Iii. Cbbs Engineering configuration for the experiment

Finally, attach the configuration that Cbbs need to use, the related works can be obtained by Cbbs.zip under the ftp "/java architect/project/".

U open server.xml in tomcat join:

<resource

Driverclassname= "Oracle.jdbc.OracleDriver"

factory= "Org.apache.commons.dbcp.BasicDataSourceFactory"

Maxactive= "maxidle=" maxwait= "5000" name= "Jdbc/eltds"

password= "XXX"

Type= "Javax.sql.DataSource"

Url= "JDBC:ORACLE:THIN:@10.225.101.51:1521:JCOEDB1"

Username= "xxx"/>

And

<context crosscontext= "true" docbase= "D:/upload" path= "/uploadpic" reloadable= "true"/>

<context docbase= "Cbbs" path= "/cbbs" reloadable= "true"/>

• Manually create a upload directory in the D-Packing directory, and create an image directory within this directory.

U open context.xml join in Tomcat

<resourcelink name= "Jdbc/cbbsds" type= "Javax.sql.DataSource" global= "Jdbc/cbbsds"/>


How Apache and Tomcat are integrated

Introduction to three ways to connect Apache HTTP Server with Tomcat

Consolidating Apache Http server and Tomcat can improve processing performance for static files, leveraging WEB servers for load balancing and fault-tolerant, seamless upgrade applications. This article describes three ways to integrate Apache and Tomcat.

Let's start by introducing why you want to connect Apache to Tomcat. In fact, Tomcat itself already provides the HTTP service, which has a default port of 8080, and you can change the port to 80 by installing Tomcat and using 8080 ports to run the application directly from Tomcat.

Since Tomcat itself can provide such services, why do we have to introduce Apache or some other dedicated HTTP server? There are several reasons for these:

1. Improve the processing performance of static files

2. Use Web server to do load balancing and fault tolerance

3. Seamless upgrade of applications

These three points are very important to a Web site, we want our site to be not only fast, but also stable, not because of a Tomcat downtime or upgrade program to cause users can not access, but to complete these functions, the best HTTP server is only Apache HTTP Server, it is the closest and most reliable combination of Tomcat.

Next we'll introduce three ways to integrate Apache and Tomcat together.

Jk

This is the most common way you can find a lot of web pages about configuring JK on the Web, and of course the most complete or the official documents provided. JK itself has two versions are 1 and 2 respectively, the current 1 latest version is 1.2.19, and version 2 has been abandoned, there will be no new version of the launch, so we recommend that you use version 1.

JK communicates with the Tomcat server through the AJP protocol, and the port of the Tomcat default AJP Connector is 8009. JK itself provides a monitoring and management of the page jkstatus, through Jkstatus can monitor the current working status of JK and the connection to Tomcat settings, as shown in the following figure:

Figure 1: Page jkstatus for monitoring and management

In this diagram we can see that the current JK is equipped with two connections to 8109 and 8209 respectively.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.