On Sun, 2015-03-29 at 12:56 -0400, Tim Watts wrote:
> On Sun, 2015-03-29 at 18:06 +0200, Lmhelp1 wrote:
> > On 3/29/2015 5:36 PM, André Warnier [via Tomcat] wrote:
> > > Lmhelp1 wrote:
> > >
> > > > Hello,
> > > >
> > > > Thank you for reading my post.
> > > >
> > > > I am getting a "ClassNotFoundException".
> > > >
> > > > Below is the situation.
> > > > - I'm working with "Eclipse" ("Luna"), "Tomcat 8" and "Java 8".
> > > > - I have three projects "project1", "project2" and "project3".
> > > > - "project1" and "project2" depend on the third project "project3".
> > > >   In "Project -> Properties -> Java Build Path -> Projects", I added
> > > > "project3" for both projects "project1" and "project2".
> > > > - "project3" is a "Java project".
> > > > - "project1" and "project2" are "Dynamic Web Projects".
> > > > - "project3" defines the class "MyFilter" which implements "Filter" and
> > > > which I put in the package "my.package".
> > > > - "project1" contains a "web.xml" file which contains the following
> > > > elements:
> > > >   [...]
> > > >   <filter>
> > > >     <filter-name>MyFilter</filter-name>
> > > > <filter-class>my.package.MyFilter</filter-class>
> > > >     <init-param>
> > > >       <param-name>requestEncoding</param-name>
> > > >       <param-value>UTF-8</param-value>
> > > >     </init-param>
> > > >   </filter>
> > > >   <filter-mapping>
> > > >     <filter-name>MyFilter</filter-name>
> > > >     <url-pattern>/*</url-pattern>
> > > >   </filter-mapping>
> > > >   [...]
> > > > - "project2" contains a "web.xml" file which contains the following
> > > > elements (same as in "project 1"):
> > > >   [...]
> > > >   <filter>
> > > >     <filter-name>MyFilter</filter-name>
> > > > <filter-class>my.package.MyFilter</filter-class>
> > > >     <init-param>
> > > >       <param-name>requestEncoding</param-name>
> > > >       <param-value>UTF-8</param-value>
> > > >     </init-param>
> > > >   </filter>
> > > >   <filter-mapping>
> > > >     <filter-name>MyFilter</filter-name>
> > > >     <url-pattern>/*</url-pattern>
> > > >   </filter-mapping>
> > > >   [...]
> > > >
> > > > When running a JSP of "project1" on the "Tomcat" server, I get the 
> > > error:
> > > > SEVERE: Exception starting filter MyFilter
> > > > java.lang.ClassNotFoundException: my.package.MyFilter
> > > >
> > > > There are no errors at build time.
> > > >
> > > > I just would like to mention that I'm working with "Tomcat 8" for the
> > > > first time.
> > > > It used to work with "Tomcat 7" but I might have done something more to
> > > > make it work... I don't remember what...
> > > >
> > > > What can I do to solve that problem?
> > > > Please let me know if you need additional information or if I'm not
> > > > clear enough.
> > > >
> > >
> > > I do not really know how to translate this for Eclipse but if this was 
> > > a stand-alone
> > > Tomcat, the way you describe it above, project1 and project2 (when 
> > > deployed) should also
> > > have the class available under their respective
> > > (catalina_base)/webapps/projectX/WEB-INF/classes/ directory (or 
> > > /WEB-INF/classes/lib/, if
> > > in a jar). Is it the case ?
> > 
> > Thank you for your answer.
> > 
> > No, it is not the case.
> > - There are no ".class" files from "project3" under "classes" 
> > directories for the two projects "project1" and "project2".
> > - I didn't make a ".jar" file out of "project3" because I don't want to 
> > have to do it every time I change the code of the classes in "project3"...
> > 
> > Note - If I do not add "project3" via "Project -> Properties -> Java 
> > Build Path -> Projects" for both projects "project1" and "project2" I 
> > get hundreds of errors. So clearly this is a required setting...
> > I don't know what is missing...
> > 
> > Thank you for helping me.
> > Best regards.
> > --
> > Léa
> 
> In Eclipse, try Project / Properties / Deployment Assembly.  Add project
> 'project3'.  It should add project3's resulting jar file to WEB-INF/lib
> or resulting classes to WEB-INF/classes depending on how project3 is
> configured.

UPDATE: The 2nd part of that sentence is not true; it will always add
the resulting jar file of project3.  However, it will create jar file on
the fly when the webapp is re/deployed OR when project3 is modified.

Keep in mind that this is simply a quick & dirty way of testing the app
from within Eclipse and NOT suitable for building a deployable war file.
You should use Maven or Ant or etc. for that.

> 
> Note that I'm using the Maven plug-in so this may be a consequent
> feature of the plug-in, I'm not sure.

This feature does not appear to require the Maven plug-in.

> 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> > For additional commands, e-mail: users-h...@tomcat.apache.org
> > 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to