• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Flash and WebObjects...Make it Work with XML or other ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Flash and WebObjects...Make it Work with XML or other ?


  • Subject: Re: Flash and WebObjects...Make it Work with XML or other ?
  • From: Chuck Hill <email@hidden>
  • Date: Fri, 9 Sep 2005 11:59:55 -0700


On Sep 9, 2005, at 11:41 AM, Nathan Walker wrote:

Well Chuck, there's a reason why you're the man.

Yeah, 'cause I've already shot off all of my toes and most of my fingers and the extreme pain has made the memories stick with me.



That worked perfectly. I downloaded the latest version of log4j and replaced it in /Library/WebObjects/Extensions and then moved all the Digester jar's and related jar's from /Library/Java/Extensions to /Library/WebObjects/Extensions and everything is working like a charm now.

Library/Java/Extensions is a dangerous place to use as general home for stray jar files.


I have one last question and I believe the XML woes are over now and the Digester api's are great I think.

It is pretty clean when compared to the alternatives.


From a performance standpoint (I'm not real versed in InputStreams and Buffers) but would the code below be best using the BufferedInputStream to pass to the parse() method:

NSData xmlData = new NSData(theXML, "UTF-8");
BufferedInputStream bis = new BufferedInputStream(xmlData.stream());

Digester digester = new Digester();
digester.push(this);

digester.addCallMethod("customizebar/step1", "addBarData", 2);
digester.addCallParam("customizebar/step1/roofSelection", 0);
digester.addCallParam("customizebar/step1/frontPanalSelection", 1);

digester.parse(bis); // Parsing the BufferedInputStream

OR would this be best (is there any real performance gain with the buffer basically?):

NSData xmlData = new NSData(theXML, "UTF-8");

Digester digester = new Digester();
digester.push(this);

digester.addCallMethod("customizebar/step1", "addBarData", 2);
digester.addCallParam("customizebar/step1/roofSelection", 0);
digester.addCallParam("customizebar/step1/frontPanalSelection", 1);

digester.parse(xmlData.stream()); // Parsing using the stream from the NSData object

I don't think it will make any difference in this situation. The XML stream is small and is already in memory as a form parameter. If you were uploading a file of XML and streaming the upload, then this might make more sense. I usually use a buffered one when I know the resource is not already in memory (e.g. when reading files).


Thank you for your continued help on this. You have saved me some hair no doubt...

Good to save some for next time. ;-)

Chuck



On Sep 9, 2005, at 12:10 AM, Chuck Hill wrote:

Trust in Google. Google is your friend. Google sees all. Google knows all.
http://www.google.com/search?client=safari&rls=en&q=No+suitable+Log +constructor


This seems likely:
http://www.qos.ch/logging/classloader.jsp

When you installed the stuff for Digester, did you put anything in /Library/Java/Extensions? If so, take it out. /Library/ WebObjects/Extensions is a better home.

If not that, check in /Library/WebObjects/Extensions for log4j. WO comes with a version that might be older than what the commons needs.

Chuck

On Sep 8, 2005, at 6: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 (_MappingHandler.java:119)
at org.apache.xerces.parsers.AbstractSAXParser.endElement (AbstractSAXParser.java:577)
at org.apache.xerces.impl.XMLNamespaceBinder.handleEndElement (XMLNamespaceBinder.java:898)
at org.apache.xerces.impl.XMLNamespaceBinder.endElement (XMLNamespaceBinder.java:644)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndEleme nt(XMLDocumentFragmentScannerImpl.java:1008)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl $FragmentContentDispatcher.dispatch (XMLDocumentFragmentScannerImpl.java:1469)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument (XMLDocumentFragmentScannerImpl.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.java: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.java:807)
at org.apache.xerces.impl.XMLEntityManager.startDocumentEntity (XMLEntityManager.java:753)
at org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource (XMLDocumentScannerImpl.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.java:1114)
at com.webobjects.appserver.xml._private._MappingModel.mappingMode lWithXMLFile(_MappingModel.java:405)
at com.webobjects.appserver.xml._private._WOXMLMappingDecoder.<ini t>(_WOXMLMappingDecoder.java:121)
at com.webobjects.appserver.xml.WOXMLDecoder.decoderWithMapping (WOXMLDecoder.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).decodeRootObject (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:
40visionworxpro.com


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











--
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









--
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: This email sent to email@hidden
References: 
 >Re: Flash and WebObjects...Make it Work with XML or other ? (From: Nathan Walker <email@hidden>)
 >Re: Flash and WebObjects...Make it Work with XML or other ? (From: Chuck Hill <email@hidden>)
 >Re: Flash and WebObjects...Make it Work with XML or other ? (From: Nathan Walker <email@hidden>)
 >Re: Flash and WebObjects...Make it Work with XML or other ? (From: Chuck Hill <email@hidden>)
 >Re: Flash and WebObjects...Make it Work with XML or other ? (From: Nathan Walker <email@hidden>)
 >Re: Flash and WebObjects...Make it Work with XML or other ? (From: Chuck Hill <email@hidden>)
 >Re: Flash and WebObjects...Make it Work with XML or other ? (From: Nathan Walker <email@hidden>)
 >Re: Flash and WebObjects...Make it Work with XML or other ? (From: Nathan Walker <email@hidden>)
 >Re: Flash and WebObjects...Make it Work with XML or other ? (From: Nathan Walker <email@hidden>)
 >Re: Flash and WebObjects...Make it Work with XML or other ? (From: Chuck Hill <email@hidden>)
 >Re: Flash and WebObjects...Make it Work with XML or other ? (From: Nathan Walker <email@hidden>)

  • Prev by Date: Re: Flash and WebObjects...Make it Work with XML or other ?
  • Next by Date: XCode Java Code Completion
  • Previous by thread: Re: Flash and WebObjects...Make it Work with XML or other ?
  • Next by thread: Re: Flash and WebObjects...Make it Work with XML or other ?
  • Index(es):
    • Date
    • Thread