You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Richard Gaywood <ri...@gmail.com> on 2007/01/22 19:05:01 UTC

Creating a new component

Hi list! I've done this before but I'm damned if I can remember what I did
last time to solve it.

I've created a new source tree alongside the main JMeter source on my
machine. I've created a new Logic Controller (the Failing Transaction
Controller -- it records it's success/failure as true based on the
success/failure of it's children samplers) and a
FailureTransactionControllerGui to go with it. They are cut/paste jobs of
the existing Transaction Controller and associated GUI class, so they are in
the same package (org.apache.jmeter.control and
org.apache.jmeter.control.gui) and have the same base class and associated
interfaces.

I've shipped these two class files into their own JAR and placed that JAR
into lib/ext in my JMeter install. I then restarted JMeter.

How do I now make them appear in the JMeter GUI? They've not auto-magically
inserted themselves into the Logic Controller menu. I have a vague feeling
that you need to change something around, but I can't remember what... I
also thought it was at least reflection based and therefore there wasn't
much config.

Any help greatfully received! Hopefully it's not complex.

Re: Creating a new component

Posted by sebb <se...@gmail.com>.
On 24/01/07, Richard Gaywood <ri...@gmail.com> wrote:
> On 1/23/07, sebb <se...@gmail.com> wrote:
>
> > Mangled jars?
>
>
> Yup, that's what it turned out to be. It was a holdover from making Jars
> with Eclipse -- some stale class files cluttering up my filesystem. I now
> have the new controller working.
>
> Thanks for you help, Sebb!
>
>

OK.

By the way, the JMeter Wiki is a good place to document such things -
anyone can contribute...

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Creating a new component

Posted by Richard Gaywood <ri...@gmail.com>.
On 1/23/07, sebb <se...@gmail.com> wrote:

> Mangled jars?


Yup, that's what it turned out to be. It was a holdover from making Jars
with Eclipse -- some stale class files cluttering up my filesystem. I now
have the new controller working.

Thanks for you help, Sebb!

Re: Creating a new component

Posted by sebb <se...@gmail.com>.
On 23/01/07, Richard Gaywood <ri...@gmail.com> wrote:
> On 1/23/07, sebb <se...@gmail.com> wrote:
> > Unless you need i18n, just implement the getLabel() method.
>
> Aha, yes, having looked at the superclass implementation I now see that is
> the way forwards here.
>
> > > I can see my JAR file on the classpath, but nothing else of note.
> >
> > It should appear in the GUI if you have got the class structure correct.
>
>
> Which I clearly do not. Harumph.
>
> I've now switched to doing my jar compilation from within Ant, whereas
> previously I was using Eclipse which resulted in all sorts of build output
> folders/up-to-date JAR containing out-of-date Class hilarity. Adding a new

I find it easiest to create a new project, and add the JMeter jars to
the classpath.

See extras/addons* for some info ...

Or just add the files to the existing tree structure initially.

When you have got them working, move them to a separate project as above.

> top-level set of classes within the jakarta-jmeter-2.2 folder structure
> alongside core,components,functions etc seems to have cleared that up. I've
> also had a side tour through how all the right-click popup menus are build
> (answer for future googlenauts: through elegant reflection in
> org.apache.jmeter.gui.util.MenuFactory.java).
>
> Now, however, with my fresh Jar file on the classpath for JMeter at runtime
> I can see two "Transaction Controller" instances in the Logic Controllers
> menu. If I add them both to a test plan, save it, and inspect the JMX I see:
>
>       <hashTree>
>         <TransactionController
> guiclass="org.apache.jmeter.control.gui.FailingTransactionControllerGui"
> testclass="TransactionController" testname="Tra
> nsaction Controller" enabled="true"/>
>         <hashTree/>
>         <TransactionController
> guiclass="TransactionControllerGui"
> testclass="TransactionController" testname="Transaction
> Controller" enabled="true"/>
>         <hashTree/>
>       </hashTree>
>
> Obviously, the second is the normal JMeter Transaction Controller and is OK,
> but the first is my new one and it's broken. My GUI class is somehow
> registered against the old Transaction Controller class.
>
> I've stared and stared at this code and I cannot see why this is happening.
> I've attached both files, but it seems to me the important bit is in
> FailingTransactionControllerGui:
>
>     /* Implements JMeterGUIComponent.createTestElement ()
> */
>     public TestElement createTestElement() {
>         FailingTransactionController lc = new
> FailingTransactionController();
>         configureTestElement(lc);
>         return lc;
>     }
>
> What is wrong with this bit of code?  Why is my testclass assoiciated with
> this guiclass incorrect?

Mangled jars?

I added your source files to the component tree and rebuilt JMeter,
and it seems to create the correct JMX entries:

      <hashTree>
        <org.apache.jmeter.control.FailingTransactionController
guiclass="org.apache.jmeter.control.gui.FailingTransactionControllerGui"
testclass="org.apache.jmeter.control.FailingTransactionController"
testname="Failing Transaction Controller" enabled="true"/>
        <hashTree/>
        <TransactionController guiclass="TransactionControllerGui"
testclass="TransactionController" testname="Transaction Controller"
enabled="true"/>
        <hashTree/>
      </hashTree>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Creating a new component

Posted by Richard Gaywood <ri...@gmail.com>.
On 1/23/07, sebb <se...@gmail.com> wrote:
>
> Unless you need i18n, just implement the getLabel() method.


Aha, yes, having looked at the superclass implementation I now see that is
the way forwards here.

> I can see my JAR file on the classpath, but nothing else of note.
>
> It should appear in the GUI if you have got the class structure correct.



Which I clearly do not. Harumph.

I've now switched to doing my jar compilation from within Ant, whereas
previously I was using Eclipse which resulted in all sorts of build output
folders/up-to-date JAR containing out-of-date Class hilarity. Adding a new
top-level set of classes within the jakarta-jmeter-2.2 folder structure
alongside core,components,functions etc seems to have cleared that up. I've
also had a side tour through how all the right-click popup menus are build
(answer for future googlenauts: through elegant reflection in
org.apache.jmeter.gui.util.MenuFactory.java).

Now, however, with my fresh Jar file on the classpath for JMeter at runtime
I can see two "Transaction Controller" instances in the Logic Controllers
menu. If I add them both to a test plan, save it, and inspect the JMX I see:

      <hashTree>
        <TransactionController guiclass="
org.apache.jmeter.control.gui.FailingTransactionControllerGui"
testclass="TransactionController" testname="Tra
nsaction Controller" enabled="true"/>
        <hashTree/>
        <TransactionController guiclass="TransactionControllerGui"
testclass="TransactionController" testname="Transaction Controller"
enabled="true"/>
        <hashTree/>
      </hashTree>

Obviously, the second is the normal JMeter Transaction Controller and is OK,
but the first is my new one and it's broken. My GUI class is somehow
registered against the old Transaction Controller class.

I've stared and stared at this code and I cannot see why this is happening.
I've attached both files, but it seems to me the important bit is in
FailingTransactionControllerGui:

    /* Implements JMeterGUIComponent.createTestElement() */
    public TestElement createTestElement() {
        FailingTransactionController lc = new
FailingTransactionController();
        configureTestElement(lc);
        return lc;
    }

What is wrong with this bit of code?  Why is my testclass assoiciated with
this guiclass incorrect?

Re: Creating a new component

Posted by sebb <se...@gmail.com>.
On 23/01/07, Richard Gaywood <ri...@gmail.com> wrote:
> On 1/22/07, sebb <se...@gmail.com> wrote:
> >
> > > How do I now make them appear in the JMeter GUI? They've not
> > auto-magically
> > > inserted themselves into the Logic Controller menu. I have a vague
> > feeling
> > > that you need to change something around, but I can't remember what... I
> > > also thought it was at least reflection based and therefore there wasn't
> > > much config.
> >
> > Should work ...
>
>
>
> Don't I need to futz about with the i18n messages file? At the moment, my
> FailingTransactionControllerGui class has this method:
>
>  public String getLabelResource() {
>        return "transaction_controller_title";
>    }
>
> Which collides with the one in TransactionController. Problem is, I would
> ideally like to ship my code as a JAR file people add to their JMeter
> install -- but this looks like I have to add lines to
> src/core/org/apache/jmeter/resources/messages.properties, and I'm guessing I
> can't do that without a custom entire build of JMeter. Is that right?

Yes - unless you use the TestBean approach, which has its own property files.

It would be useful if JMeter could read additional properties files,
but it does not do so at present.

Unless you need i18n, just implement the getLabel() method.

>
> > Any help greatfully received! Hopefully it's not complex.
> >
> > Try enabling debug trace - this should show what is done in startup.
>
>
> I can see my JAR file on the classpath, but nothing else of note.

It should appear in the GUI if you have got the class structure correct.

> I tried manually editing a JMX file to add a FailingTransactionController. I
> created this node:
>    <hashTree>
>        <FailingTransactionController
> guiclass="FailingTransactionControllerGui"
> testclass="FailingTransactionController" testname="Comtec Transaction
> Controller" enabled="true"/>
>        <hashTree/>
>      </hashTree>
>
> But when I loaded it I got a "could not initialise class" error message,
> with this in the log file:
> 2007/01/23 09:00:59 WARN  - jmeter.gui.action.Load: Could not convert file
> com.thoughtworks.xstream.converters.ConversionException:
> FailingTransactionController : FailingTransactionController
> ---- Debugging information ----
> required-type       : org.apache.jorphan.collections.ListedHashTree
> cause-message       : FailingTransactionController :
> FailingTransactionController
> class               : org.apache.jmeter.save.ScriptWrapper
> message             : FailingTransactionController :
> FailingTransactionController
> line number         : 28
> path                :
> /jmeterTestPlan/hashTree/hashTree/hashTree/FailingTransactionController
> cause-exception     :
> com.thoughtworks.xstream.alias.CannotResolveClassException
> -------------------------------
>
> Again, I can definitely see my JAR file on JMeter's classpath in jmeter.log.
>
> So is there also a separate list of XStream aliases I need to add my class
> into?

You can use the full class names.

Aliases are defined in saveservice.properties, but again, there is
only one such file.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Creating a new component

Posted by Richard Gaywood <ri...@gmail.com>.
On 1/22/07, sebb <se...@gmail.com> wrote:
>
> > How do I now make them appear in the JMeter GUI? They've not
> auto-magically
> > inserted themselves into the Logic Controller menu. I have a vague
> feeling
> > that you need to change something around, but I can't remember what... I
> > also thought it was at least reflection based and therefore there wasn't
> > much config.
>
> Should work ...



Don't I need to futz about with the i18n messages file? At the moment, my
FailingTransactionControllerGui class has this method:

  public String getLabelResource() {
        return "transaction_controller_title";
    }

Which collides with the one in TransactionController. Problem is, I would
ideally like to ship my code as a JAR file people add to their JMeter
install -- but this looks like I have to add lines to
src/core/org/apache/jmeter/resources/messages.properties, and I'm guessing I
can't do that without a custom entire build of JMeter. Is that right?


> Any help greatfully received! Hopefully it's not complex.
>
> Try enabling debug trace - this should show what is done in startup.


I can see my JAR file on the classpath, but nothing else of note.

I tried manually editing a JMX file to add a FailingTransactionController. I
created this node:
    <hashTree>
        <FailingTransactionController
guiclass="FailingTransactionControllerGui"
testclass="FailingTransactionController" testname="Comtec Transaction
Controller" enabled="true"/>
        <hashTree/>
      </hashTree>

But when I loaded it I got a "could not initialise class" error message,
with this in the log file:
2007/01/23 09:00:59 WARN  - jmeter.gui.action.Load: Could not convert file
com.thoughtworks.xstream.converters.ConversionException:
FailingTransactionController : FailingTransactionController
---- Debugging information ----
required-type       : org.apache.jorphan.collections.ListedHashTree
cause-message       : FailingTransactionController :
FailingTransactionController
class               : org.apache.jmeter.save.ScriptWrapper
message             : FailingTransactionController :
FailingTransactionController
line number         : 28
path                :
/jmeterTestPlan/hashTree/hashTree/hashTree/FailingTransactionController
cause-exception     :
com.thoughtworks.xstream.alias.CannotResolveClassException
-------------------------------

Again, I can definitely see my JAR file on JMeter's classpath in jmeter.log.

So is there also a separate list of XStream aliases I need to add my class
into?

Re: Creating a new component

Posted by sebb <se...@gmail.com>.
On 22/01/07, Richard Gaywood <ri...@gmail.com> wrote:
> Hi list! I've done this before but I'm damned if I can remember what I did
> last time to solve it.
>
> I've created a new source tree alongside the main JMeter source on my
> machine. I've created a new Logic Controller (the Failing Transaction
> Controller -- it records it's success/failure as true based on the
> success/failure of it's children samplers) and a
> FailureTransactionControllerGui to go with it. They are cut/paste jobs of
> the existing Transaction Controller and associated GUI class, so they are in
> the same package (org.apache.jmeter.control and
> org.apache.jmeter.control.gui) and have the same base class and associated
> interfaces.

OK

> I've shipped these two class files into their own JAR and placed that JAR
> into lib/ext in my JMeter install. I then restarted JMeter.

OK

> How do I now make them appear in the JMeter GUI? They've not auto-magically
> inserted themselves into the Logic Controller menu. I have a vague feeling
> that you need to change something around, but I can't remember what... I
> also thought it was at least reflection based and therefore there wasn't
> much config.

Should work ...

> Any help greatfully received! Hopefully it's not complex.
>
>

Try enabling debug trace - this should show what is done in startup.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org