HowTo use the JPOS Configuration Interface

1.444 Aufrufe
Direkt zur ersten ungelesenen Nachricht

mwyc...@gmail.com

ungelesen,
17.07.2009, 12:15:2217.07.09
an jPOS Users
Hellos,

Am stack on how the JPOS Configuration Interface works,

I have created some property file called myconfig.xml, dumped it in
the deploy folder.
It's contents are ;
<object name="TerminalList" class="org.jpos.ui.action.TerminalList">
<property name="jdbc.url" value="jdbc:sybase:Tds:neptune002:5000/
test_db" />
<property name="jdbc.driver" value="com.sybase.jdbc2.jdbc.SybDriver" /
>
<property name="db.user" value="test" />
<property name="db.user.password" value="test123" />
<property name="db.name" value="coredb" />
</object>

In the my TerminalList.java i have defined it as follows

package org.jpos.ui.action;
import org.jpos.core.Configurable;
import org.jpos.core.Configuration;
import org.jpos.iso.*;
import org.jpos.tpl.ConnectionPool;
import org.jpos.util.ThreadPool;

public class TerminalList extends JPanel
implements Configurable, ActionListener
{

try
{
Class.forName (db_driver);
..
...
}
..

public void setConfiguration(Configuration configuration)
{
....
.....
}
}

The TerminalList compiles Ok, (I then put the class in org\jpos\ui
\action and build a new JPOS.jar file)
But now on launching Q2, i get these errors/warnings;

<log realm="Q2.system" at="Fri Jul 17 19:09:07 EAT 2009.546">
<info>
deploy:myconfig.xml
</info>
</log>
java.lang.NullPointerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.jpos.ui.action.TerminalList.<init>(TerminalList.java:
50)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0
(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance
(NativeConstruct
orAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance
(DelegatingC
onstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:
513)
at com.sun.jmx.mbeanserver.MBeanInstantiator.instantiate
(MBeanInstantiat
or.java:264)
at com.sun.jmx.mbeanserver.MBeanInstantiator.instantiate
(MBeanInstantiat
or.java:577)
at com.sun.jmx.mbeanserver.MBeanInstantiator.instantiate
(MBeanInstantiat
or.java:484)
at com.sun.jmx.mbeanserver.JmxMBeanServer.instantiate
(JmxMBeanServer.jav
a:950)
at org.jpos.q2.QFactory.instantiate(QFactory.java:108)
at org.jpos.q2.Q2.deploy(Q2.java:372)
at org.jpos.q2.Q2.deploy(Q2.java:228)
at org.jpos.q2.Q2.start(Q2.java:173)
at org.jpos.q2.Q2.main(Q2.java:570)
<log realm="Q2.system" at="Fri Jul 17 19:09:07 EAT 2009.718">
<warn>
deploy
<exception name="MBean class org.jpos.ui.action.TerminalList does
not implem
ent DynamicMBean, neither follows the Standard MBean conventions
(javax.manageme
nt.NotCompliantMBeanException: Class org.jpos.ui.action.TerminalList
is not a JM
X compliant Standard MBean) nor the MXBean conventions
(javax.management.NotComp
liantMBeanException: org.jpos.ui.action.TerminalList: Class
org.jpos.ui.action.T
erminalList is not a JMX compliant MXBean)">
javax.management.NotCompliantMBeanException: MBean class
org.jpos.ui.action.
TerminalList does not implement DynamicMBean, neither follows the
Standard MBean
conventions (javax.management.NotCompliantMBeanException: Class
org.jpos.ui.act
ion.TerminalList is not a JMX compliant Standard MBean) nor the MXBean
conventio
ns (javax.management.NotCompliantMBeanException:
org.jpos.ui.action.TerminalList
: Class org.jpos.ui.action.TerminalList is not a JMX compliant MXBean)
at com.sun.jmx.mbeanserver.Introspector.checkCompliance
(Introspector.jav
a:160)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(D
efaultMBeanServerInterceptor.java:305)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean
(JmxMBeanServer.j
ava:482)
at org.jpos.q2.QFactory.createQBean(QFactory.java:135)
at org.jpos.q2.Q2.deploy(Q2.java:375)
at org.jpos.q2.Q2.deploy(Q2.java:228)
at org.jpos.q2.Q2.start(Q2.java:173)
at org.jpos.q2.Q2.main(Q2.java:570)
</exception>
</warn>
</log>
<log realm="Q2.system" at="Fri Jul 17 19:09:07 EAT 2009.734">
<warn>
Tidying C:\Documents and Settings\wycliff\Desktop\ISOServer\deploy
\myconfig.
xml out of the way, by adding .BAD
It will be called: C:\Documents and Settings\wycliff\Desktop
\ISOServer\deplo
y\myconfig.xml.BAD see log above for detail of problem.
</warn>
</log>

what could be the cause of such errors/warning; I have failed to
interprete the warnings above.

regards,

Alejandro Revilla

ungelesen,
17.07.2009, 12:23:4217.07.09
an jpos-...@googlegroups.com
The key might be in the method you are not showing us, setConfiguration().

mwyc...@gmail.com

ungelesen,
20.07.2009, 02:53:4320.07.09
an jPOS Users
My setConfiguration basically contains;

public void setConfiguration(Configuration configuration)
{
db_driver = configuration.get("jdbc.driver");
db_url = configuration.get("jdbc.url");
user = configuration.get("db.user");
passwd = configuration.get("db.user.password");
db_name = configuration.get("db.name");

Alejandro Revilla

ungelesen,
20.07.2009, 07:26:5620.07.09
an jpos-...@googlegroups.com
I would try to see the content of your db_driver variable (i.e. by using a print statement).


mwyc...@gmail.com

ungelesen,
22.07.2009, 02:35:1322.07.09
an jPOS Users
I tried printing one of the parameters but it returns null, see out
below (the 1st line)

null
<log realm="Q2.system" at="Wed Jul 22 09:21:57 EAT 2009.234">
<warn>
deploy
<exception name="MBean class org.jpos.ui.action.TerminalList does
not implement DynamicMBean, neither follows the Standard MBean
conventions (javax.management.NotCompliantMBeanException: Class
org.jpos.ui.action.TerminalList is not a JMX compliant Standard MBean)
nor the MXBean conventions
(javax.management.NotCompliantMBeanException:
org.jpos.ui.action.TerminalList: Class org.jpos.ui.action.T
erminalList is not a JMX compliant MXBean)">
javax.management.NotCompliantMBeanException: MBean class
org.jpos.ui.action.
TerminalList does not implement DynamicMBean, neither follows the
Standard MBean conventions
(javax.management.NotCompliantMBeanException: Class
org.jpos.ui.action.TerminalList is not a JMX compliant Standard MBean)
nor the MXBean conventions
(javax.management.NotCompliantMBeanException:
org.jpos.ui.action.TerminalList: Class org.jpos.ui.action.TerminalList
is not a JMX compliant MXBean) at
com.sun.jmx.mbeanserver.Introspector.checkCompliance(Introspector.java:
160)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean
(DefaultMBeanServerInterceptor.java:305)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean
(JmxMBeanServer.java:482)
at org.jpos.q2.QFactory.createQBean(QFactory.java:118)
at org.jpos.q2.Q2.deploy(Q2.java:434)
at org.jpos.q2.Q2.deploy(Q2.java:270)
at org.jpos.q2.Q2.run(Q2.java:183)
at java.lang.Thread.run(Thread.java:619)
</exception>
</warn>
</log>
<log realm="Q2.system" at="Wed Jul 22 09:21:57 EAT 2009.250">
<warn>
Tidying C:\Documents and Settings\wycliff\Desktop\build\deploy
\myconfig.xml out of the way, by adding .BAD
It will be called: C:\Documents and Settings\wycliff\Desktop\build
\deploy\myconfig.xml.BAD see log above for detail of problem.
</warn>
</log>

If I may ask,
Having implemented Configurable, why does it complain about
implementing DynamicMBean?

Do you think my properties file is defined correctly? Is <object> a
valid JPOS tag?

<object name="TerminalList" class="org.jpos.ui.action.TerminalList">
<property name="jdbc.url" value="jdbc:sybase:Tds:neptune002:5000/
test_db" />
<property name="jdbc.driver"
value="com.sybase.jdbc2.jdbc.SybDriver" />
<property name="db.user" value="test" />
<property name="db.user.password" value="test123" />
<property name="db.name" value="coredb" />
</object>

Since my TerminalList class also implements ActionListener, would this
conflict with Configurable?

thanks

Mark Salter

ungelesen,
22.07.2009, 04:14:0022.07.09
an jpos-...@googlegroups.com
mwyc...@gmail.com wrote:
> I tried printing one of the parameters but it returns null, see out
> below (the 1st line)
>
> null
This is the problem then, your setConfiguration is not being called.

> <log realm="Q2.system" at="Wed Jul 22 09:21:57 EAT 2009.234">
> <warn>
> deploy
> <exception name="MBean class org.jpos.ui.action.TerminalList does
> not implement DynamicMBean, neither follows the Standard MBean
> conventions (javax.management.NotCompliantMBeanException: Class
> org.jpos.ui.action.TerminalList is not a JMX compliant Standard MBean)
> nor the MXBean conventions

What did you model TerminalList on?

Pick a QBean that works and make sure your class follows the same
convention?

> If I may ask,
> Having implemented Configurable, why does it complain about
> implementing DynamicMBean?

These are different interfaces, DynamicMBean is the one that is needed,
but that you are not implementing?

>
> Do you think my properties file is defined correctly? Is <object> a
> valid JPOS tag?

Q2 is trying to instance your QBean, which would indicate to me that
your config file is ok?

>
> <object name="TerminalList" class="org.jpos.ui.action.TerminalList">
> <property name="jdbc.url" value="jdbc:sybase:Tds:neptune002:5000/
> test_db" />
> <property name="jdbc.driver"
> value="com.sybase.jdbc2.jdbc.SybDriver" />
> <property name="db.user" value="test" />
> <property name="db.user.password" value="test123" />
> <property name="db.name" value="coredb" />
> </object>
>
> Since my TerminalList class also implements ActionListener, would this
> conflict with Configurable?

Conflict in which way - do you get compile errors or warnings?

Make sure your class 'looks' like a QBean class that works for you.
Once they implement the same interfaces and get their config in the same
way, you should be good.

--
Mark

mwyc...@gmail.com

ungelesen,
23.07.2009, 01:50:2023.07.09
an jPOS Users
> What did you model TerminalList on?

My TerminalList composition is similar to that of the files in
org.jpos.ui.action which implement ActionListener, my intention was to
use it in my ISOMeter such that it drives one of my menuitems, just
like I use org.jpos.ui.action.Exit

> Conflict in which way - do you get compile errors or warnings?
No I don't get any compilation errors

> Make sure your class 'looks' like a QBean class that works for you.
> Once they implement the same interfaces and get their config in the same
> way, you should be good.

I have not implemented QBeans before, but let me try and read about
them, may be I will get a clue.

If I may ask,
My ISOServer config is defined as follows;

<server name="bnk" class="org.jpos.q2.iso.QServer" logger="Q2">
<attr name="port" type="java.lang.Integer">15000</attr>
<channel
name="post.channel"class="org.jpos.iso.channel.PostChannel"packager="org.jpos.iso.packager.PostPackager"
logger="Q2">
</channel>
<request-listener class="Breft" logger="Q2">
<property name="jdbc.url" value="jdbc:sybase:Tds:neptune002:5000/
testdb" />
<property name="jdbc.driver"
value="com.sybase.jdbc2.jdbc.SybDriver" />

</request-listener>
</server>

And with that setup am able to access the defined Property Values with
in the Breft class. In the Breft class I also just implement
Configurable and define the setConfiguration method just like I did in
the TerminalList class.
How is this setup different from the one of my TerminalList class
scenario above?

The only difference I see is that for the TerminalList case, I defined
a seperate Property File(myconfig.xml), well as for the Breft class
the Properties are imbedded in the ISOServer definition.

thanks


On Jul 22, 11:14 am, Mark Salter <marksal...@talktalk.net> wrote:

Mark Salter

ungelesen,
23.07.2009, 05:12:4123.07.09
an jpos-...@googlegroups.com
mwyc...@gmail.com wrote:
>> What did you model TerminalList on?
>
> My TerminalList composition is similar to that of the files in
> org.jpos.ui.action which implement ActionListener, my intention was to
> use it in my ISOMeter such that it drives one of my menuitems, just
> like I use org.jpos.ui.action.Exit
Ok, it is still hard to 'see' from here what you are doing and what
might be wrong. I think you might be mixing approaches and assuming
that because a method is implemented it will always be called. The
issue might be that the 'holders' of these objects are treating in
different ways because they are different; we shall see.

>
>> Conflict in which way - do you get compile errors or warnings?
> No I don't get any compilation errors

Then conflicts of Interfaces and perhaps others are not a problem?

What is controlling this above QBean - Q2; it makes sure the methods
are called and passes down the configuration data in doing so.

>
> The only difference I see is that for the TerminalList case, I defined
> a seperate Property File(myconfig.xml), well as for the Breft class
> the Properties are imbedded in the ISOServer definition.

I think you need to worry about what might be calling the methods and
that your objects might be operating in different 'environments' and
thus methods you are expecting to be called are not.

We know that your setConfiguration is not being invoked (the null value)
so now you need to find out why, or place the code somewhere it is called.

--
Mark

mwyc...@gmail.com

ungelesen,
24.07.2009, 01:22:5824.07.09
an jPOS Users
> Then conflicts of Interfaces and perhaps others are not a problem?
Yes I d agree with you.

> I think you need to worry about what might be calling the methods and
> that your objects might be operating in different 'environments' and
> thus methods you are expecting to be called are not.

I think that is the actual problem, the operating environment seems
not to affect the invoking of the setConfiguration().
Does it mean that Q2 will not invoke setConfiguration() for classes
placed in org.jpos.ui.action?

The challenge I have it that my TerminalList has to reside in
org.jpos.ui.action for it to be used in my ISOMeter definition.
See how am using the TerminalList in the ISOMeter.
<qbean class="org.jpos.q2.ui.UI" name="UI" logger="Q2" look-and-
feel="com.sun.java.swing.plaf.windows.WindowsLookAndFeel">
........
........
<menu id="Terminals" accesskey="e">
<menuitem id="Our Terminals" accesskey="G" action="terminallist" /
>
</menu>
</menubar>
.......
.......
<object class="org.jpos.ui.action.TerminalList" id="terminallist" />

</qbean>

Is there any other location in which I can place TerminalList so that
it's setConfiguration() will be invoked.

regards


On Jul 23, 12:12 pm, Mark Salter <marksal...@talktalk.net> wrote:
> mwycli...@gmail.com wrote:
> >> What did you model TerminalList on?
>
> > My TerminalList composition is similar to that of the files in
> > org.jpos.ui.action which implement ActionListener, my intention was to
> > use it in my ISOMeter such that it drives one of my menuitems, just
> > like I use org.jpos.ui.action.Exit
>
> Ok, it is still hard to 'see' from here what you are doing and what
> might be wrong.  I think you might be mixing approaches and assuming
> that because a method is implemented it will always be called.  The
> issue might be that the 'holders' of these objects are treating in
> different ways because they are different; we shall see.
>
>
>
> >> Conflict in which way - do you get compile errors or warnings?
> > No I don't get any compilation errors
>
> Then conflicts of Interfaces and perhaps others are not a problem?
>
>
>
>
>
>
>
> >> Make sure your class 'looks' like a QBean class that works for you.
> >> Once they implement the same interfaces and get their config in the same
> >> way, you should be good.
>
> > I have not implemented QBeans before, but let me try and read about
> > them, may be I will get a clue.
>
> > If I may ask,
> > My ISOServer config is defined as follows;
>
> > <server name="bnk" class="org.jpos.q2.iso.QServer" logger="Q2">
> >  <attr name="port" type="java.lang.Integer">15000</attr>
> >    <channel
> > name="post.channel"class="org.jpos.iso.channel.PostChannel"packager="org.jp­os.iso.packager.PostPackager"
> Mark- Hide quoted text -
>
> - Show quoted text -

Mark Salter

ungelesen,
24.07.2009, 03:39:1224.07.09
an jpos-...@googlegroups.com
mwyc...@gmail.com wrote:
>> I think you need to worry about what might be calling the methods and
>> that your objects might be operating in different 'environments' and
>> thus methods you are expecting to be called are not.
>
> I think that is the actual problem, the operating environment seems
> not to affect the invoking of the setConfiguration().
> Does it mean that Q2 will not invoke setConfiguration() for classes
> placed in org.jpos.ui.action?
Q2 would need to be the 'one' processing the configuration file and
'launching' the component. Part of this launch is to pass in the
configuration details to the QBean.

*If* Q2 is not 'launching' your component, then it doesn't have the
chance to call setConfiguration.

>
> The challenge I have it that my TerminalList has to reside in
> org.jpos.ui.action for it to be used in my ISOMeter definition.
> See how am using the TerminalList in the ISOMeter.
> <qbean class="org.jpos.q2.ui.UI" name="UI" logger="Q2" look-and-
> feel="com.sun.java.swing.plaf.windows.WindowsLookAndFeel">
> ........
> ........
> <menu id="Terminals" accesskey="e">
> <menuitem id="Our Terminals" accesskey="G" action="terminallist" /
> </menu>
> </menubar>
> .......
> .......
> <object class="org.jpos.ui.action.TerminalList" id="terminallist" />
>
> </qbean>
>
> Is there any other location in which I can place TerminalList so that
> it's setConfiguration() will be invoked.

I'm not sure, but your TerminalList needs to get it's configuration from
somewhere, perhaps from ISOMeter (via NameRegistrar or if a reference is
available on a call made to it)?

Rather than try and guess from here, can you share your :-

TerminalList code,
ISOMeter deploy file

and anything else I will need to actually see your set-up?


--
Mark

Alejandro Revilla

ungelesen,
24.07.2009, 08:51:2224.07.09
an jpos-...@googlegroups.com

I'm not sure, but your TerminalList needs to get it's configuration from
somewhere, perhaps from ISOMeter (via NameRegistrar or if a reference is
available on a call made to it)?

Exactly, we are not pushing a Configuration object in the UI. but if your object implements UIAware, your setUI (UI ui, Element config) would get called. So you could modify your TerminalList configuration to look like this:



  <object class="org.jpos.ui.action.TerminalList" id="terminallist">
   <jdbc-driver>xxx</jdbc-driver>
   <jdbc-url>xxx</jdbc-url>
  </object>

Your setUI implementation could use code like this:

class TerminalList implements UIAware ... {
    ...
    ...
    public void setUI (UI ui, Element config) {
      String jdbcDriver = config.getChildTextTrim("jdbc-driver")
      String jdbcUrl = config.getChildTextTrim("jdbc-url");
    }
}

We hope this solves your issue.

Mark Salter

ungelesen,
24.07.2009, 10:51:0024.07.09
an jpos-...@googlegroups.com
Alejandro Revilla wrote:
> So you could modify your TerminalList configuration to look like
> this:
>
>
> <object class="org.jpos.ui.action.TerminalList" id="terminallist">
> <jdbc-driver>xxx</jdbc-driver>
> <jdbc-url>xxx</jdbc-url>
> </object>
>
> Your setUI implementation could use code like this:
>
> class TerminalList implements UIAware ... {
> ...
> ...
> public void setUI (UI ui, Element config) {
> String jdbcDriver = config.getChildTextTrim("jdbc-driver")
> String jdbcUrl = config.getChildTextTrim("jdbc-url");
> }
> }
>
> We hope this solves your issue.

Thanks Alejandro - it was the detail on the interface I was missing and
hoping to discover/investigate in seeing the code 8).

--
Mark

mwyc...@gmail.com

ungelesen,
27.07.2009, 03:26:2827.07.09
an jPOS Users
Hello,

I have tried the new approach as you had advised, but still get same
errors;

java.lang.NullPointerException [ is due to System.out.println
(jdbcDriver);]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance
(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance
(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.sun.jmx.mbeanserver.MBeanInstantiator.instantiate
(MBeanInstantiator.java:264)
at com.sun.jmx.mbeanserver.MBeanInstantiator.instantiate
(MBeanInstantiator.java:577)
at com.sun.jmx.mbeanserver.MBeanInstantiator.instantiate
(MBeanInstantiator.java:484)
at com.sun.jmx.mbeanserver.JmxMBeanServer.instantiate
(JmxMBeanServer.java:950)
at org.jpos.q2.QFactory.instantiate(QFactory.java:91)
at org.jpos.q2.Q2.deploy(Q2.java:431)
at org.jpos.q2.Q2.deploy(Q2.java:270)
at org.jpos.q2.Q2.run(Q2.java:183)
at java.lang.Thread.run(Thread.java:619)
<log realm="Q2.system" at="Mon Jul 27 10:01:18 EAT 2009.610">
<warn>
deploy
<exception name="MBean class org.jpos.ui.action.TerminalList does not
implement DynamicMBean, neither follows the Standard MBean conventions
(javax.management.NotCompliantMBeanException: Class
org.jpos.ui.action.TerminalList is not a JMX compliant Standard MBean)
nor the MXBean conventions
(javax.management.NotCompliantMBeanException:
org.jpos.ui.action.TerminalList: Class org.jpos.ui.action.TerminalList
is not a JMX compliant MXBean)">
.......
.......

Also tried defining the jdbcDriver variables outside the setUI, but
still got same errors/warnings.

thanks

mwyc...@gmail.com

ungelesen,
30.07.2009, 07:26:2730.07.09
an jPOS Users
Hellos,

Below are the src files as per Mark's request;

1. myconfig.xml

<object class="org.jpos.ui.action.TerminalList" id="terminallist">
<jdbc-driver>com.sybase.jdbc2.jdbc.SybDriver</jdbc-driver>
<jdbc-url>jdbc:sybase:Tds:neptune002:5000/test_db</jdbc-url>
</object>

2. ISOMeter.xml

<qbean class="org.jpos.q2.ui.UI" name="UI" logger="Q2" look-and-
feel="com.sun.java.swing.plaf.windows.WindowsLookAndFeel">
<ui width="550" height="480" full-screen="false" undecorated="true"
close="false">
<caption>JPOS ISO 8583 INTERFACE</caption>
<menubar id="MAIN">
<menu id="Actions" accesskey="f">
<menuitem id="Echo-Test" accesskey="E" action="bsh" command="cfg/
echotest.bsh" />
<menuseparator />
<menuitem id="Debug" accesskey="Q" action="debug" />
<menuitem id="Quit" accesskey="X" action="exit" />
</menu>
<menu id="Terminals" accesskey="e">
<menuitem id="Our ATMs" accesskey="G" action="terminallist" />
</menu>
</menubar>
<components>
<border-layout>
<center>
<vsplit divider="150">
<top>
<grid rows="1" columns="1" >
<cell>
<iso-meter refresh="250" idref="server.JPOS">JPOS : 12000</
iso-meter>
</cell>
</top>
<bottom>
<log-listener scrollable="true" logger="Q2" font="fixed-
normal-12" max-events="1000" max-lines="50"/>
</bottom>
</vsplit>
</center>
<south>
<label font="helvetica-bold-10">Copyright (c) 2008 - ISO Meter -
jSwitch Control Center</label>
</south>
</border-layout>
</components>
</ui>
<object class="org.jpos.ui.action.TerminalList" id="terminallist" />
<object class="org.jpos.ui.action.Exit" id="exit" />
<object class="org.jpos.ui.action.Debug" id="debug" />
</qbean>

3. TerminalList.java

package org.jpos.ui.action;

import java.awt.*;
import java.io.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.SQLException;
import java.util.Arrays;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.PrintStream;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import org.jdom.Element;
import org.jpos.ui.UI;
import org.jpos.ui.UIAware;

public class TerminalList extends JPanel
implements ActionListener, UIAware

public UI ui;
private static String jdbcurl="";
private static String jdbcdriver="";


{

private boolean DEBUG = false;
public TerminalList()
{
GridLayout layout = new GridLayout(1,0);

try
{

jdbcurl=config.getChildTextTrim("jdbc-url");
jdbcdriver=config.getChildTextTrim("jdbc-driver");

System.out.println(jdbcdriver);
System.out.println(jdbcurl);

//Class.forName ("com.sybase.jdbc2.jdbc.SybDriver");
//Connection con = DriverManager.getConnection
("jdbc:sybase:Tds:neptune002:5000/coredb","test","test123");

Class.forName (jdbcdriver);
Connection con = DriverManager.getConnection
(jdbcurl,"test","test123");


Statement stmt = con.createStatement();
ResultSet result = stmt.executeQuery("select * from
test_db..terminal");
ResultSetMetaData md = result.getMetaData();
int columnCount = md.getColumnCount();

Vector columns = new Vector(columnCount);

for(int i=1; i<=columnCount; i++)
columns.add(md.getColumnName(i));

Vector data = new Vector();
Vector row;

while(result.next())
{
row = new Vector(columnCount);
for(int i=1; i<=columnCount; i++)
{
row.add(result.getString(i));
}
data.add(row);
}
final JTable table = new JTable(data, columns);

table.setPreferredScrollableViewportSize(new Dimension(500,
300));

if (DEBUG) {
table.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
printDebugData(table);
}
});
}

javax.swing.JScrollPane sp = new javax.swing.JScrollPane
(table);

add(sp);

}
catch(Exception exp)
{
exp.printStackTrace();
}
}

private void printDebugData(JTable table) {
int numRows = table.getRowCount();
int numCols = table.getColumnCount();
javax.swing.table.TableModel model = table.getModel();

System.out.println("Value of data: ");
for (int i=0; i < numRows; i++) {
System.out.print(" row " + i + ":");
for (int j=0; j < numCols; j++) {
System.out.print(" " + model.getValueAt(i, j));
}
System.out.println();
}
System.out.println("--------------------------");
}

private static void createAndShowGUI() {
JFrame fr = new JFrame("TerminalList");
fr.setTitle("Terminals");

TerminalList newContentPane = new TerminalList();
newContentPane.setOpaque(true); //content panes must be opaque
fr.setContentPane(newContentPane);

fr.pack();
fr.setVisible(true);
}

public void setUI (UI ui, Element config) {
this.ui = ui;
}


public void actionPerformed(ActionEvent ev)
{
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}


}


TerminalList compiles OK, but on starting Q2, I get the following
errors;

java.lang.NullPointerException [ is due to System.out.println
(jdbcDriver);]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance
(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance
(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.sun.jmx.mbeanserver.MBeanInstantiator.instantiate
(MBeanInstantiator.java:264)
at com.sun.jmx.mbeanserver.MBeanInstantiator.instantiate
(MBeanInstantiator.java:577)
at com.sun.jmx.mbeanserver.MBeanInstantiator.instantiate
(MBeanInstantiator.java:484)
at com.sun.jmx.mbeanserver.JmxMBeanServer.instantiate
(JmxMBeanServer.java:950)
at org.jpos.q2.QFactory.instantiate(QFactory.java:91)
at org.jpos.q2.Q2.deploy(Q2.java:431)
at org.jpos.q2.Q2.deploy(Q2.java:270)
at org.jpos.q2.Q2.run(Q2.java:183)
at java.lang.Thread.run(Thread.java:619)
<log realm="Q2.system" at="Mon Jul 27 10:01:18 EAT 2009.610">
<warn>
deploy
<exception name="MBean class org.jpos.ui.action.TerminalList does not
implement DynamicMBean, neither follows the Standard MBean
conventions
(javax.management.NotCompliantMBeanException: Class
org.jpos.ui.action.TerminalList is not a JMX compliant Standard
MBean)
nor the MXBean conventions
(javax.management.NotCompliantMBeanException:
org.jpos.ui.action.TerminalList: Class
org.jpos.ui.action.TerminalList
is not a JMX compliant MXBean)">

thanks&regards,



On Jul 24, 5:51 pm, Mark Salter <marksal...@talktalk.net> wrote:
> Alejandro Revilla wrote:
> > So you could modify your TerminalListconfigurationto look like
> > this:
>
> >   <object class="org.jpos.ui.action.TerminalList" id="terminallist">
> >    <jdbc-driver>xxx</jdbc-driver>
> >    <jdbc-url>xxx</jdbc-url>
> >   </object>
>
> > Your setUI implementation could use code like this:
>
> > class TerminalList implements UIAware ... {
> >     ...
> >     ...
> >     public void setUI (UI ui, Element config) {
> >       String jdbcDriver = config.getChildTextTrim("jdbc-driver")
> >       String jdbcUrl = config.getChildTextTrim("jdbc-url");
> >     }
> > }
>
> > We hope this solves your issue.
>
> Thanks Alejandro - it was the detail on theinterfaceI was missing and
> hoping to discover/investigate in seeing the code 8).
>
> --

Mark Salter

ungelesen,
30.07.2009, 07:43:5630.07.09
an jpos-...@googlegroups.com
mwyc...@gmail.com wrote:

>
> Below are the src files as per Mark's request;

>
> 3. TerminalList.java

This copy of the file is suffering a number of problems and does not
compile, perhaps try again?

As a 'for instance field' 'config' is never defined and you have some
badly placed field definitions?

Can you also describe for the list, what your intent is with two deploy
files?

--
Mark

mwyc...@gmail.com

ungelesen,
31.07.2009, 03:34:0731.07.09
an jPOS Users
Hello,

Sorry I had just misplaced the "{" and hadn't declared the "config"
variable.
I corrected that and the file compiles;
public Element config;
> Can you also describe for the list, what your intent is with two deploy
> files?
I didn't get this question clearly, please re-phrase for me.
Which deploy files are your refering to in this case?

thanks

On Jul 30, 2:43 pm, Mark Salter <marksal...@talktalk.net> wrote:

Mark Salter

ungelesen,
31.07.2009, 04:01:2231.07.09
an jpos-...@googlegroups.com
mwyc...@gmail.com wrote:

>> Can you also describe for the list, what your intent is with two deploy
>> files?
> I didn't get this question clearly, please re-phrase for me.
> Which deploy files are your refering to in this case?

You currently have two deploy files using your TerminalList, why do you
need both?

Which is your main focus?

--
Mark

Mark Salter

ungelesen,
31.07.2009, 04:45:5731.07.09
an jpos-...@googlegroups.com
mwyc...@gmail.com wrote:
> TerminalList compiles OK, but on starting Q2, I get the following
> errors;
>
> java.lang.NullPointerException [ is due to System.out.println
> (jdbcDriver);]

This is because config is currently null...

You need to does this work later (not in the constructor), perhaps after
the setUI method has been called to pass in the config?


--
Mark

mwyc...@gmail.com

ungelesen,
31.07.2009, 13:57:0131.07.09
an jPOS Users
Hello,

By deploy files are you refering to myconfig.xml and ISOmeter.xml?
I am using myconfig.xml as the configuration file for my TerminalList
and is where am setting the values for the variables that I want to
use in TerminalList.
Meanwhile, in the ISometer.xml, I have a menuitem that access the
TerminalList Class.

On the ISometer GUI, when someone clicks on the OUR ATMs menu item, a
the class TerminalList is invoked which in turn pops up a JTable with
values
picked from the database.
I don't want to hard code the connection parameters to the db, I want
to supply them in a config file, thats why am trying to use
myconfig.xml.

jdbcdriver=config.getChildTextTrim("jdbc-driver");

//Class.forName ("com.sybase.jdbc2.jdbc.SybDriver");
Class.forName (jdbcdriver);



regards,


On Jul 31, 11:01 am, Mark Salter <marksal...@talktalk.net> wrote:

Mark Salter

ungelesen,
31.07.2009, 14:56:4331.07.09
an jpos-...@googlegroups.com
mwyc...@gmail.com wrote:

>
> By deploy files are you refering to myconfig.xml and ISOmeter.xml?

Yes, referring to the folder they sit in under jpos-ee.

> I am using myconfig.xml as the configuration file for my TerminalList
> and is where am setting the values for the variables that I want to
> use in TerminalList.

So you are trying to set-up a QBean (with config) that is referenced
from the gui component?

To do this your TerminalList needs to be a QBean and this implement the
correct interfaces - I think this is your current issue.


> Meanwhile, in the ISometer.xml, I have a menuitem that access the
> TerminalList Class.

Your gui will need to pull the TerminalList object (that has picked up
it's config) from the NameRegister, at present you are directly
instancing an object that cannot get at it's config.

>
> On the ISometer GUI, when someone clicks on the OUR ATMs menu item, a
> the class TerminalList is invoked which in turn pops up a JTable with
> values
> picked from the database.

Ok.

> I don't want to hard code the connection parameters to the db, I want
> to supply them in a config file, thats why am trying to use
> myconfig.xml.
>
> jdbcdriver=config.getChildTextTrim("jdbc-driver");
>
> //Class.forName ("com.sybase.jdbc2.jdbc.SybDriver");
> Class.forName (jdbcdriver);

Ideally the component you are instancing in the gui component should be
able to get some 'gui config' - I think there is likely a place you
could put config - but it is not obvious (to me) where at this point.

I don't think you *need* a separately deployed object *just* to pass in
some config - there must be a more direct way.

As noted in another reply, your current NPE is because your config
object has not been initialised and is null. This is just a coding
error I'm afraid - and comes about from your use within the ui component.

The arrangement of components and config needs some work too.

I will try and take a look as the jPos ui components are new to me - so
I am interested in discovering how they work...

... but of course time is limited.

--
Mark

Mark Salter

ungelesen,
01.08.2009, 05:57:1301.08.09
an jpos-...@googlegroups.com
Mark Salter wrote:

There will be other ways to achieve the same, but here is my suggestion...

If you modify your ISOServer.xml to include :-

<object class="org.jpos.ui.action.TerminalList" id="terminallist"

jdbc-driver="com.sybase.jdbc2.jdbc.SybDriver"
jdbc-url="jdbc:sybase:Tds:neptune002:5000/test_db"/>

<object class="org.jpos.ui.action.Exit" id="exit" />
<object class="org.jpos.ui.action.Debug" id="debug" />
</qbean>

Then jdbc-driver & jdbc-url are available as Attributes within the
config passed to your setUI method, allowing you to:-

jdbcurl=config.getAttributeValue("jdbc-url");
jdbcdriver=config.getAttributeValue("jdbc-driver");

You can get rid of your myconfig.xml - it is then redundant (if it ever
wasn't!).

I don't have your full environment to test, but I checked the attributes
make it through ok.

May I suggest that in future you setup a development environment so you
may debug your code and processes. It is very easy then to see what is
happening. I think you are working blind and making bad guesses as to
what *might* happen, thus causing you more grief than needed (and then
us) 8).

Is the check in the post?

--
Mark

mwyc...@gmail.com

ungelesen,
03.08.2009, 04:35:5703.08.09
an jPOS Users
Thanks alot Mark.

I have tried out your suggestion below;
> If you modify your ISOServer.xml to include :- (Hope here you meant ISOMeter.xml)
> <object class="org.jpos.ui.action.TerminalList" id="terminallist" jdbc-driver="com.sybase.jdbc2.jdbc.SybDriver jdbc-url="jdbc:sybase:Tds:neptune002:5000/test_db"/>

> <object class="org.jpos.ui.action.Exit" id="exit" />
> <object class="org.jpos.ui.action.Debug" id="debug" />
> </qbean>

However, I still get some error on launching the Q2, but am nolonger
getting the errors due to not implementating DynamicMbean.

Below is the stack Trace;
java.lang.NullPointerException
at org.jpos.ui.action.TerminalList.<init>(TerminalList.java:
51)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0
(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance
(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance
(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:
513)
at com.sun.jmx.mbeanserver.MBeanInstantiator.instantiate
(MBeanInstantiator.java:264)
at com.sun.jmx.mbeanserver.MBeanInstantiator.instantiate
(MBeanInstantiator.java:577)
at com.sun.jmx.mbeanserver.MBeanInstantiator.instantiate
(MBeanInstantiator.java:484)
at com.sun.jmx.mbeanserver.JmxMBeanServer.instantiate
(JmxMBeanServer.java:950)
at org.jpos.q2.QFactory.newInstance(QFactory.java:332)
at org.jpos.q2.ui.UI.newInstance(UI.java:56)
at org.jpos.ui.UI.createObjects(UI.java:500)
at org.jpos.ui.UI.configure(UI.java:225)
at org.jpos.ui.UI.configure(UI.java:168)
at org.jpos.q2.ui.UI.startService(UI.java:46)
at org.jpos.q2.QBeanSupport.start(QBeanSupport.java:114)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2
(StandardMBeanIntrospector.java:93)
at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2
(StandardMBeanIntrospector.java:27)
at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM
(MBeanIntrospector.java:208)
at com.sun.jmx.mbeanserver.PerInterface.invoke
(PerInterface.java:120)
at com.sun.jmx.mbeanserver.MBeanSupport.invoke
(MBeanSupport.java:262)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke
(DefaultMBeanServerInterceptor.java:836)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke
(JmxMBeanServer.java:761)
at org.jpos.q2.QFactory.startQBean(QFactory.java:199)
at org.jpos.q2.Q2.start(Q2.java:468)
at org.jpos.q2.Q2.deploy(Q2.java:286)
at org.jpos.q2.Q2.run(Q2.java:183)
at java.lang.Thread.run(Thread.java:619)

See the new definition for the TerminalList.java, please advise if
it's fine especially on how I have place the setUI and how I have
declared the ui and config variables.
jdbcurl=config.getAttributeValue("jdbc-url");
jdbcdriver=config.getAttributeValue("jdbc-driver");

> May I suggest that in future you setup a development environment so you
> may debug your code and processes.
Yes, I will try and adopt this approach, I believe it's a better one.

> To do this your TerminalList needs to be a QBean and this implement the
> correct interfaces - I think this is your current issue.
Indeed this is where my issue is

thanks

Mark Salter

ungelesen,
03.08.2009, 06:46:2903.08.09
an jpos-...@googlegroups.com
mwyc...@gmail.com wrote:

> public TerminalList()
> {
> GridLayout layout = new GridLayout(1,0);
>
> try
> {
>
> jdbcurl=config.getAttributeValue("jdbc-url");
> jdbcdriver=config.getAttributeValue("jdbc-driver");

At this point config is null. You cannot use the config until *after*
your setUI method has been called *and* you have set your config from
that passed in.

This is now a total java issue, I am not doing your java coding and
debugging for you...


> public void setUI (UI ui, Element config) {
> this.ui = ui;

this.config = config;


... over to you.

--
Mark

mwyc...@gmail.com

ungelesen,
04.08.2009, 06:38:1204.08.09
an jPOS Users
Thanks for all the assistance rendered,

I finally got a work around and it's now working fine.
All along I didn't know at what point the configuration was being
invoked, but i foundout that it's set when an action is Performed,
so what I did was to split my TerminalList into two and I call up the
other part under actionPerformed; Then I can access the config in my
TerminalList2,
and get the values for the respective attributes.

package org.jpos.ui.action;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.jdom.Element;
import org.jpos.ui.UI;
import org.jpos.ui.UIAware;

public class TerminalList implements ActionListener, UIAware {

public static UI ui;
public static Element config;

public void setUI (UI ui, Element config) {
this.ui = ui;
this.config = config;

}

public TerminalList() {

super();
}



public void actionPerformed(ActionEvent ev)
{

TerminalList2 t = new TerminalList2();
t.setVisible(true);

}
}

thanks again for all the help.

regards,

On Aug 3, 1:46 pm, Mark Salter <marksal...@talktalk.net> wrote:
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten