[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tomcat-user
Subject:    Re: ClassNotFoundException - Involving a class implementing Filter and two projects depending on ano
From:       Léa_Massiot <lmhelp1 () orange ! fr>
Date:       2015-03-30 8:17:31
Message-ID: 551906D5.2080908 () orange ! fr
[Download RAW message or body]


On 3/30/2015 2:36 AM, Tim Watts-3 [via Tomcat] wrote:
> 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.

Ok. Thank you.
--
Léa




--
View this message in context: \
http://tomcat.10.x6.nabble.com/ClassNotFoundException-Involving-a-class-implementing-Filter-and-two-projects-depending-on-another-oe-tp5032615p5032638.html
 Sent from the Tomcat - User mailing list archive at Nabble.com.



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic