Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Memory Analyzer » Cannot get extension report to be found.
Cannot get extension report to be found. [message #892828] Sat, 30 June 2012 02:52 Go to next message
Stephen McGruer is currently offline Stephen McGruerFriend
Messages: 4
Registered: June 2012
Junior Member
Hi there.

I created a plugin extension for MAT following the instructions at wiki.eclipse.org/MemoryAnalyzer/Extending_Memory_Analyzer, targetting a new report (and query) instead. Unfortunately, I've been unable to get MAT to recognize that my report is there. To launch my code, I am doing:

* Run As -> Run Configurations
* Set 'Run An Application' to 'org.eclipse.mat.api.parse'
* Set the Program arguments to '/path/to/my/test/heap org.eclipse.mat.api:my_first_query'

When I hit Run, I just get an error that the report is not found. ("Report not found: org.eclipse.mat.api:my_first_query").

What is the correct way to associate my report & query with MAT? At the moment, I have registered extension points in my plugin.xml file, and added a query.xml file for the query, but this doesnt seem to work.

My code:

MyFirstQuery.java:
package my_mat_extension;

import org.eclipse.mat.query.IQuery;
import org.eclipse.mat.query.IResult;
import org.eclipse.mat.query.annotations.Argument;
import org.eclipse.mat.query.annotations.CommandName;
import org.eclipse.mat.query.results.TextResult;
import org.eclipse.mat.util.IProgressListener;

import java.io.CharArrayWriter;
import java.io.PrintWriter;

@CommandName("my_first_query")
public class MyFirstQuery implements IQuery {

  @Override
  public IResult execute(IProgressListener listener) throws Exception {
    CharArrayWriter outWriter = new CharArrayWriter(1000);
    PrintWriter out = new PrintWriter(outWriter);
    out.println("My first query.");
    return new TextResult(outWriter.toString(), false);
  }

}


plugin.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension point="org.eclipse.mat.report.query">
      <query impl="my_mat_extension.MyFirstQuery" />
   </extension>
   
   <extension point="org.eclipse.mat.report.report">
      <report id="my_first_query" name="My First Query"
        description="My First Description"
        file="META-INF/reports/my_first_query.xml" />
   </extension>

</plugin>


META-INF/reports/my_first_query.xml (link spaces necessary to post this thread):
<query name="My First Query" xmlns:xsi="h t t p : / / w w w .w3.org/2001/XMLSchema-instance"
  xmlns="h t t p : / / w w w .eclipse.org/mat/report.xsd"
  xsi:schemaLocation="h t t p : / / w w w .eclipse.org/mat/report.xsd ../../../org.eclipse.mat.report/schema/report.xsd">

  <param key="filename_suffix" value="My First Query" />
  <command>my_first_query</command>
</query>




Thanks for any help, and please ask if there is any more information you need!

Regards,
Stephen

[Updated on: Sat, 30 June 2012 02:53]

Report message to a moderator

Re: Cannot get extension report to be found. [message #892965 is a reply to message #892828] Mon, 02 July 2012 07:57 Go to previous messageGo to next message
Krum Tsvetkov is currently offline Krum TsvetkovFriend
Messages: 164
Registered: July 2009
Senior Member
Hi Stephen,

The snippets you sent seem correct.
I am wondering if there is a problem with the run configuration for 'org.eclipse.mat.api.parse' (i.e. startup sequence or whatever else), or if there is in general a problem with the xmls (which I cannot see at the moment).
Can you perhaps try to run the MAT as product (i.e. get the GUI) and see if the query is visible among the other queries, and also if the report is showing up in the list with the reports.
There is a description how to do this (may be a bit outdatedm but should work):
http://wiki.eclipse.org/index.php?title=MemoryAnalyzer/Contributor_Reference#Launch_Configuration

If this works OK, then we should investigate (and describe) what would be the proper approach for the parse application.
I will give it a try following your description.

Krum
Re: Cannot get extension report to be found. [message #893115 is a reply to message #892965] Mon, 02 July 2012 17:00 Go to previous messageGo to next message
Stephen McGruer is currently offline Stephen McGruerFriend
Messages: 4
Registered: June 2012
Junior Member
Krum,

Thank you for your help. As it turned out, it was my own fault of course! I was trying to run the report with a prefix of org.eclipse.mat.api:my_first_query, when it should of course have been myproject:my_first_query.

Checking the GUI was a good idea, as it had correctly found the report and listed it's full name.

To repeat (for anyone coming via Google): if you create an extension project, the report is referred to via "myproject:my_first_report", not via "org.eclipse.mat.api:my_first_report"!


Thank you very much!

Stephen
Re: Cannot get extension report to be found. [message #893187 is a reply to message #893115] Tue, 03 July 2012 06:47 Go to previous messageGo to next message
Krum Tsvetkov is currently offline Krum TsvetkovFriend
Messages: 164
Registered: July 2009
Senior Member
Hi Stephen,

I extended the http://wiki.eclipse.org/MemoryAnalyzer/Extending_Memory_Analyzer#Reports_in_Memory_Analyzer part with a short description explaining how to execute a custom report from the IDE using the parse application. Please have a look at it, if you have time, and let me know if the description is ok.
Thanks!

Krum
Re: Cannot get extension report to be found. [message #894623 is a reply to message #893187] Mon, 09 July 2012 20:45 Go to previous messageGo to next message
Stephen McGruer is currently offline Stephen McGruerFriend
Messages: 4
Registered: June 2012
Junior Member
Apologies for the delay! I've now had a chance to look at the added section. It looks good, it's certainly nice to have a little bit on reports. When I have time, I might take a run through those documents and see if I can tidy it up.

Can I ask, is there any plans to expose a fully functional programmatic interface to MAT? That is, at the moment the only way to get at MAT functionality programmatically (and please correct me if I'm wrong!) to generate output for another program is to use the reports framework. However, reports seem to be deeply hardcoded (again as far as I know!) to generate a HTML file inside of a Zipped folder, located in exactly the same place as the heap dump.

Ideally, I'd be able to call one of the queries (or do the same actions as it, as I know that queries are not part of the API) programmatically from some code not relying on OSGI, or at least dump the results of a query out to a file/etc without worrying about this generated HTML & Zip folder.

Thanks,
Stephen


EDIT/UPDATE: So, I realized that using an IApplication might be slightly better, as it avoids the HTML/Zip problem while still allowing access to MAT internals. Is this the best approach then?

[Updated on: Tue, 10 July 2012 01:12]

Report message to a moderator

Re: Cannot get extension report to be found. [message #899482 is a reply to message #894623] Wed, 01 August 2012 06:45 Go to previous message
Krum Tsvetkov is currently offline Krum TsvetkovFriend
Messages: 164
Registered: July 2009
Senior Member
Hi Stephen,

sorry for the delayed reply.
Just to make sure what is your use case. Do you want to
a) call MAT from a different Java process, make it do some calclulations for you and use results exported in some form better than HTML
b) have MAT and your code in one process and use the APIs

MAT itself uses the Eclipse extensions mechanism so you won't be able to run it non-OSGi.

Krum
Previous Topic:Leak suspect report
Next Topic:Can I see the contents of the generations?
Goto Forum:
  


Current Time: Thu Mar 28 21:41:06 GMT 2024

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

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

Back to the top