[x3d-public] X3D python language binding, pyjnius validation

Brutzman, Donald (Don) (CIV) brutzman at nps.edu
Mon Apr 8 09:53:43 PDT 2019


John, thanks for any improvements.  n.b. please be sure to update your subversion and get my modifications.

Summary: finally back on track (on one machine at least), more to follow.  Troubleshooting log follows FYI.

-----------------------------------------------------------------------------------------------------------

I've improved the build files further and can create both SomeModel.py and SomeModel.future.py for any of the X3D Examples.

As you can see from excerpted log for "create python:" target, the conversion from SomeModel.x3d to SomeModel.py works OK.

However I consistently get the same error.  This occurs even when I remove all comments from the source model.  Excerpt:

=====================
ant -f C:\\x3d-code\\www.web3d.org\\x3d\\content\\examples\\X3dForWebAuthors processScenes.python
processScenes.python:
$pyjnius.path=C:\x3d-code\www.web3d.org\x3d\stylesheets\java\src\python\pyjnius
$pyjnius.configurationPath=C:\Program Files\Java\jdk1.8.0_202\jre\bin\server;.;C:\Program Files\Java\jdk1.8.0_202\bin;C:\apache-ant-1.10.5\bin;C:\Program Files\Python37\Scripts\;C:\Program Files\Python37\;C:\Program Files\ImageMagick-7.0.6-Q16;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS\System32\Wbem;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Dell\Dell Data Protection\Drivers\TSS\bin\;C:\Program Files\Git\cmd;C:\Program Files\IDM Computer Solutions\UltraEdit;C:\Program Files\Instant Reality\bin\;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\PuTTY\;C:\Program Files\jEdit;C:\Program Files\IDM Computer Solutions\UltraCompare;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Blender Foundation\Blender;C:\Program Files\VCG\MeshLab;C:\Program Files\TortoiseGit\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\nodejs\;C:\Users\brutzman\AppData\Local\Microsoft\WindowsApps;C:\Users\brutzman\AppData\Roaming\npm
$CLASSPATH=C:\x3d-code\www.web3d.org\x3d\stylesheets\java\jars\X3DJSAIL.3.3.full.jar;C:\x3d-code\www.web3d.org\x3d\stylesheets\java\lib\saxon9he.jar;
Verifying Apache Ant XML Catalog resolver classpath: C:\apache-ant-1.10.5\lib/resolver.jar (84091 bytes)
=====================
create python:
node xml2all.js C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForWebAuthors/Chapter01TechnicalOverview//EmptyScene.x3d
EmptyScene.x3d converted to EmptyScene.py
test python:
Loading and running EmptyScene.py program, if successful then saving as round-trip .x3d version:
Traceback (most recent call last):
   File "C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForWebAuthors/Chapter01TechnicalOverview//EmptyScene.py", line 4, in <module>
     from X3Dautoclass import *
   File "C:\x3d-code\www.web3d.org\x3d\stylesheets\java\src\python\pyjnius\X3Dautoclass.py", line 2, in <module>
     CommentsBlock = autoclass('org.web3d.x3d.jsail.Core.CommentsBlock')
   File "C:\Program Files\Python37\lib\site-packages\jnius\reflect.py", line 159, in autoclass
     c = find_javaclass(clsname)
   File "jnius\jnius_export_func.pxi", line 26, in jnius.find_javaclass
jnius.JavaException: Class not found b'org/web3d/x3d/jsail/Core/CommentsBlock'
Result: 1
=====================
etc.
=====================

I have verified that org.web3d.x3d.jsail.Core.CommentsBlock is correctly found in X3DJSAIL.3.3.full.jar, X3Dautoclass.py and autoclass.py files.

Suspiciously the following line is first in X3Dautoclass.py and so I tried deleting it:
CommentsBlock = autoclass('org.web3d.x3d.jsail.Core.CommentsBlock')

Sure enough that moved the exception to match the next line in X3Dautoclass.py, hmmm:
=====================
create python:
node xml2all.js C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForWebAuthors/Chapter01TechnicalOverview//EmptySceneCoreProfile.x3d
EmptySceneCoreProfile.x3d converted to EmptySceneCoreProfile.py
test python:
Loading and running EmptySceneCoreProfile.py program, if successful then saving as round-trip .x3d version:
Traceback (most recent call last):
   File "C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForWebAuthors/Chapter01TechnicalOverview//EmptySceneCoreProfile.py", line 4, in <module>
     from X3Dautoclass import *
   File "C:\x3d-code\www.web3d.org\x3d\stylesheets\java\src\python\pyjnius\X3Dautoclass.py", line 2, in <module>
     X3DNode = autoclass('org.web3d.x3d.sai.Core.X3DNode')
   File "C:\Program Files\Python37\lib\site-packages\jnius\reflect.py", line 159, in autoclass
     c = find_javaclass(clsname)
   File "jnius\jnius_export_func.pxi", line 26, in jnius.find_javaclass
jnius.JavaException: Class not found b'org/web3d/x3d/sai/Core/X3DNode'
Result: 1
=====================

Not sure why their exception has a stray 'b' character in it, is that fixable?  Offending diagnostic:

	jnius.JavaException: Class not found b'org/web3d/x3d/sai/Core/X3DNode'

Was surprised by your change to ".newf" file suffix and so changed that to ".newFile" for searchability and clarity.

Then realized that one major difference between your working script and my X3D Example Archives script was that you were running in the pyjnius directory, which could account for why some files were not being seen.  In other words, perhaps PYTHONPATH wasn't enough?

Sure enough, modifying the execution directory in the Ant target led to the right validation occurring of ModelName.newFile.x3d models generated from ModelName.py and ModelName.future.py conversions.  Presence of the naming-convention warning indicates that X3DJSAIL has fully validated the result file, and has no other warnings or reports.

*Excerpts*

=====================
ant -f C:\\x3d-code\\www.web3d.org\\x3d\\content\\examples\\X3dForWebAuthors processScenes.python
processScenes.python:
$env.JAVA_HOME=C:\Program Files\Java\jdk1.8.0_202
$env.CLASSPATH=C:\x3d-code\www.web3d.org\x3d\stylesheets\java\jars\X3DJSAIL.3.3.full.jar;C:\x3d-code\www.web3d.org\x3d\stylesheets\java\lib\saxon9he.jar;
$pyjnius.X3DautoclassPath =C:\x3d-code\www.web3d.org\x3d\stylesheets\java\src\python\pyjnius
PYTHONPATH                =C:\x3d-code\www.web3d.org\x3d\stylesheets\java\src\python\pyjnius
$pyjnius.configurationPath=C:\Program Files\Java\jdk1.8.0_202\jre\bin\server;.;C:\Program Files\Java\jdk1.8.0_202\bin;C:\apache-ant-1.10.5\bin;C:\Program Files\Python37\Scripts\;C:\Program Files\Python37\;C:\Program Files\ImageMagick-7.0.6-Q16;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS\System32\Wbem;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Dell\Dell Data Protection\Drivers\TSS\bin\;C:\Program Files\Git\cmd;C:\Program Files\IDM Computer Solutions\UltraEdit;C:\Program Files\Instant Reality\bin\;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\PuTTY\;C:\Program Files\jEdit;C:\Program Files\IDM Computer Solutions\UltraCompare;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Blender Foundation\Blender;C:\Program Files\VCG\MeshLab;C:\Program Files\TortoiseGit\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\nodejs\;C:\Users\brutzman\AppData\Local\Microsoft\WindowsApps;C:\Users\brutzman\AppData\Roaming\npm
Verifying Apache Ant XML Catalog resolver classpath: C:\apache-ant-1.10.5\lib/resolver.jar (84091 bytes)
=====================
create python:
node xml2all.js C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForWebAuthors/Chapter01TechnicalOverview//EmptyScene.x3d
EmptyScene.x3d converted to EmptyScene.py
- - - - - - - - - - -
validate python:
Loading and running EmptyScene.py program, if successful then saving as round-trip EmptyScene.newFile.x3d version:
Warning: /x3d-code/www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter01TechnicalOverview//EmptyScene.newFile.x3d does not meet suggested X3D naming conventions, output serialization continuing...
- - - - - -
Loading and running EmptyScene.future.py program, if successful then saving as round-trip EmptyScene.newFile.x3d version:
Warning: /x3d-code/www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter01TechnicalOverview//EmptyScene.newFile.x3d does not meet suggested X3D naming conventions, output serialization continuing...
Warning: toFileX3D() is overwriting prior file /x3d-code/www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter01TechnicalOverview//EmptyScene.newFile.x3d
=====================
create python:
node xml2all.js C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForWebAuthors/Chapter01TechnicalOverview//EmptySceneCoreProfile.x3d
EmptySceneCoreProfile.x3d converted to EmptySceneCoreProfile.py
- - - - - - - - - - -
validate python:
Loading and running EmptySceneCoreProfile.py program, if successful then saving as round-trip EmptySceneCoreProfile.newFile.x3d version:
Traceback (most recent call last):
   File "C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForWebAuthors/Chapter01TechnicalOverview//EmptySceneCoreProfile.py", line 87, in <module>
     MetadataBoolean19.setValue([true,false])
NameError: name 'true' is not defined
Result: 1
- - - - - -
Loading and running EmptySceneCoreProfile.future.py program, if successful then saving as round-trip EmptySceneCoreProfile.newFile.x3d version:
Traceback (most recent call last):
   File "C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForWebAuthors/Chapter01TechnicalOverview//EmptySceneCoreProfile.future.py", line 69, in <module>
     .setName("NodeSet") \
AttributeError: 'org.web3d.x3d.sai.Core.X3DMetadataObject' object has no attribute 'setValue'
Result: 1
=====================
create python:
node xml2all.js C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForWebAuthors/Chapter01TechnicalOverview//HeaderProfileComponentMetaExample.x3d
HeaderProfileComponentMetaExample.x3d converted to HeaderProfileComponentMetaExample.py
- - - - - - - - - - -
validate python:
Loading and running HeaderProfileComponentMetaExample.py program, if successful then saving as round-trip HeaderProfileComponentMetaExample.newFile.x3d version:
Warning: /x3d-code/www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter01TechnicalOverview//HeaderProfileComponentMetaExample.newFile.x3d does not meet suggested X3D naming conventions, output serialization continuing...
- - - - - -
Loading and running HeaderProfileComponentMetaExample.future.py program, if successful then saving as round-trip HeaderProfileComponentMetaExample.newFile.x3d version:
Warning: /x3d-code/www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter01TechnicalOverview//HeaderProfileComponentMetaExample.newFile.x3d does not meet suggested X3D naming conventions, output serialization continuing...
Warning: toFileX3D() is overwriting prior file /x3d-code/www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter01TechnicalOverview//HeaderProfileComponentMetaExample.newFile.x3d
=====================
=====================


So: think we are back in business.  Have checked in current changes, will produce larger outputs tonight.

Having fun with X3D python!  8)


On 4/4/2019 8:15 AM, John Carlson wrote:
> Okay. I am in charge of the JavaScript.
> 
> 
> I removed all references to stack space, classpath and jnius_config
> 
> It works on local files (not future.py files). I have not tried running python on things in the archive yet.
> 
> **
> 
> *You will need to set the CLASSPATH env variable in build.xml.*
> 
> **
> 
> I have checked in changes to serializers, and restarted my build.
> 
> I recommend regenerating python files and rerunning validation:
> 
> See below, existing error locally (needs to be debugged, serializer changed etc.  But first we need to patch it or autoclass.py, X3Dautoclass.py to see if we can get rid of the error.
> 
> Suggestions?
> 
> $ python abox.future.py
> 
> Traceback (most recent call last):
> 
>    File "abox.future.py", line 47, in <module>
> 
>      .setProtoField("myShape") \
> 
>    File "jnius\jnius_export_class.pxi", line 760, in jnius.JavaMethod.__call__
> 
>    File "jnius\jnius_conversion.pxi", line 78, in jnius.populate_args
> 
>    File "jnius\jnius_utils.pxi", line 205, in jnius.check_assignable_from
> 
> jnius.JavaException: Invalid instance of 'org/web3d/x3d/jsail/X3DConcreteNode' passed for a 'org/web3d/x3d/sai/Core/X3DNode'
> 
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
> 
> *From: *Brutzman, Donald (Don) (CIV) <mailto:brutzman at nps.edu>
> *Sent: *Thursday, April 4, 2019 7:57 AM
> *To: *John Carlson <mailto:yottzumm at gmail.com>
> *Cc: *X3D Graphics public mailing list <mailto:x3d-public at web3d.org>
> *Subject: *Re: X3D python language binding, pyjnius validation
> 
> probably best if you stay in charge of the javascript modifications, that is your work.
> 
> a. do we need to set classpath value below as a settable parameter, or better, just have it use existing classpath?  that way location of X3DJSAIL.3.3.full.jar is controlled externally on local system, as intended.
> 
> b. need CommentsBlock to be available since it is part of conversions.
> 
> On 4/3/2019 10:28 AM, John Carlson wrote:
> 
>  > For example, in python files you send me, I think the following line:
> 
>  >
> 
>  > jnius_config.set_classpath('.', '../../../jars/X3DJSAIL.3.3.full.jar')
> 
>  >
> 
>  > Is not working.
> 
>  >
> 
>  > I believe that CommentsBlock may be taken out of the X3Dautoclass.py file, since I don’t use it.  But may later.
> 
>  >
> 
>  > John
> 
>  >
> 
>  > Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
> 
>  >
> 
>  > *From: *John Carlson <mailto:yottzumm at gmail.com>
> 
>  > *Sent: *Wednesday, April 3, 2019 12:22 PM
> 
>  > *To: *Brutzman, Donald (Don) (CIV) <mailto:brutzman at nps.edu>; X3D Graphics public mailing list <mailto:x3d-public at web3d.org>
> 
>  > *Subject: *RE: X3D python language binding, pyjnius validation
> 
>  >
> 
>  > My guess would be the classpath set by jnius_config…. Method is not working.
> 
>  >
> 
>  > John
> 
>  >
> 
>  > Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
> 
>  >
> 
>  > *From: *Brutzman, Donald (Don) (CIV) <mailto:brutzman at nps.edu>
> 
>  > *Sent: *Wednesday, April 3, 2019 12:17 PM
> 
>  > *To: *John Carlson <mailto:yottzumm at gmail.com>; X3D Graphics public mailing list <mailto:x3d-public at web3d.org>
> 
>  > *Subject: *X3D python language binding, pyjnius validation
> 
>  >
> 
>  > Hi John.  Status report.
> 
>  >
> 
>  > a. am able to build on primary Windows 10 box,
> 
>  >
> 
>  > b. still grappling with Visual Studio bug related to on Windows XP box,
> 
>  >
> 
>  > c. have added build targets for X3D examples archives: clean.python and processScenes.python which work on first box,
> 
>  >
> 
>  > d. .py generation works (see attached) but running self-validation of the two .py files still has problems.
> 
>  >
> 
>  > Am getting a lot of these errors.  Do you have a bidirectional python-to-java mapping for x3djsail CommentsBlock when comments are encountered?
> 
>  >
> 
>  > =====================
> 
>  >
> 
>  > create python:
> 
>  >
> 
>  > node xml2all.js C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForAdvancedModeling/Visualization//TextureBackgroundCube.x3d
> 
>  >
> 
>  > TextureBackgroundCube.py produced from TextureBackgroundCube.x3d
> 
>  >
> 
>  > test python:
> 
>  >
> 
>  > Loading and running TextureBackgroundCube.py program, if successful then saving as round-trip .x3d version:
> 
>  >
> 
>  > Traceback (most recent call last):
> 
>  >
> 
>  >     File "C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForAdvancedModeling/Visualization//TextureBackgroundCube.py", line 5, in <module>
> 
>  >
> 
>  >       from X3Dautoclass import *
> 
>  >
> 
>  >     File "C:\x3d-code\www.web3d.org\x3d\stylesheets\java\src\python\pyjnius\X3Dautoclass.py", line 2, in <module>
> 
>  >
> 
>  >       CommentsBlock = autoclass('org.web3d.x3d.jsail.Core.CommentsBlock')
> 
>  >
> 
>  >     File "C:\Program Files\Python37\lib\site-packages\jnius\reflect.py", line 159, in autoclass
> 
>  >
> 
>  >       c = find_javaclass(clsname)
> 
>  >
> 
>  >     File "jnius\jnius_export_func.pxi", line 26, in jnius.find_javaclass
> 
>  >
> 
>  > jnius.JavaException: Class not found b'org/web3d/x3d/jsail/Core/CommentsBlock'
> 
>  >
> 
>  > Result: 1
> 
>  >
> 
>  > =====================
> 
>  >
> 
>  > In addition to example-project build.xml files, am also working with the pyjnius subdirectory build.xml still, but standing clear of your .py and .js files.
> 
>  >
> 
>  > TIA for continuing insights and improvements.
> 
>  >
> 
>  > all the best, Don
> 
>  >
> 
>  > --
> 
>  >
> 
>  > Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
> 
>  >
> 
>  > Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
> 
>  >
> 
>  > X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman
> 
>  >
> 
> all the best, Don
> 
> -- 
> 
> Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
> 
> Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
> 
> X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman
> 


all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman


More information about the x3d-public mailing list