This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

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: 4101
64
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: 4101
64
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.
 
He's my best friend. Not yours. Mine. You can have this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!