You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by James Strachan <ja...@yahoo.co.uk> on 2002/12/06 19:16:10 UTC

Re: [messenger] problem running messenger

From: "Jukka Nikki" <Ju...@Kolumbus.fi>
> Hi James,
>
> I'm sorry to disturb you, but I do have problem with nightly build of
> messenger. I think I do have all needed libraries, but system halts within
> first test to "java.lang.NoSuchMethodError" message..
>
> ..
>
> 2002-12-06 07:41:40 - Ctx( /mestest ): Exception in: R( /mestest +
> /sendmessageservlet + null) - java.lang.NoSuchMethodError at
> org.apache.commons.digester.Digester.getXMLReader(Digester.java:607) at
> org.apache.commons.digester.Digester.parse(Digester.java:1338) at

The problem appears to be in digester performing a SAX parse, rather than in
messenger per-se. So it seems like you've an old SAX jar on the classpath
somewhere?

It might be worth trying the xml-apis-1.0b2.jar instead as thats actually
more recent (the 2.0.* versions are wrong).

http://www.ibiblio.org/maven/xml-apis/jars/

Unless someone else has any bright ideas?


>
org.apache.commons.messenger.MessengerManager.load(MessengerManager.java:57)
> ..
>
> I'd like to know if 5.12.2002 build is stable enought or should I try some
> other and if these dependencies are still correct.
>
> commons-logging  1.0  commons-logging-1.0.jar
> commons-beanutils  1.3  commons-beanutils-1.3.jar
> commons-collections  2.0  commons-collections-2.0.jar
> commons-digester  1.2  commons-digester-1.2.jar
> servletapi  2.3  servletapi-2.3.jar
> jms  1.0.2b  jms-1.0.2b.jar
> xml-apis  2.0.0  xml-apis-2.0.0.jar
> ant  1.4.1  ant-1.4.1.jar
> junit  3.7  junit-3.7.jar
>
> I had some problems finding xml-apis, which is the correct place to look
for
> them?
>
> I am testing with WLS 7.0+SP1 - is there any mysteries with it?
>
> I'm glad if you have time to help me, this is quite nice abstraction and
it
> deserves to become widely used..

Thanks!

James
-------
http://radio.weblogs.com/0112098/

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

RE: BeanUtils and Dates

Posted by Greg Dunn <gr...@nisc.cc>.
robert:

Thanks for the assistance.  As it happens storing the value as a Timestamp
suits my purposes and it works with "off the shelf" BeanUtils.  However I'm
sure your solution will come in handy with other nonstandard data I need to
deal with.

Greg


-----Original Message-----
From: robert burrell donkin
[mailto:robertburrelldonkin@blueyonder.co.uk]
Sent: Saturday, December 07, 2002 3:26 PM
To: Jakarta Commons Users List
Subject: Re: BeanUtils and Dates


hi greg

the standard SqlDateConvertor in beanutils uses java.sql.Date.valueOf to
perform the conversion. this method requires a date in sql date format ie
yyyy-mm-dd. i don't think that the conversion will work given an input in
your format.

there is an easy way to make this work in beanutils. you can create a
custom converter and then register it to handle your java.sql.date's.

i'd create a custom convertor by extending SqlDateConverter and overriding
convert with something like

<untested-code-warning>

public Object convert(Class type, Object value) {

	if (value == null) {
		return super.convert(type, value);
	}

	return super.convert(type, value.toString().substring(0, 10));

}

</untested-code-warning>

see java docs for explanation of how to register a custom converter.

- robert

On Friday, December 6, 2002, at 06:32 PM, Greg Dunn wrote:

> I'm using BeanUtils to populate a bean with records from a resultSet via
> a
> HashMap built using the metadata.getColumnName for property names and the
> rst.getString for values in the usual way.  A date field in the resultSet
> (we'll call it "myDate") is causing an exception.
>
> Debug log shows ConvertUtils is attempting to "Convert string '2002-09-25
> 01:05:43.0' to class 'java.sql.Date'" but it cannot and throws a
> ConversionException.
>
> My bean imports java.sql.Date, and the instance variable is:
>
> 	private Date myDate = null;
>
> My setter is:
>
> 	public void setMyDate(Date myDate) {
> 		this.myDate = myDate;
> 	}
>
> How do I get the date into my bean as a date?  Am I stuck with setting it
> as
> a String?
>
> Greg
>
>
> --
> To unsubscribe, e-mail:   <mailto:commons-user-unsubscribe@jakarta.apache.
> org>
> For additional commands, e-mail: <mailto:commons-user-help@jakarta.apache.
> org>
>


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>




Re: BeanUtils and Dates

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
hi greg

the standard SqlDateConvertor in beanutils uses java.sql.Date.valueOf to 
perform the conversion. this method requires a date in sql date format ie 
yyyy-mm-dd. i don't think that the conversion will work given an input in 
your format.

there is an easy way to make this work in beanutils. you can create a 
custom converter and then register it to handle your java.sql.date's.

i'd create a custom convertor by extending SqlDateConverter and overriding 
convert with something like

<untested-code-warning>

public Object convert(Class type, Object value) {
	
	if (value == null) {
		return super.convert(type, value);
	}	

	return super.convert(type, value.toString().substring(0, 10));

}

</untested-code-warning>

see java docs for explanation of how to register a custom converter.

- robert

On Friday, December 6, 2002, at 06:32 PM, Greg Dunn wrote:

> I'm using BeanUtils to populate a bean with records from a resultSet via 
> a
> HashMap built using the metadata.getColumnName for property names and the
> rst.getString for values in the usual way.  A date field in the resultSet
> (we'll call it "myDate") is causing an exception.
>
> Debug log shows ConvertUtils is attempting to "Convert string '2002-09-25
> 01:05:43.0' to class 'java.sql.Date'" but it cannot and throws a
> ConversionException.
>
> My bean imports java.sql.Date, and the instance variable is:
>
> 	private Date myDate = null;
>
> My setter is:
>
> 	public void setMyDate(Date myDate) {
> 		this.myDate = myDate;
> 	}
>
> How do I get the date into my bean as a date?  Am I stuck with setting it 
> as
> a String?
>
> Greg
>
>
> --
> To unsubscribe, e-mail:   <mailto:commons-user-unsubscribe@jakarta.apache.
> org>
> For additional commands, e-mail: <mailto:commons-user-help@jakarta.apache.
> org>
>


BeanUtils and Dates

Posted by Greg Dunn <gr...@nisc.cc>.
I'm using BeanUtils to populate a bean with records from a resultSet via a
HashMap built using the metadata.getColumnName for property names and the
rst.getString for values in the usual way.  A date field in the resultSet
(we'll call it "myDate") is causing an exception.

Debug log shows ConvertUtils is attempting to "Convert string '2002-09-25
01:05:43.0' to class 'java.sql.Date'" but it cannot and throws a
ConversionException.

My bean imports java.sql.Date, and the instance variable is:

	private Date myDate = null;

My setter is:

	public void setMyDate(Date myDate) {
		this.myDate = myDate;
	}

How do I get the date into my bean as a date?  Am I stuck with setting it as
a String?

Greg


Re: [messenger] problem running messenger

Posted by James Strachan <ja...@yahoo.co.uk>.
Thanks for this Jukkis. Sorry it took so long to get to, but I've finally
committed your WebLogic deployment descriptor.

Incidentally rather than write 2 new programs to send & receive, you can
reuse the existing utillity programs to send & receive messages using your
config file.

e.g. instead of SendTest and Receive test you could do

java -Dorg.apache.commons.messenger=file:c:/dev/messengertest/messenger.xml
\
    org.apache.commons.messenger.tool.Producer \
    weblogic.examples.jms.exampleQueue message.txt

Where 'weblogic.examples.jms.exampleQueue' = the queue to use and
'message.txt' is a file name containing the message to be sent.

The above will send the message on the queue using your deployment
descriptor. Then to consume the message try..

java -Dorg.apache.commons.messenger=file:c:/dev/messengertest/messenger.xml
\
    org.apache.commons.messenger.tool.Consumer \
    weblogic.examples.jms.exampleQueue

James
-------
http://radio.weblogs.com/0112098/
----- Original Message -----
From: "Jukka Nikki" <Ju...@Kolumbus.fi>
To: "James Strachan" <ja...@yahoo.co.uk>;
<co...@jakarta.apache.org>
Sent: Friday, December 06, 2002 6:52 PM
Subject: VS: [messenger] problem running messenger


> Thanks James,
>
> I did find the problem. Tomcat 3.2.1 embedded inside JBuilder 5 did the
> trick. After this it was quite straightforward, some quirks still..
>
> 1) Sample messenger.xml did contain reference to dtd file that I didn't
have
> (I took reference off)
> 2) Properties needed some thought before I got them fine (studied
> javax.naming.Context static values)
> 3) Examples just needed addition of exception handling
>
> To help any of you I'll put what I did to this message. This works with
> WLS7+SP1 example server. Just install it, change configuration file path
> from source and run these from your command line..
>
> Messenger.XML
> -------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <manager>
>   <!-- WLS 7 + SP1 queue test -->
>   <messenger name="WLS_queue" jndiDestinations="true">
>     <jndi lookupName="weblogic.examples.jms.QueueConnectionFactory"
> topic="false">
>       <property>
>         <name>java.naming.factory.initial</name>
>         <value>weblogic.jndi.WLInitialContextFactory</value>
>       </property>
>       <property>
>         <name>java.naming.provider.url</name>
>         <value>t3://127.0.0.1:7001</value>
>       </property>
>     </jndi>
>   </messenger>
> </manager>
>
> SendMessage.java
> ----------------
>
> package messengertest;
>
> import org.apache.commons.messenger.*;
> import javax.jms.*;
> import javax.naming.*;
> import org.apache.commons.logging.*;
>
> public class sendMessage {
>
>   public static void main(String[] args) {
>     // sending
>     //Log log = logFactory
>     Log log = LogFactory.getLog("Tester");
>     try {
>       // --- NOTE: Change path!!!
>
MessengerManager.configure("file:c:/dev/messengertest/messenger.xml");
>       log.info("Messenger configured");
>       // get a Messenger and Destination
>       Messenger messenger = MessengerManager.get("WLS_queue");
>       log.info("WLS_queue initialized");
>       Destination destination = messenger.getDestination
> ("weblogic.examples.jms.exampleQueue");
>       log.info("Destination found");
>       // now lets send a message
>       TextMessage message = messenger.createTextMessage("testi");
>       log.info("Message created");
>       messenger.send( destination, message );
>       log.info("Message sent");
>     } catch (JMSException e) {
>       e.printStackTrace();
>       log.error("Sending error", e);
>     }
>   }
> }
>
> ReadMessage.java
> ----------------
>
> package messengertest;
>
> import org.apache.commons.messenger.*;
> import javax.jms.*;
> import org.apache.commons.logging.*;
>
> public class ReadMessage {
>
>   public static void main(String[] args) {
>     // sending
>     //Log log = logFactory
>     Log log = LogFactory.getLog("Tester");
>     try {
>       // --- NOTE: Change path!!!
>
MessengerManager.configure("file:c:/dev/messengertest/messenger.xml");
>       log.info("Messenger configured");
>       // get a Messenger and Destination
>       Messenger messenger = MessengerManager.get("WLS_queue");
>       log.info("WLS_queue initialized");
>       Destination destination = messenger.getDestination
> ("weblogic.examples.jms.exampleQueue");
>       log.info("Destination found");
>       // now lets read a message
>       Message message = messenger.receive(destination);
>       log.info("Message received");
>       System.out.println("Got text: "+((TextMessage)message).getText());
>       log.info("Message parsed");
>     } catch (JMSException e) {
>       e.printStackTrace();
>       log.error("receiving error", e);
>     }
>   }
> }
>
> If any of you needs straightforward message receiving and sending facade
> this one is easy to understand and gives some extras too..
>
> - Jukkis
>
> -----Alkuperäinen viesti-----
> Lähettäjä: James Strachan [mailto:james_strachan@yahoo.co.uk]
> Lähetetty: 6. joulukuuta 2002 20:16
> Vastaanottaja: Jukka Nikki; commons-user@jakarta.apache.org
> Aihe: Re: [messenger] problem running messenger
>
>
> From: "Jukka Nikki" <Ju...@Kolumbus.fi>
> > Hi James,
> >
> > I'm sorry to disturb you, but I do have problem with nightly build of
> > messenger. I think I do have all needed libraries, but system halts
within
> > first test to "java.lang.NoSuchMethodError" message..
> >
> > ..
> >
> > 2002-12-06 07:41:40 - Ctx( /mestest ): Exception in: R( /mestest +
> > /sendmessageservlet + null) - java.lang.NoSuchMethodError at
> > org.apache.commons.digester.Digester.getXMLReader(Digester.java:607) at
> > org.apache.commons.digester.Digester.parse(Digester.java:1338) at
>
> The problem appears to be in digester performing a SAX parse, rather than
in
> messenger per-se. So it seems like you've an old SAX jar on the classpath
> somewhere?
>
> It might be worth trying the xml-apis-1.0b2.jar instead as thats actually
> more recent (the 2.0.* versions are wrong).
>
> http://www.ibiblio.org/maven/xml-apis/jars/
>
> Unless someone else has any bright ideas?
>
>
> >
>
org.apache.commons.messenger.MessengerManager.load(MessengerManager.java:57)
> > ..
> >
> > I'd like to know if 5.12.2002 build is stable enought or should I try
some
> > other and if these dependencies are still correct.
> >
> > commons-logging  1.0  commons-logging-1.0.jar
> > commons-beanutils  1.3  commons-beanutils-1.3.jar
> > commons-collections  2.0  commons-collections-2.0.jar
> > commons-digester  1.2  commons-digester-1.2.jar
> > servletapi  2.3  servletapi-2.3.jar
> > jms  1.0.2b  jms-1.0.2b.jar
> > xml-apis  2.0.0  xml-apis-2.0.0.jar
> > ant  1.4.1  ant-1.4.1.jar
> > junit  3.7  junit-3.7.jar
> >
> > I had some problems finding xml-apis, which is the correct place to look
> for
> > them?
> >
> > I am testing with WLS 7.0+SP1 - is there any mysteries with it?
> >
> > I'm glad if you have time to help me, this is quite nice abstraction and
> it
> > deserves to become widely used..
>
> Thanks!
>
> James
> -------
> http://radio.weblogs.com/0112098/
>
> __________________________________________________ Do You Yahoo!?
Everything
> you'll ever need on one web page from News and Sport to Email and Music
> Charts http://uk.my.yahoo.com
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

VS: [messenger] problem running messenger

Posted by Jukka Nikki <Ju...@Kolumbus.fi>.
Thanks James,

I did find the problem. Tomcat 3.2.1 embedded inside JBuilder 5 did the
trick. After this it was quite straightforward, some quirks still..

1) Sample messenger.xml did contain reference to dtd file that I didn't have
(I took reference off)
2) Properties needed some thought before I got them fine (studied
javax.naming.Context static values)
3) Examples just needed addition of exception handling

To help any of you I'll put what I did to this message. This works with
WLS7+SP1 example server. Just install it, change configuration file path
from source and run these from your command line..

Messenger.XML
-------------

<?xml version="1.0" encoding="UTF-8"?>
<manager>
  <!-- WLS 7 + SP1 queue test -->
  <messenger name="WLS_queue" jndiDestinations="true">
    <jndi lookupName="weblogic.examples.jms.QueueConnectionFactory"
topic="false">
      <property>
        <name>java.naming.factory.initial</name>
        <value>weblogic.jndi.WLInitialContextFactory</value>
      </property>
      <property>
        <name>java.naming.provider.url</name>
        <value>t3://127.0.0.1:7001</value>
      </property>
    </jndi>
  </messenger>
</manager>

SendMessage.java
----------------

package messengertest;

import org.apache.commons.messenger.*;
import javax.jms.*;
import javax.naming.*;
import org.apache.commons.logging.*;

public class sendMessage {

  public static void main(String[] args) {
    // sending
    //Log log = logFactory
    Log log = LogFactory.getLog("Tester");
    try {
      // --- NOTE: Change path!!!
      MessengerManager.configure("file:c:/dev/messengertest/messenger.xml");
      log.info("Messenger configured");
      // get a Messenger and Destination
      Messenger messenger = MessengerManager.get("WLS_queue");
      log.info("WLS_queue initialized");
      Destination destination = messenger.getDestination
("weblogic.examples.jms.exampleQueue");
      log.info("Destination found");
      // now lets send a message
      TextMessage message = messenger.createTextMessage("testi");
      log.info("Message created");
      messenger.send( destination, message );
      log.info("Message sent");
    } catch (JMSException e) {
      e.printStackTrace();
      log.error("Sending error", e);
    }
  }
}

ReadMessage.java
----------------

package messengertest;

import org.apache.commons.messenger.*;
import javax.jms.*;
import org.apache.commons.logging.*;

public class ReadMessage {

  public static void main(String[] args) {
    // sending
    //Log log = logFactory
    Log log = LogFactory.getLog("Tester");
    try {
      // --- NOTE: Change path!!!
      MessengerManager.configure("file:c:/dev/messengertest/messenger.xml");
      log.info("Messenger configured");
      // get a Messenger and Destination
      Messenger messenger = MessengerManager.get("WLS_queue");
      log.info("WLS_queue initialized");
      Destination destination = messenger.getDestination
("weblogic.examples.jms.exampleQueue");
      log.info("Destination found");
      // now lets read a message
      Message message = messenger.receive(destination);
      log.info("Message received");
      System.out.println("Got text: "+((TextMessage)message).getText());
      log.info("Message parsed");
    } catch (JMSException e) {
      e.printStackTrace();
      log.error("receiving error", e);
    }
  }
}

If any of you needs straightforward message receiving and sending facade
this one is easy to understand and gives some extras too..

- Jukkis

-----Alkuperäinen viesti-----
Lähettäjä: James Strachan [mailto:james_strachan@yahoo.co.uk]
Lähetetty: 6. joulukuuta 2002 20:16
Vastaanottaja: Jukka Nikki; commons-user@jakarta.apache.org
Aihe: Re: [messenger] problem running messenger


From: "Jukka Nikki" <Ju...@Kolumbus.fi>
> Hi James,
>
> I'm sorry to disturb you, but I do have problem with nightly build of
> messenger. I think I do have all needed libraries, but system halts within
> first test to "java.lang.NoSuchMethodError" message..
>
> ..
>
> 2002-12-06 07:41:40 - Ctx( /mestest ): Exception in: R( /mestest +
> /sendmessageservlet + null) - java.lang.NoSuchMethodError at
> org.apache.commons.digester.Digester.getXMLReader(Digester.java:607) at
> org.apache.commons.digester.Digester.parse(Digester.java:1338) at

The problem appears to be in digester performing a SAX parse, rather than in
messenger per-se. So it seems like you've an old SAX jar on the classpath
somewhere?

It might be worth trying the xml-apis-1.0b2.jar instead as thats actually
more recent (the 2.0.* versions are wrong).

http://www.ibiblio.org/maven/xml-apis/jars/

Unless someone else has any bright ideas?


>
org.apache.commons.messenger.MessengerManager.load(MessengerManager.java:57)
> ..
>
> I'd like to know if 5.12.2002 build is stable enought or should I try some
> other and if these dependencies are still correct.
>
> commons-logging  1.0  commons-logging-1.0.jar
> commons-beanutils  1.3  commons-beanutils-1.3.jar
> commons-collections  2.0  commons-collections-2.0.jar
> commons-digester  1.2  commons-digester-1.2.jar
> servletapi  2.3  servletapi-2.3.jar
> jms  1.0.2b  jms-1.0.2b.jar
> xml-apis  2.0.0  xml-apis-2.0.0.jar
> ant  1.4.1  ant-1.4.1.jar
> junit  3.7  junit-3.7.jar
>
> I had some problems finding xml-apis, which is the correct place to look
for
> them?
>
> I am testing with WLS 7.0+SP1 - is there any mysteries with it?
>
> I'm glad if you have time to help me, this is quite nice abstraction and
it
> deserves to become widely used..

Thanks!

James
-------
http://radio.weblogs.com/0112098/

__________________________________________________ Do You Yahoo!? Everything
you'll ever need on one web page from News and Sport to Email and Music
Charts http://uk.my.yahoo.com