Re: Conflict When Having Two XMLBean Generated classes for the same Schema...

2011-06-23 Thread Kevin Krouse
If you have schemas that define components in the same namespace you'll need
to isolate the generated schema jars using classloaders.  The issue is
similar to trying to load two different java classes with the same name.

Kevin


On Thu, Jun 16, 2011 at 7:35 AM, Horst Heistermann 
horst.heisterm...@oracle.com wrote:

 Hi,

  I am having an issue in my environment because I have two XMLBean
 generated classes pointing to the same schema. Sometimes when I use the
 factory of one class
 it tries to create an instance of the other XMLBean class (even though I am
 using the factory of the class I want to create!).  This causes a
 classcastexeception

 Is there a way to avoid this? The issue is indeterminate because it works
 fine most of the time but once in a while this issue crashes the program

 Thanks,

 Horst


 --**--**-
 To unsubscribe, e-mail: 
 user-unsubscribe@xmlbeans.**apache.orguser-unsubscr...@xmlbeans.apache.org
 For additional commands, e-mail: user-h...@xmlbeans.apache.org




Re: Why is scomp trying to access remote url without -dl option set?

2011-06-23 Thread Cezar Andrei
What you get is exactly what we were expecting, from my knowledge we use a 
single resolver for all imports.
I wouldn't file a bug if you can't reproduce it anymore, but if you feel 
strongly about it go ahead.

Cezar

On Jun 22, 2011, at 2:16 PM, Jeff Martin wrote:

 Good news and bad news.
 
 I can't reproduce the exact conditions, since I don't have control 
 over www.w3.org and so I can't force the 503 for 
 http://www.w3.org/2001/xml.xsd
 
 So instead I wrote the following my.xsd:
 
  xs:schema
  xmlns:xs=http://www.w3.org/2001/XMLSchema;
  xmlns:c=my:common 
xs:import namespace=my:common
schemaLocation=http://netjeff.com/always503.cgi; /
xs:element name=My
  xs:complexType
xs:sequence
  xs:element ref=c:Common /
/xs:sequence
  /xs:complexType
/xs:element
  /xs:schema
 
 When I run scomp *without* the -dl option, scomp seems to behave 
 correctly:
 
  $ scomp -out my.jar my.xsd
 
  my.xsd:6:3: error: Could not load resource 
  http://netjeff.com/always503.cgi; (network downloads disabled).
  my.xsd:12:9: error: src-resolve: element 'Common@my:common' not found.
  Time to build schema type system: 3.097 seconds
  BUILD FAILED
 
 So that is good news that scomp *without* -dl seems to work, as seen 
 in the network downloads disabled portion of the error message.  
 But then why was scomp spitting out an error when www.w3.org was 
 returning 503, as I described below?  
 
 Since I can't force www.w3.org to return 503, I set up a page on my 
 personal server (netjeff.com) to always return 503, and set that as 
 the schemaLocation (see above).  Then I ran *with* -dl option to see 
 what the error looks like:
 
  $ scomp -dl -out my.jar my.xsd
 
  IO Error java.io.IOException: Server returned HTTP response code: 503
  for URL: http://netjeff.com/always503.cgi
  my.xsd:6:3: error: java.io.IOException: Server returned HTTP response 
  code: 503 for URL: http://netjeff.com/always503.cgi
  my.xsd:12:9: error: src-resolve: element 'Common@my:common' not found.
  Time to build schema type system: 3.396 seconds
  BUILD FAILED
 
 Note that the error above *with* -dl set looks very different from the 
 error when www.w3.org was returning 503:
 
  [ERROR] java.lang.RuntimeException: java.lang.RuntimeException: 
  org.apache.ws.commons.schema.XmlSchemaException: 
  Server returned HTTP response code: 503 for URL:
  http://www.w3.org/2001/xml.xsd
 
 Since the error messages looks so different, maybe the issue has 
 nothing to do with the -dl option? Could scomp be hardcoded such 
 that scomp always try to fetch http://www.w3.org/2001/xml.xsd 
 regardless of the -dl option?
 
 I'm still concerned that if www.w3.org returns 503 during a build, 
 my build will be blocked (regardless of -dl).  Should I still log 
 an issue with Jira, since I can't actually reproduce?
 
 -- Jeff
 
 
 
 -Original Message-
 From: Cezar Andrei [mailto:cezar.and...@oracle.com] 
 Sent: Wednesday, June 22, 2011 11:25 AM
 To: user@xmlbeans.apache.org
 Subject: Re: Why is scomp trying to access remote url without -dl option
 set?
 
 Jeff,
 
 This looks like a bug if it really happens, can you please make a small
 repro which shows the problem all the time and file it under Jira?
 
 Cezar
 
 
 
 On Jun 22, 2011, at 12:21 PM, Jeff Martin wrote:
 
 I've been using scomp successfully for years (currently XMLBeans
 2.4.0).
 
 Recently I got the following error:
 
 $ scomp -d genDir -src genDir -javasource 1.5 -out my.jar \
 my.xsd my.xsdconfig
 {...snip...}
 [ERROR] java.lang.RuntimeException: java.lang.RuntimeException: 
 org.apache.ws.commons.schema.XmlSchemaException: 
 Server returned HTTP response code: 503 for URL:
 http://www.w3.org/2001/xml.xsd
 
 Why was/is scomp trying to retrieve http://www.w3.org/2001/xml.xsd?
 
 According to the scomp help, scomp should never try to download 
 anything  over the network unless you explicitly set -dl option:
  -dl - permit network downloads for imports and includes (default is
 off)
 
 I'm *NOT* using the -dl switch, so why was/is scomp trying to 
 download this file?
 
 Fortunately, the web server at http://www.w3.org stopped returning
 503, 
 and my builds now work again.  But I don't want to be dependent on 
 internet resources at build time.   Why was/is scomp trying to fetch 
 any remote resource without the -dl option set?
 
 -- Jeff
 
 
 
 
 
 
 
 CONFIDENTIALITY NOTICE: The information contained in this message may be 
 privileged and/or confidential. If you are not the intended recipient, or 
 responsible for delivering this message to the intended recipient, any 
 review, forwarding, dissemination, distribution or copying of this 
 communication or any attachment(s) is strictly prohibited. If you have 
 received this message in error, please notify the sender immediately, and 
 delete it and all attachments from your computer and network.
 
 -
 To unsubscribe, 

Re: Conflict When Having Two XMLBean Generated classes for the same Schema...

2011-06-23 Thread Cezar Andrei
Best way to avoid this problem is to have different target namespaces for your 
schemas, or same target namespace but without conflicts.

If you can't do that next is to manage the jars/classes in different 
classloaders like Kevin suggested.

If this is not possible, at least use different java package names for the two 
files (see .sconfig files), but there are limitations about this, is you start 
with xml/schema names you'll always get the resources from the first jar on the 
classpath.

Cezar

On Jun 23, 2011, at 12:46 PM, Kevin Krouse wrote:

 If you have schemas that define components in the same namespace you'll need 
 to isolate the generated schema jars using classloaders.  The issue is 
 similar to trying to load two different java classes with the same name.
 
 Kevin
 
 
 On Thu, Jun 16, 2011 at 7:35 AM, Horst Heistermann 
 horst.heisterm...@oracle.com wrote:
 Hi,
 
  I am having an issue in my environment because I have two XMLBean generated 
 classes pointing to the same schema. Sometimes when I use the factory of one 
 class
 it tries to create an instance of the other XMLBean class (even though I am 
 using the factory of the class I want to create!).  This causes a 
 classcastexeception
 
 Is there a way to avoid this? The issue is indeterminate because it works 
 fine most of the time but once in a while this issue crashes the program
 
 Thanks,
 
 Horst
 
 
 -
 To unsubscribe, e-mail: user-unsubscr...@xmlbeans.apache.org
 For additional commands, e-mail: user-h...@xmlbeans.apache.org