Deploy the web application to tomcat

Yesterday, a web project was deployed to the local tomcat. The process was very difficult and various errors were reported. First of all, this project can be started with jetty embedded in eclipse, try to use tomcat container, various errors are reported. Here are the detailed steps:

1. Use eclipse to package the program, right-click the project --run as--run configurations --maven build--right click to create a new one, as shown below

 

2. Packing error: unmappable characters encoding gbk

Because my project is checked out from svn, and some files are compiled in gbk format, not utf-8, so add <encoding>utf8</encoding> to maven-compiler-plugin in pom.xml

<plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.0</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
          <encoding>utf8</encoding>
        </configuration>
</plugin>

 

3. There is a successful war package in the target folder of the project, but the configuration file in the webapp folder of the project is not entered into the package

There is a sentence Copying webapp resources [D:\workspace_armc_app3\armc-asi\WebContent] in the packaging log, which should be the configuration file in the webapp is placed in the webcontent folder, but after checking it, right-click the project --build path-- configure build path--Deployment Assembly, the files that have already set up the webapp are placed under the path "/", as shown in the figure

It turns out that there is <warSourceDirectory>WebContent</warSourceDirectory> in the pom.xml file, just comment it out, just fine

<plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.3</version>
        <configuration>
          <!-- <warSourceDirectory>WebContent</warSourceDirectory> -->
          <failOnMissingWebXml> false </failOnMissingWebXml>
        </configuration>
      </plugin>

4. Place the prepared war package in the webapps folder of the local tomcat

5. Start tomcat (cmd, go to apache-tomcat-7.0.82\bin, execute the command startup.bat, shut down tomcat with shutdown.bat)

6. Access http://localhost:8080/ succeeded
7. Failed to access http://localhost:8080/ project name, prompt 404, in order to see the error log in the eclipse console, I decided to set tomcat in eclipse

8. At this time, I modified the tomcat access port to 8081


9. Next, configure tomcat in eclipse, windows--preferences-tomcat

Write the configuration file armc-asi.xml under localhost

<Context path="/armc-asi" docBase="D:\workspace_armc_app4\armc-asi\src\main\webapp" reloadable="true">

        <Resource acquireIncrement="2" auth="Container" description="Oracle 11g Connection Pool" 
            driverClass="oracle.jdbc.driver.OracleDriver" 
            factory="org.apache.naming.factory.BeanFactory" 
            jdbcUrl="jdbc:oracle:thin:@ip:port:service-name" maxPoolSize="10" minPoolSize="2" 
             password="" type="com.mchange.v2.c3p0.ComboPooledDataSource" user=""/>
    
</Context>

 

10. Right-click the project, run on server, warning

Warning: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:armc-asi' did not find a matching property.
Solution: Double-click the server, Check publish module contexts...
11. Then report an error: The class cannot be found, but the jar package has been introduced. Later, it is found that some jar packages in the pom are provided, and you can comment them out. If there is provided, then the jar The bag will not go into the bag

<dependency>
<groupId>weblogic</groupId>
<artifactId>wlclient</artifactId>
<version>1.0.0</version>
<!-- <scope>provided</scope> -->
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>wljmsclient</artifactId>
<version>1.0.0</version>
<!-- <scope>provided</scope> -->

12. Then an error is reported:
Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
but the project has introduced ojdbc6.jar
because the ojdbc6.jar is not placed in D :\apache-tomcat-7.0.82\lib, after checking tomcat, it will only check the driver under its own lib.
13. Continue to report errors, double-click the server, and change the time limit. The default is 45.



14、继续报错
Exception in thread "http-bio-8081-exec-2" Exception in thread "http-bio-8081-exec-1" Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" Exception in thread "http-bio-8081-exec-3"
JAVA_OPTS="$JAVA_OPTS -server -XX:PermSize=128M -XX:MaxPermSize=256M"

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324970309&siteId=291194637