Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » JDT Debugger Not Finding Source
JDT Debugger Not Finding Source [message #202308] Tue, 03 May 2005 03:26 Go to next message
Jeremy Whitlock is currently offline Jeremy WhitlockFriend
Messages: 23
Registered: July 2009
Junior Member
I am working on a Weblogic plugin for Eclipse. In doing so, I am
providing the capability to debug deployed java applications. My previous
version of this worked but now has deprecated code that I'm trying to get
rid of in the new release. The problem I'm having is that I am building a
JavaSourceLookupDirector. I am then creating a list of ISourceContainer
objects and then adding them to the JavaSourceLookupDirector. I set some
config parameters and I run the Launch. When the breakpoint is hit in the
java source of a Servlet deployed on Weblogic, the debugger perspective
opens and then prompts me to modify the source path because the source
cannot be found. I follow the usual procedures to add the Java project to
the source path but lo and behold, it's already there?! What gives?
Attached is the important source for this class. Can anyone see where I'm
going wrong? Do any of you have any alternatives for achieving the goal
of launching a VM programmatically within a plugin's code and allow for
java source to be debugged? Like I mentioned before, I did this in the
previous version of the plugin but it uses deprecated code. Here is the
code:

public ISourceContainer[] computeRuntimeContainers(ILaunchConfiguration
configuration, IProgressMonitor monitor) throws CoreException {
IRuntimeClasspathEntry[] unresolvedEntries =
JavaRuntime.computeUnresolvedSourceLookupPath(configuration) ;
IProject[] projects =
ResourcesPlugin.getWorkspace().getRoot().getProjects();
List javaProjectList = new ArrayList();
IWLSClasspathEntry[] preC = server.getPreBootClasspath();
IWLSClasspathEntry[] pstC = server.getPostBootClasspath();

for(int i = 0; i<projects.length;i++)
{
if(projects[i].hasNature(JavaCore.NATURE_ID))
{
IJavaProject javaProject = (IJavaProject)
projects[i].getNature(JavaCore.NATURE_ID);

javaProjectList.add(javaProject);
}
}
IRuntimeClasspathEntry[] projectEntries = new
IRuntimeClasspathEntry[javaProjectList.size()];
for (int i = 0; i < javaProjectList.size(); i++) {
projectEntries[i] =
JavaRuntime.newProjectRuntimeClasspathEntry((IJavaProject)ja vaProjectList.get(i));
}
IRuntimeClasspathEntry[] entries = new
IRuntimeClasspathEntry[projectEntries.length+unresolvedEntri es.length];
System.arraycopy(unresolvedEntries,0,entries,0,unresolvedEnt ries.length);
System.arraycopy(projectEntries,0,entries,unresolvedEntries. length,projectEntries.length);

IRuntimeClasspathEntry[] resolved =
JavaRuntime.resolveSourceLookupPath(entries, configuration);
return JavaSourceLookupUtil.translate(resolved, true);
}

public boolean launchServer(IServerInstall server) {
boolean success = true;
IVMInstall vmInstall = null;
String mode = ""; //$NON-NLS-1$
this.server = server;

vmInstall = getVMInstall();

if (vmInstall == null) {
vmInstall = JavaRuntime.getDefaultVMInstall();
}

if (server.getRunMode().equals("Debug Mode")) {
mode = ILaunchManager.DEBUG_MODE;
} else {
mode = ILaunchManager.RUN_MODE;
}

if (vmInstall != null) {
IVMRunner vmRunner = vmInstall.getVMRunner(mode);
if (vmRunner != null) {
try {
String[] classpath = computeClasspath();
ILaunchConfigurationType launchType =
DebugPlugin.getDefault().getLaunchManager().getLaunchConfigu rationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICA TION);
//$NON-NLS-1$

DebugUITools.setLaunchPerspective(launchType, mode,
IDebugUIConstants.PERSPECTIVE_DEFAULT);
ILaunchConfigurationWorkingCopy config = launchType.newInstance(null,
server.getDisplayName() + " (" + server.getRunMode() + ")");

config.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);

ISourceLookupDirector sourceLocator = new JavaSourceLookupDirector();
ISourceContainer[] runtimeContainers =
computeRuntimeContainers(config, null);

sourceLocator.setSourceContainers(runtimeContainers);
sourceLocator.setFindDuplicates(false);

try{
config.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR _MEMENTO,
sourceLocator.getMemento());
config.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR _ID,
sourceLocator.getId());
config.doSave();
}catch(CoreException ce){
WeblogicPlugin.log(ce);
}

if (classpath != null) {
VMRunnerConfiguration vmConfig = new VMRunnerConfiguration(
"weblogic.Server", classpath);

if (server.getDomainHome() == null ||
server.getDomainHome().trim().equals("")) {
success = false;
} else {
vmConfig.setWorkingDirectory(server.getDomainHome());
}

if (server.getProgramArgs() != null &&
!server.getProgramArgs().trim().equals("")) {
String[] pArgs = server.getProgramArgs().split("\n");

for (int i = 0; i < pArgs.length; i++) {
pArgs[i] = pArgs[i].trim();
}

vmConfig.setProgramArguments(pArgs);
}

if (server.getVmArgs() != null &&
!server.getVmArgs().trim().equals("")) {
String[] vmArgs = server.getVmArgs().split("\n");

for (int i = 0; i < vmArgs.length; i++) {
vmArgs[i] = vmArgs[i].trim();
}

vmConfig.setVMArguments(vmArgs);
}

ILaunch launch = new Launch(config, mode, sourceLocator);
vmRunner.run(vmConfig, launch, null);

DebugPlugin.getDefault().getLaunchManager().addLaunch(launch );
}
} catch (CoreException ce) {
WeblogicPlugin.log(ce);
success = false;
}
}
}

return success;
}

Thanks, Jeremy
Re: JDT Debugger Not Finding Source [message #202941 is a reply to message #202308] Mon, 09 May 2005 14:05 Go to previous message
Jeremy Whitlock is currently offline Jeremy WhitlockFriend
Messages: 23
Registered: July 2009
Junior Member
I resolved the issue by using the:

org.eclipse.debug.core.launchConfigurationTypes
org.eclipse.debug.core.sourcePathComputers

extension points. Take care, Jeremy
Previous Topic:OutOfMemory error
Next Topic:Cannot open build.xml with Ant Editor
Goto Forum:
  


Current Time: Sat Nov 09 03:00:43 GMT 2024

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

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

Back to the top