Re: Flash and WebObjects...Make it Work with XML or other ?
Re: Flash and WebObjects...Make it Work with XML or other ?
- Subject: Re: Flash and WebObjects...Make it Work with XML or other ?
- From: Kieran Kelleher <email@hidden>
- Date: Fri, 9 Sep 2005 14:09:53 -0400
Nathan,
I hope this helps a little.........
Commons Logging is really only a bridge or interface to a logging
system of choice. The developers objective was not to be dependent on a
specific logging system, however commons logging defaults to using
log4j. In other words, commons logging just passes through logging
responsibility to the actual installed logger. The jakarta common
logging docs describe how it discovers what logging system is in use.
http://jakarta.apache.org/commons/logging/guide.html#Configuration
I use jakarta HTTPClient which uses commons logging and I have no
issues. I also use Project Wonder (compiled from a few weeks ago)
In /Library/Java/Extensions, I have commons-logging and log4j-1.2.9.
AFAIK the commons-logging and the log4j must be in the same directory.
In my application Properties file, logging is configured something like
this:
########################################################################
#
# ERXLogger
########################################################################
#
# Pattern codes:
# %-5p : Priority DEBUG, INFO, WARN, etc.
# %d{ISO08601} : Date and time
# %t : Thread
# %c : Logger name (usually a class name)
# %m%n : Log message followed by line feed
# Available levels are DEBUG, INFO, WARN, ERROR, FATAL
//log4j appender and formatting
log4j.rootLogger=WARN, A1, A2
log4j.loggerFactory=er.extensions.ERXLogger$Factory
# A1 is a ConsoleAppender
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=er.extensions.ERXPatternLayout
log4j.appender.A1.layout.ConversionPattern=%r %-5p [%t] (%C, %M, %L) -
%n%m%n%n
# A2 is a DailyRollingFileAppender
log4j.appender.A2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A2.file=/var/log/webobjects_apps/log4j_myapp.log
log4j.appender.A2.datePattern='.'yyyy-MM-dd
log4j.appender.A2.append=true
log4j.appender.A2.layout=er.extensions.ERXPatternLayout
log4j.appender.A2.layout.ConversionPattern=%-5p %d{ISO8601} [%t] (%c) -
%m%n
# Project Wonder logger configuration
# ---------------------------
er.extensions.ERXNSLogLog4jBridge=INFO
___________________________________
D. Kieran Kelleher
Palm Harbor, Florida USA
On Sep 8, 2005, at 9:11 PM, Nathan Walker wrote:
well, i love the api for Digester and I believe I have everything
good, but since I use ERExtensions and log4j, I believe it interferes
with the commons-logging package and I receive an error because
Digester is dependent on commons-logging. This is the Exception/Error
I get:
org.apache.commons.logging.LogConfigurationException:
org.apache.commons.logging.LogConfigurationException: No suitable Log
constructor [Ljava.lang.Class;@d1223d for
org.apache.commons.logging.impl.Log4JLogger (Caused by
java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by
org.apache.commons.logging.LogConfigurationException: No suitable Log
constructor [Ljava.lang.Class;@d1223d for
org.apache.commons.logging.impl.Log4JLogger (Caused by
java.lang.NoClassDefFoundError: org/apache/log4j/Category))
If I could get around that error, I believe Digester would be the way
to go. I have all the dependent jar files downloaded needed for
Digester including the common-logging.jar so I'm left there....
I might go back to WOXMLCoding to see if I can get to the bottom of
the ArrayIndexOutOfBoundsException...
On Sep 8, 2005, at 6:28 PM, Chuck Hill wrote:
Save yourself some hair.
http://www.javaworld.com/javaworld/jw-10-2002/jw-1025-
opensourceprofile.html
Chuck
On Sep 8, 2005, at 3:17 PM, Nathan Walker wrote:
OK, so I got it to read in the XML now without the
MalformedURLException but now I get this:
2005-09-08 18:09:47,258 WARN TikiBarz[49613] NSLog
(ERXNSLogLog4jBridge.java:41) - <DirectAction>: Exception in
performActionNamed() on the action "newOrder" with the message:
java.lang.ArrayIndexOutOfBoundsException: -1
[2005-09-08 18:09:47 EDT] <WorkerThread13>
java.lang.ArrayIndexOutOfBoundsException: -1
at
com.webobjects.appserver.xml._private._MappingHandler.endElement(_Mappi
ngHandler.java:119)
at
org.apache.xerces.parsers.AbstractSAXParser.endElement(AbstractSAXParse
r.java:577)
at
org.apache.xerces.impl.XMLNamespaceBinder.handleEndElement(XMLNamespace
Binder.java:898)
at
org.apache.xerces.impl.XMLNamespaceBinder.endElement(XMLNamespaceBinder
.java:644)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XM
LDocumentFragmentScannerImpl.java:1008)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDi
spatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1469)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLD
ocumentFragmentScannerImpl.java:329)
at
org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:
525)
at
org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:
581)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
at
org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.jav
a:1175)
at
com.webobjects.appserver.xml.WOXMLDecoder.decodeRootObject(WOXMLDecoder
.java:700)
at
com.webobjects.appserver.xml.WOXMLDecoder.decodeRootObject(WOXMLDecoder
.java:676)
at XMLDecodeMachine.decodeXML(XMLDecodeMachine.java:26)
at DirectAction.newOrderAction(DirectAction.java:47)
And index out of bounds exception ?? now, that seems it would have
something to do with the XML or mapping model..Here is the XML and
below it is the mapping model I'm using (the mapping model is bare
because I'm just trying to get it working, then I would add mapping
for all the attributes):
<customizebar><step1><roofSelection>Palm
Branches</roofSelection><frontPanalSelection>Bamboo</
frontPanalSelection></step1><step2><customBarTop>None</customBarTop></
step2><step3><accessories>None</accessories></step3><step4><order
OrderTotal="4625" OrderNumber="50480"><firstname></firstname><lastname
/><address></address><city></city><state>AL</state><zip></
zip><phone></phone><email></email><username></username><password></
password><cardname></cardname><cardnum></cardnum><cardexp>/</
cardexp><cardtype>Visa</cardtype></order></step4></customizebar>
Mapping Model:
<model>
<entity name="CustomBar" xmlTag="customizebar"
ignoreUnmappedTags="YES">
<property name="roof" xmlTag="roofSelection" />
<property name="front" xmlTag="frontPanalSelection" />
</entity>
<entity name="CustomBar" xmlTag="CustomBarTop"
ignoreUnmappedTags="YES">
<property name="customName" xmlTag="CustomName"
attribute="YES" />
</entity>
<entity name="Orders" xmlTag="order" ignoreUnmappedTags="YES">
<property name="orderTotal" xmlTag="OrderTotal"
attribute="YES" />
<property name="orderNumber" xmlTag="OrderNumber"
attribute="YES" />
</entity>
</model>
I'm trying everything thing here and trying not to go insane.....
On Sep 8, 2005, at 2:05 PM, Nathan Walker wrote:
Wow, I am starting to make stupid mistakes because I have been
battling this off and on for the past two weeks and I've about thrown
my hands up on this one and I've just started to become angry as to
why dealing with XML has become so difficult for me. Thanks for the
hard clarification, I needed that !
I have been dragging on this project because of this and I am just
ready to have this part figured out...
Frustration definitely causes dumb mistakes and ridiculous oversight...
On Sep 8, 2005, at 1:33 PM, Chuck Hill wrote:
Nathan,
On Sep 8, 2005, at 8:58 AM, Nathan Walker wrote:
I gave this a try and I am still getting a MalformedURLException.
Debugging requires careful reading of the API and stack trace and a
scientific approach of hypothesis, test, repeat. You are making
assumptions and jumping to incorrect conclusions. That is not an
effective way of finding bugs.
I will restate the above (from your point of view) as: I made several
changes and I am getting a MalformedURLException which I am assuming
is coming from the same place that it originally did.
Here's the part of the stack trace:
Read carefully now, top to bottom:
[2005-09-08 11:54:56 EDT] <WorkerThread13>
com.webobjects.foundation.NSForwardException for
java.net.MalformedURLException
at java.net.URL.<init>(URL.java:571)
at java.net.URL.<init>(URL.java:434)
at java.net.URL.<init>(URL.java:383)
at
org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.ja
va:807)
at
org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(XMLEntityMa
nager.java:753)
at
org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(XMLDocumen
tScannerImpl.java:260)
at
org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:
499)
at
org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:
581)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
at
org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.jav
a:1114)
at
com.webobjects.appserver.xml._private._MappingModel.mappingModelWithXML
File(_MappingModel.java:405)
at
com.webobjects.appserver.xml._private._WOXMLMappingDecoder.<init>(_WOXM
LMappingDecoder.java:121)
at
com.webobjects.appserver.xml.WOXMLDecoder.decoderWithMapping(WOXMLDecod
er.java:581)
This tells us that the exception is coming from a call to
decoderWithMapping() on WOXMLDecoder. This call happens at this line:
at XMLDecodeMachine.decodeXML(XMLDecodeMachine.java:25)
at DirectAction.newOrderAction(DirectAction.java:47)
the XMLDecodeMachine.decodeXML method is here (with line 25 denoted):
public String decodeXML (String theXML) {
mappingFile =
application().resourceManager().pathForResourceNamed("OrderXMLModel.xml
", null, null);
NSData xmlData = new NSData(theXML, "UTF-8");
line 25 --> CustomBar custBar =
(CustomBar)WOXMLDecoder.decoderWithMapping(mappingFile).decodeRootObjec
t(xmlData);
System.out.println(custBar);
So the error is coming from
WOXMLDecoder.decoderWithMapping(mappingFile). That indicates that it
is mappingFile _not_ xmlData that is in error. The mapppingFile
parameter should be "an URL to the mapping file that specifies the
mapping model". You are creating mappingFile like this:
mappingFile =
application().resourceManager().pathForResourceNamed("OrderXMLModel.xml
", null, null);
pathForResourceNamed returns a path, not a URL. A path is not a URL
and so a MalformedURLException would be expected. Read the
WOResourceManager API more thoroughly. Notice there is a method
urlForResourceNamed. That will probably work but you will still need
to make it absolute which is probably more work than you want. First,
I would try adding 'file://' to the start of mappingFile to see if
that works. Also see the maze of java.net.URL and java.net.URI.
return "Done";
}
I don't understand why I am getting the malformedURLException...I'm
passing in an NSData object which is acceptable. I AM CONFUSED here.
It's just not making sense !!
That is because you are assuming that it is coming from where it is
not. :-)
Chuck
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
--
Practical WebObjects - a book for intermediate WebObjects developers
who want to increase their overall knowledge of WebObjects, or those
who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden