Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Problem with Project references in ECLIPSE IDE

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Eclipse IDE. I have created a new Web Project and created a Servlet. I also created a new Java Project and created a class(LogUtility.java) in it. I want to refer this Java Class from my Servlet.
So I refered my Java Project in "Java Build Path" in my Web Project.

Now I imported the Java class in my Java Project to the Servlet and invoked
a method in the java class from my Servlet.The Servlet class compiles fine. No error. But when choose to run the servlet, it is throwing the error:

java.lang.NoClassDefFoundError:LogUtility

I know that this error will be displayed if JVM is unable to find out the class in the class path. But I dont know how to resolve this error. I have tried creating the Jar file of that entire java project and adding the Jar file in web project's build path. But the result is the same.

Can anybody clear me why this error is occuring? How to resolve the NoClassDefFoundError while refering a Java Project from a Web Project
 
Bartender
Posts: 4107
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why you create a java project, inorder to use the utility (or whatever) classes in your web project. Can't you do the same thing by including utility classes in separate package within your web project?
[ November 27, 2008: Message edited by: Vijitha Kumara ]
 
Thirugnanam Saravanan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Why you create a java project, inorder to use the utility (or whatever) classes in your web project. Can't you do the same thing by including utility classes in separate package within your web project?


I want to reuse the java class present in a java project(Assume this class is being used in java project as well). If I move the java class to this web project, I may end up in duplicating the utility class in all the web projects(think in a real life project scenario).
Any body have ideas?
[ November 27, 2008: Message edited by: Thirugnanam Saravanan ]
 
Vijitha Kumara
Bartender
Posts: 4107
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it is not possible to use java project's class file (any way this should be deployed somewhere some how) the way you are doing.

I have tried creating the Jar file of that entire java project and adding the Jar file in web project's build path



Have you tried jar'ing classes (not the entire project) and put them in the class path. Then I think it will work.

Another option would be, use it as a web service (what ever the utility class' funtionality) though this may not what you are looking for
 
Thirugnanam Saravanan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vijitha,

Thanks for your suggestion. I resolved the problem by giving the reference to the java project in J2EE module Dependencies section in the Web Project's properties window. Now everything is working fine without even setting the class's jar file in build path.
 
Onion rings are vegetable donuts. Taste this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic