MyEclipse compiling the source file Tomcat explains the. class file mechanism

Source: Internet
Author: User


a scene:

In SVN download the latest version of the project, start MyEclipse Tomcat, found an error, unable to find the SPRINGMVC configuration file, and then put the root directory resource folder under the source code output directory. Start again and similar to the error found in the file, and then modified the build path--configure build Paht, the SRC and resource two directories (their own project to write all the source code) are placed in the source output sources location. You have changed the location of the class input file. The result is another error ... The error is as follows:

Severity: Exception starting filter SecurityFilterjava.lang.ClassNotFoundException: Com.cdvcloud.programedit.web.filter.SecurityFilterat Org.apache.catalina.loader.WebappClassLoader.loadClass ( webappclassloader.java:1720) at Org.apache.catalina.loader.WebappClassLoader.loadClass (Webappclassloader.java : 1571) at Org.apache.catalina.core.DefaultInstanceManager.loadClass (defaultinstancemanager.java:529) at Org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged (defaultinstancemanager.java:511) at Org.apache.catalina.core.DefaultInstanceManager.newInstance (defaultinstancemanager.java:139) at Org.apache.catalina.core.ApplicationFilterConfig.getFilter (applicationfilterconfig.java:258) at Org.apache.catalina.core.applicationfilterconfig.<init> (applicationfilterconfig.java:105) at Org.apache.catalina.core.StandardContext.filterStart (standardcontext.java:4809) at Org.apache.catalina.core.StandardContext.startInternal (standardcontext.java:5485) at Org.apache.catalina.util.LifecycleBase.staRT (lifecyclebase.java:150) at Org.apache.catalina.core.ContainerBase.addChildInternal (containerbase.java:901) at Org.apache.catalina.core.ContainerBase.addChild (containerbase.java:877) at Org.apache.catalina.core.StandardHost.addChild (standardhost.java:632)



two MyEclipse Some of the file descriptions

Let's start with a description of some of the operations in MyEclipse, as shown in:


The description is as follows:

1. Source Tab

source folders on Build Paht: Sets the root output path of the. Java source file

Default output folder: The project source file is compiled by the MyEclipse compiler to generate the. class file, which is configured with the. class file output path. (PS: For Java WEB projects, the default source file directory: Project name/src output directory: Project name/webroot/web-inf/classes. For simple Java project, the default output path is different: project name/bin. )

2. Projects tab

Whether it is related to other projects, such as the introduction of two other projects in the Projects tab, so that when we import the project, we can import the two items we just introduced. and view the project's. classpaht file, the file contents are as follows.

<?xml version= "1.0" encoding= "UTF-8"? ><classpath><classpathentry kind= "src" path= "resource"/> <classpathentry kind= "src" path= "1"/><classpathentry kind= "con" path= "org.eclipse.jdt.launching.JRE_ CONTAINER "/><classpathentry kind=" con "path=" melibrary.com.genuitec.eclipse.j2eedt.core.MYECLIPSE_JAVAEE_6 _container "/><classpathentry kind=" con "path=" Org.eclipse.jst.j2ee.internal.web.container "/>< Classpathentry kind= "Con" path= "Org.eclipse.jst.j2ee.internal.module.container"/><classpathentry Combineaccessrules= "false" kind= "src" path= "/BSS"/><classpathentry combineaccessrules= "false" kind= "src" path = "/vms2.0"/><classpathentry kind= "Output" path= "Webroot/web-inf/myclasses"/></classpath>
This allows us to introduce the class files in the BSS and other packages in the vms2.0 project.

3. Libraries Tab

used to manage the class libraries used in the project, including the JDK's own and the JRE's own jar, as well as the third-party jar we introduced ourselves, to add and remove the class library.

4. Order and Expor tab

Priority: The better the call priority, the better it will be called from top to bottom, such as the package name and the class name of two items, which are invoked according to this priority (this article validates this view). Tick and uncheck, the difference is that the project when the war package will be the jar is also packaged in the box.


three project generation file descriptionEvery new project we create, as the project builds. Classpath,. MyMetadata,. Project three files, these three files are described below.

. classpath file


This file is automatically changed when we modify the Java build Paht.

. mymetadata file

<?xml version= "1.0" encoding= "UTF-8"? ><project-module  type= "WEB"  name= "Pgmedit_record" id= "  myeclipse.1416988570034 "  context-root="/pgmedit_record "  j2ee-spec=" 6.0 "archive=" Pgmedit_  Record.war ">  <attributes>    <attribute name=" Webrootdir "value=" WebRoot "/>  </ Attributes></project-module>

Obviously, here is the project name, project default access, project package default name, Project Access default path Webroot.

. project file

Do not paste content, similar, including the project name, the compiler specifies the loading content and some core features.


Four default rules for MyEclipse


1, we can arbitrarily change the source code placement, but no matter where to put in the Java build Paht-"source.

2, tomcat explanation. class file, the default location is the file in the Project--web-inf--class folder.

When I change the output class to my own MyClass, I start Tomcat and the program will give an error. Look at the classess file under the Web-inf of Tomcat, there are no class classes, and when I copy the compiled class and XML files under MyClasses to this directory, I can run them.

This shows that the MyEclipse compilation path can be modified without specification, but Tomcat must be placed under Web-inf in classes when interpreting the. class file, so that Tomcat can find what to run.


Five Summary

careful observation, no solution can not solve the problem, give everyone a small sweet sound, wish to live happily
If you can't play it, click here




MyEclipse compiling the source file Tomcat explains the. class file mechanism

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.