Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Class not found(Eclipse debug says source not found)
Class not found [message #950050] Fri, 19 October 2012 15:29 Go to next message
Alan Farroll is currently offline Alan FarrollFriend
Messages: 60
Registered: June 2012
Member
Hello,

I have taken over an Eclipse project from a previous employee and attempting to create a walkthrough class to provide a "main" method so I can use breakpoints to step through the other classes and methods. Previously there was no "main" method because the project was accessd via a web service.

I have my "main" method set up and call to the first function coded and no red lines but when I attempt to instantiate the first object I am told "source not found". How do I rectify this please.

Thanks in advance

AJF
Re: Class not found [message #950165 is a reply to message #950050] Fri, 19 October 2012 17:32 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 10/19/2012 9:30 AM, Alan Farroll wrote:
> Hello,
>
> I have taken over an Eclipse project from a previous employee and
> attempting to create a walkthrough class to provide a "main" method so I
> can use breakpoints to step through the other classes and methods.
> Previously there was no "main" method because the project was accessd
> via a web service.
>
> I have my "main" method set up and call to the first function coded and
> no red lines but when I attempt to instantiate the first object I am
> told "source not found". How do I rectify this please.
>
> Thanks in advance
>
> AJF

This is all sorts of wrong. There are two things you could do here to
accomplish what I think you're trying to do.

First, if there are JUnit tests, you could run those in debug and step
through them. If the application was written correctly, there are JUnit
tests that, at very least, demonstrate the business logic of the
application by way of the principal classes. These should not require
the wire or the database, but they will inject dependencies correctly
and meaningfully.

(However, testing--usually the lack of it--is the devil's playground, so...)

Second, as it's a web application, you could break in the one or more
entry points at its top stopping there after launching it as a web
application using a server container such as Tomcat or whatever the
original author intended.

Both of these plans require that you understand the architecture of this
application. Attempting to instantiate random classes from the
application in a main() doesn't fill me with confidence that you
wouldn't be wasting your time even if you somehow got some of them
properly injected with required dependencies. It's just a lost cause.
Re: Class not found [message #953548 is a reply to message #950165] Mon, 22 October 2012 10:38 Go to previous messageGo to next message
Alan Farroll is currently offline Alan FarrollFriend
Messages: 60
Registered: June 2012
Member
Hello Russell,

Thanks for your feedback. I am quite new to Eclipse and Java so bare with me.

Yes the original author created this to run as a WAR file in Tomcat, and there is a WSDL with several web service requests to the methods in the WAR file. So how do I go about breaking the running of the code at the start of each web service requests? I also have SoapUI to test the web service requests and output.

Thanks in advance

AJF
Re: Class not found [message #953770 is a reply to message #953548] Mon, 22 October 2012 14:15 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 10/22/2012 4:38 AM, Alan Farroll wrote:
> Hello Russell,
>
> Thanks for your feedback. I am quite new to Eclipse and Java so bare
> with me.
>
> Yes the original author created this to run as a WAR file in Tomcat, and
> there is a WSDL with several web service requests to the methods in the
> WAR file. So how do I go about breaking the running of the code at the
> start of each web service requests? I also have SoapUI to test the web
> service requests and output.
>
> Thanks in advance
>
> AJF
The easist way to debug a web application that runs on Tomcat is to run
the application in Eclipse over Tomcat. You download and associate
Tomcat with Eclipse and run your application from within the workbench.
If you do not know how to associate Tomcat with Eclipse, read this:

http://www.javahotchocolate.com/tutorials/setup-tomcat.html

(Unless you specifically know what version of Tomcat you want to use,
I'd suggest 6 at this point.)

I assume your web application is already set up in Eclipse.

Once Tomcat is associated with Eclipse, create a new Server:
1. File -> New -> Other.
2. Scroll down to Server and choose Server, click Next.
3. Choose the version of Tomcat you associated with Eclipse. click Next.
4. Double-click your application to move it from the left pane to the
right pane, click Finish.

At this point, you should have a) Server in your Project/Package
Explorer view (leftmost pane in workbench). You should also see, perhaps
in the bottom pane, a Servers view with the server inside that you set up.

Right-click the server, probably "Tomcat v6.0 Server at localhost", in
the Servers view. This will involve

a) Eclipse publishing your application (as if it were a WAR) to
<workspace>/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps
just as if this subdirectory were tomcat/webapps where the WAR file is
dropped.

b) running the application using your web.xml as a guide; if this is
wrong, there will be trouble.

Once up and running, you can set breakpoints where you think execution
will wander and stop. This is the main point of your asking this question.

To get things going, use the client application or a browser to hit your
applicaion via the URL, probably
http://localhost:8080/<projet-name>/etc. I can't say what this is.

If the port's already in use, you would have gotten an error when you
launched Tomcat, go back to the Servers view, double-click the Tomcat
server which will bring up a configuration page. Change the port to
something else like 8000 and save, relaunch the server, retry your
application with the new port number.

This is all pretty complicated for beginning Eclipse users. You should
be asking questions about web programming in the Eclipse web tools
platform forum instead of this one. You may also contact me directly for
help if you like. I'll take you as far as I can. I have some experience
with SOAP and WSDL, but not much and it's pretty old now.

Best,

Russ
Re: Class not found [message #954474 is a reply to message #950050] Tue, 23 October 2012 02:54 Go to previous messageGo to next message
Brent Pathakis is currently offline Brent PathakisFriend
Messages: 1
Registered: October 2012
Junior Member
Russell,

You may also want to look at step filters:

Windows > Preferences

Click on java > debug > step filtering.

Try enabling it and selecting the defaults (java.* and java.lang.clasLoader). I haven't worked on webapps, but by default eclipse will try to step into all classes .. including 3rd party ones.

Hope this helps. Smile
Re: Class not found [message #958904 is a reply to message #953770] Fri, 26 October 2012 10:01 Go to previous messageGo to next message
Alan Farroll is currently offline Alan FarrollFriend
Messages: 60
Registered: June 2012
Member
Hi Russell

I apologise for not replying sooner but I have other projects that require my attention.

I have set up the server as per your instructions, but I am confused at the point in your instructions - "Right-click the server, probably "Tomcat v6.0 Server at localhost", in the Servers view. This will involve";

I can right click on mine, which is Tomcat v7.0 Server at localhost, but what do I do next.


Also, should I adjust the configuration in the way Brent Pathakis explains too?

Thanks again for your assistance

Regards

AJF

Re: Class not found [message #959148 is a reply to message #958904] Fri, 26 October 2012 13:41 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 10/26/2012 04:01 AM, Alan Farroll wrote:
> Hi Russell
>
> I apologise for not replying sooner but I have other projects that
> require my attention.
>
> I have set up the server as per your instructions, but I am confused at
> the point in your instructions - "Right-click the server, probably
> "Tomcat v6.0 Server at localhost", in the Servers view. This will involve";
>
> I can right click on mine, which is Tomcat v7.0 Server at localhost, but
> what do I do next.
You choose Debug to launch the service, then you engage the service via
some means, a separate client program, a web browser, etc. such that
breakpoints are hit. Be sure that at least one of the breakpoints you
set will be hit otherwise you'll be disappointed and left wondering
whether it works. Choose a really trivial breakpoint if you have
to--anything that will get the pump primed after which you can finesse it.

> Also, should I adjust the configuration in the way Brent Pathakis
> explains too?
I'm unfamiliar with what's under Brent's advice never having used it at all.


Note that it's also possible to debug your application running remotely.
It's certainly an advanced skill, but it's possible under the right
conditions. When you get to that point or want to confuse yourself even
more, check out:

http://www.javahotchocolate.com/tutorials/eclipse-debugging.html


What you might want to do before much longer is find some nice, easy
tutorials on Eclipse, Debugging and Web Applications that will give you
a sure and successful experience. Doing them will help you overcome your
lack of familiarity with the Eclipse workbench, the various components
of a web application and how to debug through it. Some great tutorials
can be found at www.vogella.de, probably elsewhere too.
Re: Class not found [message #959163 is a reply to message #959148] Fri, 26 October 2012 13:51 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

> What you might want to do before much longer is find some nice, easy
> tutorials on Eclipse, Debugging and Web Applications that will give you
> a sure and successful experience. Doing them will help you overcome your
> lack of familiarity with the Eclipse workbench, the various components
> of a web application and how to debug through it. Some great tutorials
> can be found at www.vogella.de, probably elsewhere too.

I particularly recommend the following in your case. (Mind you, I'm
making a hasty judgment based on this thread. You may not in fact need
these.)

Basic Eclipse/Java debugging:
http://www.vogella.com/articles/EclipseDebugging/article.html

This one's a lot of work:
http://www.vogella.com/articles/JavaServerFaces/article.html

Maybe this one is less work, plus there's a lot of explanation going on.
After going through it, you'll definitely start to grok the whole web
application thing.*
http://www.javahotchocolate.com/wtp-tutorials/wtp-tutorial.html


* Your SOAP/WSDL stuff is common, but very old technology. Most of us
are using ReST now. Lars Vogel used to have a great tutorial
demonstrating SOAP/WSDL, but he dropped it from his site. I did the
tutorial at the time and saved the source code and project. Contact me
directly if you want me to zip them up and send them to you (although
except for comments I may have put into the files, there's no tutorial
or explanations).

Not sure if this will help, but you're welcome to my notes on using soapUI:
http://www.javahotchocolate.com/tutorials/soapui.html

Best of luck to you.

Russ
Re: Class not found [message #963282 is a reply to message #959148] Mon, 29 October 2012 17:52 Go to previous messageGo to next message
Alan Farroll is currently offline Alan FarrollFriend
Messages: 60
Registered: June 2012
Member
Hi Russell,

Thanks again for your response and advice. No, I appreciate the links you also forwarded and will follow up the tutorials. As I said I was involved in Unix projects and Unix scripting for the past few years and new to Java after being handed this project.

When you say "choose debug to launch the service", when I right click on the server I have set up I have no basic debug option I have "Debug as" awhich has a submenu of Debug Javascript and Debug configurations. Please find attached the screen dump of the configurations.

Although, when I right click on the actual project folder and this provides a Debug As with a sub menu that includes Debug on Server. However, when I selected this option I get the message of "Server Tomcat v7.0 Server at localhost failed to start."
(I ensured the ports the server is using are free ones). But I think this was because I was also running Tomcat locally outside Eclipse.

The next attempt it seemed to start but then provided a message stating;

HTTP Status 404 - /projectname/

--------------------------------------------------------------------------------

type Status report

message /projectname/

description The requested resource (/projectname/) is not available.

------------------------------------------------------------

My question is what should I do now? Was I doing this correctly?

Thanks for yoru patience, advice and feedback

AJF
Re: Class not found [message #963325 is a reply to message #963282] Mon, 29 October 2012 18:33 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 10/29/2012 11:52 AM, Alan Farroll wrote:
> Hi Russell,
>
> Thanks again for your response and advice. No, I appreciate the links you also forwarded and will follow up the tutorials. As I said I was involved in Unix projects and Unix scripting for the past few years and new to Java after being handed this project.
>
> When you say "choose debug to launch the service", when I right click on the server I have set up I have no basic debug option I have "Debug as" awhich has a submenu of Debug Javascript and Debug configurations. Please find attached the screen dump of the configurations.

Sorry, you must choose first Add and Remove... to add your project to
the server, then Debug. This will launch Tomcat in the Console window.

> Although, when I right click on the actual project folder and this provides a Debug As with a sub menu that includes Debug on Server. However, when I selected this option I get the message of "Server Tomcat v7.0 Server at localhost failed to start."
> (I ensured the ports the server is using are free ones). But I think this was because I was also running Tomcat locally outside Eclipse.

Yes, right-clicking on one of your source files or the project and
choosing to run on the Server is a way to launch, just not the optimal way.

> The next attempt it seemed to start but then provided a message stating;
>
> HTTP Status 404 - /projectname/
>
> --------------------------------------------------------------------------------
>
> type Status report
>
> message /projectname/
>
> description The requested resource (/projectname/) is not available.
>
> ------------------------------------------------------------
>
> My question is what should I do now? Was I doing this correctly?
Once you're running as a service (first interwoven answer), you can
begin hitting the service.

If you get 404 back, it usually means there's something out of whack
between the environment and your project's web.xml.

I would suggest you get Tomcat running in the Console which, if you've
added your project, it will do using your web.xml. Then try hitting it,
from a client application, the browser, whatever.

Russ
Re: Class not found [message #967344 is a reply to message #963325] Thu, 01 November 2012 17:48 Go to previous messageGo to next message
Alan Farroll is currently offline Alan FarrollFriend
Messages: 60
Registered: June 2012
Member
Hi Russell,

Thanks again for all your help. I am getting somewhere now. At least slowly. I am managing to get the Tomcat server running within Eclipse and setting a break point and hitting the break point by running a call to the web service using SoapUI.

I can step through some code but always appear to eventually be told messages such as "source not found" or "class not found. Attach source". See attached image.

Can you advise on what best to do to be able to step through all the code without getting these messages.

Thanks again for your patience.

AJF
Re: Class not found [message #967390 is a reply to message #967344] Thu, 01 November 2012 18:28 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 11/1/2012 11:48 AM, Alan Farroll wrote:
> Hi Russell,
>
> Thanks again for all your help. I am getting somewhere now. At least slowly. I am managing to get the Tomcat server running within Eclipse and setting a break point and hitting the break point by running a call to the web service using SoapUI.
>
> I can step through some code but always appear to eventually be told messages such as "source not found" or "class not found. Attach source". See attached image.
>
> Can you advise on what best to do to be able to step through all the code without getting these messages.
>
> Thanks again for your patience.
>
> AJF
>
You're running into code that's in a JAR, in this case, the catalina
JAR, that you don't need to debug through (in particular, catalina is a
Tomcat thing). So, you'll be learning what's yours (and therefore what
you want to step through) versus what's not yours (and therefore what
you hope just works and don't have to worry about).

When you reach something that's in a third-party JAR, just step over it
either with F6 or by setting another breakpoint and continuing
(F8-Resume) to it.
Re: Class not found [message #968639 is a reply to message #967390] Fri, 02 November 2012 16:22 Go to previous messageGo to next message
Alan Farroll is currently offline Alan FarrollFriend
Messages: 60
Registered: June 2012
Member
Hi Russell,

I have a good grip of this debugging thing now I think. I will still continue to learn through. I have found that when I get to a point in the code that states "source not found" or "class not found" whatever, if I press F7 on the Eclipse I am using it goes back to the previous point and I can then F6 past it.

Thanks so much for all your help. One change I did make though was in the Eclipse server setup for Tomcat I changed it to use the JDK and not the JRE. What difference will this make? One thing that did change was that when I started the server in Eclipse the "HTTP Status 404 - /projectname/" did not occur. When this error appeared previously, you suggested it was something in the Web.xml file but I could not tell what was wrong in the web.xml file.

In regards to entering into Jar's that are third party, i.e Catalina and other Tomcat components, is there a way I can go into the source to see how things happen? Reason I ask is that this project involves using HTTP sessions and that is what I must learn next. Maybe you have some links you could give me on that one.

Thanks again for your assistance

Regards

AJF
Re: Class not found [message #968661 is a reply to message #968639] Fri, 02 November 2012 16:44 Go to previous message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 11/2/2012 10:22 AM, Alan Farroll wrote:
> Hi Russell,
>
> I have a good grip of this debugging thing now I think. I will still
> continue to learn through. I have found that when I get to a point in
> the code that states "source not found" or "class not found" whatever,
> if I press F7 on the Eclipse I am using it goes back to the previous
> point and I can then F6 past it.

Great news.

> Thanks so much for all your help. One change I did make though was in
> the Eclipse server setup for Tomcat I changed it to use the JDK and not
> the JRE. What difference will this make?

I never use a mere JRE since I'm a Java developer. I always use one or
more real (and Sun) JDK versions just as I maintain both Tomcat 6 and 7
for use depending.

> One thing that did change was
> that when I started the server in Eclipse the "HTTP Status 404 -
> /projectname/" did not occur. When this error appeared previously, you
> suggested it was something in the Web.xml file but I could not tell what
> was wrong in the web.xml file.

web.xml seems a lot of hocus pocus to the beginning developer. Even
after all these years, I grumble a little when I see a 404 and peek into
web.xml searching for the reason. Typically though, once the ducks are
aligned and waddling in step, you never look there for trouble.

> In regards to entering into Jar's that are third party, i.e Catalina and
> other Tomcat components, is there a way I can go into the source to see
> how things happen? Reason I ask is that this project involves using
> HTTP sessions and that is what I must learn next. Maybe you have some
> links you could give me on that one.

Yes, when you get your Tomcat download, look for a tarball that contains
source code. You can get both if you like. When you wire up Tomcat (as
you've done, you get it into Build Path not as individual JARs, but as
Apache Tomcat v6.0. If you expand the triangle to the left, you'll see
the JARs. Expand a JAR and you can see how to wire up Javadoc or source
code. Browsing and wiring up a JAR to its source in the Tomcat source
download will make it so that in debugging, you'll be able to walk down
inside.

A warning here...

If you're cooperating with other developers via a version control like
Git or Subversion, wiring up to Javadoc or source outside your workspace
will create host-specific paths in your project's .classpath file. Then,
when you commit that file, you screw the other developers. To read more
on this problem see
http://www.javahotchocolate.com/tutorials/git-eclipse.html --no matter
that it's Git, the problem is the same for any version-control system.

> Thanks again for your assistance
>
> Regards
>
> AJF

Best of luck!
Previous Topic:How and what to measure Eclipse?
Next Topic:Adding Jar Files to the Build Path
Goto Forum:
  


Current Time: Thu Apr 25 10:01:48 GMT 2024

Powered by FUDForum. Page generated in 0.10963 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top