Ant definitely does play some unkind games with classloaders. But now that I think about it, part of the problem may be due to the fact that the classes being bound aren't necessarily on the execution classpath for the binding compiler - it loads them through BCEL, which has it's own mechanism. One way around this might be to use our own classloader for getting the binding definition files as resources. You might look at the org.jibx.binding.Compile class, which has a simple classloader used for test loading of modified classes. Creating an instance of this classloader with the full array of classpath entries used by the binding compiler should allow all the files to be found.

 - Dennis

Arnaud Lenfant wrote:

I've tried to load the included files as resources in the classpath.
Worked fine as long as I was not using the Ant task to run the binding
compiler. In this case the Class loader would be unable to find my
files. Looks like there is some kind of weird interaction between Ant
and the class loaders ...




Date: Tue, 12 Apr 2005 16:18:21 -0700 From: Dennis Sosnoski <[EMAIL PROTECTED]> To: [email protected] Subject: Re: [jibx-users] Issue with splitting binding files Reply-To: [email protected]

That's an interesting idea, to search as resources in the classpath.
I=20
think it's too late to include this in 1.0, since I've frozen new=20
features in order to stabilize for the release. Perhaps you can see a=20
way to add this for a post-1.0 release. As a suggestion, the
<include>=20
target doesn't have to be relative to the including file - it's like=20
hrefs in HTML, where if the target doesn't start with a protocol
(such=20
as http:, ftp:, etc.) or '/' it's relative to the origin page. Using
a=20
special custom protocol such as "res://somepackage.someclass" might be
a=20
good way of handling your needs. You'd need to make sure the protocol=20
name didn't conflict with any standard ones, but that shouldn't be a
big=20
problem.

Incidentally, I did take care of detecting the situation you'd=20
originally reported as giving a Runtime exception. It turned out to be
a=20
lot more complex than I'd originally anticipated, so kept me busy for=20
most of the time I was conscious in the 30-hour transit time going=20
Seattle->Los Angeles->Sydney->Wellington.

 - Dennis

Arnaud Lenfant wrote:



Thanks for the quick answer, Dennis.

<include> would help me, but as I understand it searches for locations
relative to the inclusing file.

When I have:

Import somePackage.Type

public class SomeObject {
  Type type;
}

I have no idea of the location of somePackage relative to my class, I
just assume it is in the classpath.
Would it be possible to have <include> lookup for binding files as
resources ?

Regards,

Arnaud


Subject: Re: [jibx-users] Issue with splitting binding files To: [email protected] Reply-To: [email protected]

Hi Arnaud,

You should be able to do what you want by using <include>:

<binding>
  <include path=3D3D"type-binding.xml"/>
  <include path=3D3D"status-binding.xml"/>
  <mapping name=3D3D"someObj" ...

I'm surprised that your binding:

<binding>
<mapping name=3D3D"someObj" class=3D3D"SomeObject">
  <structure field=3D3D"status"/>
  <structure field=3D3D"type"/>
</mapping>
</binding>=3D20

got as far as it did (into code generation). This should have been=3D
=3D20
rejected before the code generation phase because there was no


mappin=3D


g=3D20
defined within this binding for the types of the fields.

- Dennis

Arnaud Lenfant wrote:

=20



Hello All,

I've written a little xdoclet to generate the binding files for my


j=3D


 =20



ava
=20



classes. I generate a xxx.binding.xml for every xxx.java.
But I'm not sure it's the right way to do things with  Jibx.

I have the following classes:

public class SomeObject {
Status=3D09status;
Type=3D09type;
}

public class Type{
String=3D09name;
}

public class Status{
String=3D09name;
}

Using the following binding works fine:

<?xml version=3D3D'1.0' encoding=3D3D'UTF-8'?>
<binding>

<mapping name=3D3D"status" class=3D3D"Status">
 <value name=3D3D"name" field=3D3D"name"/>
</mapping>

<mapping name=3D3D"type" class=3D3D"Type">
 <value name=3D3D"name" field=3D3D"name"/>
</mapping>
=3D20
<mapping name=3D3D"someObj" class=3D3D"SomeObject">
 <structure field=3D3D"status"/>
 <structure field=3D3D"type"/>
</mapping>

</binding>

But if I split the bindings and put the bindings for Type and


Status=3D


 =20



in
=20



different files I have the following errors:

With=3D20

<?xml version=3D3D'1.0' encoding=3D3D'UTF-8'?>
<binding>
<mapping name=3D3D"status" class=3D3D"Status">
 <value name=3D3D"name" field=3D3D"name"/>
</mapping>
</binding>

<?xml version=3D3D'1.0' encoding=3D3D'UTF-8'?>
<binding>=3D20
<mapping name=3D3D"someObj" class=3D3D"SomeObject">
 <structure field=3D3D"status"/>
</mapping>
</binding>

The binding works allright but I have a runtime exception:

Exception in thread "main" java.lang.NullPointerException
     at java.net.URLClassLoader$1.run(URLClassLoader.java:190)
     at java.security.AccessController.doPrivileged(Native Method=3D
 =20



)
=20



     at java.net.URLClassLoader.findClass(URLClassLoader.java:187=3D
 =20



)
=20



     at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:282)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:=3D
 =20



274)
=20



at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at
org.jibx.runtime.impl.MarshallingContext.getMarshaller(MarshallingCo=3


D


 =20



n
=20



text.java:905)
     at Status.marshal(Status.java)
     at SomeObject.JiBX_conf_SomeObject_marshal_1_0(SomeObject.ja=3D
 =20



va)
=20



at JiBX_conf_SomeObjectSomeObject_access.marshal()
at SomeObject.marshal(SomeObject.java)
at
org.jibx.runtime.impl.MarshallingContext.marshalRoot(MarshallingCont=3


D


 =20



e
=20



xt.java:964)
at
org.jibx.runtime.impl.MarshallingContext.marshalDocument(Marshalling=3


D


 =20



C
=20



ontext.java:1056)
     at Run.main(Run.java:29)


Now if I try to include both type and status in my mapping:=3D20

<?xml version=3D3D'1.0' encoding=3D3D'UTF-8'?>
<binding>
<mapping name=3D3D"someObj" class=3D3D"SomeObject">
 <structure field=3D3D"status"/>
 <structure field=3D3D"type"/>
</mapping>
</binding>=3D20

I have a binding error:


Using bindings: conf/SomeObject.jibx.xml Running binding compiler version jibx-rc0 binding conf_SomeObject: context (mp#=3D3D1) (cv#=3D3D0) (fm#=3D3D0) mapping class SomeObject to element someObj element wrapper someObj object binding for SomeObject structure ordered mapping reference to Status using property status (Status) mapping reference to Type using property type (Type) Generating code for mapping SomeObject Error running binding compiler

*** Error during code generation - please report this error on the


J=3D


 =20



iBX
=20



users li
st so that the condition can be caught during validation ***

java.lang.IllegalStateException: Internal error: Too few values on


s=3D


 =20



tack
=20



full stack:
0: Type

at
org.jibx.binding.classes.MethodBuilder.verifyStackDepth(MethodBuilde=3


D


 =20



r
=20



java:432)
at
org.jibx.binding.classes.MethodBuilder.verifyStack(MethodBuilder.jav=3


D


 =20



a
=20



:459)
at
org.jibx.binding.classes.MethodBuilder.appendPutField(MethodBuilder.=3


D


 =20



j
=20



ava:743)
at
org.jibx.binding.classes.MethodBuilder.appendPut(MethodBuilder.java:=3


D


 =20



7
=20



72)
at
org.jibx.binding.def.PropertyDefinition.genStore(PropertyDefinition.=3


D


 =20



j
=20



ava:520)
at
org.jibx.binding.def.DirectGeneric.genUnmarshal(DirectGeneric.java:1=3


D


 =20



5
=20



6)
at
org.jibx.binding.def.DirectGeneric.genContentUnmarshal(DirectGeneric=3


D


 =20



=20



java:230)
at
org.jibx.binding.def.PassThroughComponent.genContentUnmarshal(PassTh=3


D


 =20



r
=20



oughComponent.java:111)
at
org.jibx.binding.def.NestedStructure.genContentUnmarshal(NestedStruc=3


D


 =20



t
=20



ure.java:153)
at
org.jibx.binding.def.ObjectBinding.genUnmarshalContentCall(ObjectBin=3


D


 =20



d
=20



ing.java:736)
at
org.jibx.binding.def.ObjectBinding.genContentUnmarshal(ObjectBinding=3


D


 =20



=20



java:875)
at
org.jibx.binding.def.ElementWrapper.genContentUnmarshal(ElementWrapp=3


D


 =20



e
=20



r.java:272)
at
org.jibx.binding.def.MappingDefinition.generateCode(MappingDefinitio=3


D


 =20



n
=20



java:541)
at
org.jibx.binding.def.DefinitionContext.generateCode(DefinitionContex=3


D


 =20



t
=20



java:600)
at
org.jibx.binding.def.BindingDefinition.generateCode(BindingDefinitio=3


D


 =20



n
=20



java:578)
     at org.jibx.binding.Compile.compile(Compile.java:303)
     at org.jibx.binding.Compile.main(Compile.java:382)



So clearly I'm doing something wrong.
Is there a way to separate the binding files for different classes ?

In my case the Status and Type classes would be referenced by a lot


=3D


 =20



of
=20



different classes. What I'd like is a way to generate their mapping


=3D


 =20



once
=20



and have it used whenever it is needed.


Thanks for your help,

Arnaud Lenfant



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real


us=3D


 =20



ers.
=20



Discover which products truly live up to the hype. Start reading


now=3D


 =20



=20



http://ads.osdn.com/?ad_ide95&alloc_id=3D14396&op=3DCCk
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

=3D20

 =20




-- __--__--


_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users


End of jibx-users Digest


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real


users.


Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id=14396&op=CCk
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

=20





--__--__--

Message: 5
Date: Tue, 12 Apr 2005 16:17:55 -0700
From: Dennis Sosnoski <[EMAIL PROTECTED]>
To: [email protected]
Subject: Re: [jibx-users] ExceptionInInitializer while using ant
task....
Reply-To: [email protected]

I think this occurred with Beta 3c when you didn't include the jibx-run.jar in the classpath set inside the bind task. This should be corrected with RC0, so that you no longer need to include anything on the inner classpath except your own classes (one of the many cleanup items that have gone into RC0).

 - Dennis

Paul Tomsic wrote:



here's the relevant parts of my build.xml:
<property name="build.dest"
value="${basedir}/build/classes"/>
<path id="bind.tools.class.path">
<pathelement location="${basedir}/lib/bcel.jar"/>
<pathelement location="${basedir}/lib/jibx-bind.jar"/>
<pathelement location="${basedir}/lib/jibx-run.jar"/>
<pathelement location="${basedir}/lib/xpp3.jar"/>
<pathelement
location="${basedir}/lib/dom4j-1.5.2.jar"/>
</path>

<target name="bind" depends="compile, about">
<bind verbose="true" load="true">
<bindingfileset dir="${bind.src.dir}"/>
<classpathset dir="${build.dest}"/>
</bind>
</target>


and the output: [bind] Using the following paths: [bind] home/build/classes [bind] Using the following binding paths: [bind] home/binding/binding.xml [bind] Running binding compiler version jibx-beta3c

BUILD FAILED
java.lang;ExceptionInInitializerError



any thoughts?





-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real


users.


Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users








--__--__--

_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users


End of jibx-users Digest


------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_ide95&alloc_id396&op�k _______________________________________________ jibx-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jibx-users





-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to