Problem using Java extension classes

Having trouble installing Oxygen? Got a bug to report? Post it all here.
smaug42
Posts: 44
Joined: Tue May 25, 2004 2:27 pm

Problem using Java extension classes

Post by smaug42 »

According to the Oxygen Help file (Transforming Documents > Configuring the extension paths...) , if I want to use Java extension classes that are referenced in my XSLTs I should add:
--------
"-Dcom.oxygenxml.additional.classpath=test1;test2" to the java command line in your script file
---------
If I do this (replacing test1;test2 with the path and filename of my custom jarfile), the transform I want to do fails and the error is telling me that it can't find my external .jar file.

If I put that same custom jar file in Oxygen5.1/lib, restart Oxygen from the batch/shell file (without the classpath parameter in the batchfile) and try the transform again it works fine with no errors.

What's up? Why can't I reference an external jar? Any ideas what is going wrong here?
iulian_velea
Posts: 63
Joined: Fri Dec 12, 2003 6:34 pm
Contact:

Post by iulian_velea »

Hello,

Thank you for contacting us. I have tested the Xalan Java Extensions with oXygen using the example provided at http://xml.apache.org/xalan-j/extensions.html#ex-java and it worked in the following cases:
- with the batch file modified and the jar (containing the java class) specified in the value of the property: com.oxygenxml.additional.classpath
- with the batch file modified and the compiled java class file in the folder specified in the property value.
- with the jar file in the "/lib" folder from the oXygen intallation folder and the batch file unchanged.

Make sure that the classpath you specify in the command line is reffering to the correct path and jar files, or the correct path if you use compiled java classes instead of jars. You can also try to provide an absolute path for the jar files.
Maybe you can send us an example consisting of the command line, java classes or jars and xml/xsl files, in order to reproduce the problem.

Best Regards,
Iulian.
smaug42
Posts: 44
Joined: Tue May 25, 2004 2:27 pm

Post by smaug42 »

The line in the batch file is currently:
-------
java -Xmx256m -Dcom.oxygenxml.additional.classpath=C:\cvs\tools\bin\tools.jar -cp %CP% ro.sync.exml.Oxygen %1 %2 %3 %4 %5 %6 %7
------

The jar file contains java classes and ant tasks. Nothing too scary or magical. :-)

I tried with and without naming the jar file in the classpath property... same results. It will not do the transform unless I put the jar in the /lib directory. If the custom jar file is in /lib the transform works fine. I need to keep the custom jar file outside of the Oxygen install though.

I can't really package up and send you the XML I'm having problems with since it's more than one file... more like a total of almost 2000 XML files involved in the transform that I am doing (plus the various DTDs, XSLs, entities etc.).

I'll try again here and see if it was a Friday thing...
iulian_velea
Posts: 63
Joined: Fri Dec 12, 2003 6:34 pm
Contact:

Post by iulian_velea »

If you can, please try the example at the following URL: http://xml.apache.org/xalan-j/extensions.html#ex-java and check if it works, or contact us by emailing at support@oxygenxml.com and we will send you the example that we tested.
Also you can try to send us a small sample of your work with a stylesheet, a sample XML document and the java class used from the XSL.
Please give us more informations about your platform like oXygen version, OS, JVM.

Regards,
Iulian.
smaug42
Posts: 44
Joined: Tue May 25, 2004 2:27 pm

Post by smaug42 »

Hmmmm after tinkering wtih the Xalan example, the proverbial lightbulb appeared over my head :-) It comes down to the difference between jars with java classes and compiled java classes and how they are referenced in the line in the batch file... plus Friday-itus. Works now... not sure why I was running into difficulty on Friday.

BTW, using/testing Oxygen5.1 on WindowsXP with JSDK1.4, but target OS is Linux and/or Eclipse.

Thanks for the example... got my addled brain thinking on the right track.
dennis
Posts: 2
Joined: Sat Feb 05, 2005 3:18 pm

java extensions in Eclipse version

Post by dennis »

Hi,

I am evaluating oxygen as an eclipse plugin and I have a similar problem. I have some java extension classes I wrote for Saxon and I want to use them in my transformation. In this case, I have not found any information in the oxygen docs. I have tried putting the classes in my system classpath and I have tried defining the oxygenxml.additional.classpath variable using -vmargs attribute on the eclipse launcher.

Do you know how I can do this? It would be nice to be able to reference an eclipse java projects.

cheers,
d.
iulian_velea
Posts: 63
Joined: Fri Dec 12, 2003 6:34 pm
Contact:

Post by iulian_velea »

Hi dennis,

If your classes are in a jar, the simplest way to use them is to copy the jar file into the "[eclipse_dir]\plugins\com.oxygenxml.editor_5.1.0\lib" and modify the file "plugin.xml" from the "[eclipse_dir]\plugins\com.oxygenxml.editor_5.1.0" by adding the following lines inside the element "runtime". Something like this:

Code: Select all


<runtime>
...
<library name="lib/jar_file.jar">
<export name="*"/>
</library>
...
</runtime>
You must restart Eclipse ofcourse for changes to take effect.
Please let us know if this fixes the problem.

Best Regards,
Iulian.
dennis
Posts: 2
Joined: Sat Feb 05, 2005 3:18 pm

Post by dennis »

thanks for the suggestion, but I have not been able to get this working (I still get a "stylesheet compilation error: on the line containing the definition of my extension class). I really thought this should have worked. The problem must be in the way the XSLT process is spawned from eclipse. It is really strange that this won't work even when the class is defined in the user classpath variable.

I think I am going to give up. :(
d.
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi Dennis,

Make sure you are using the processor for which you have the extensions as the XSLT Processor used for validation. You can set that from the oXygen options. By default I think it is set to Xalan and from the previous messages it seems you have Saxon extensions so that might be the problem.

Best Regards,
George
claus
Posts: 5
Joined: Tue Nov 06, 2007 3:05 pm

same problem 3 years later

Post by claus »

hi george,

was the above problem from dennis ever solved?
i made the changes to the standalone runtime above and everything works fine there, but the eclipse plugin does not work in this way you described.

in my case i am using my java logger:

xmlns:log="misc.XsltLogger"
...
<xsl:value-of select="log:debug('test')"/>

i edited plugin.xml:

<library name="lib/logger.jar">
<export name="misc.*"/>
</library>

and added the jar file in the oxygen eclipse plugin lib folder.

it does not work, oxygen (eclipse plugin only) reports a syntax error.
the code as it is runs fine when i start my java application using the xsl sources with saxon 8 as a transformer.

any suggestions?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

Did you restart Eclipse? What is the Eclipse version number and the oXygen plugin version number? What is the full message of the syntax error? If the jar file is not loaded the error should be that the misc.XsltLogger class could not be found instead of an XSLT syntax error.


Regards,
Sorin
claus
Posts: 5
Joined: Tue Nov 06, 2007 3:05 pm

Post by claus »

hi,

sorry for my uncomplete post. of course i restarted eclipse.

The error is: Cannot find a matching 1 argument function named: ...

with a bit more text around. the full message is more cryptic stuff around and unfortunatly i cannot copy paste out of the tool tip box where the message is displayed when you move the mouse over the red X on the left side of the editor.
below in the console he only reports an error with no detailed information.
i am using oxygen 8.1 und eclipse 3.2

meanwhile i found out, if you create a scenario for a certain document where the extension is set (using the extension button on the dialog) then for this, and only for this document the errors are not set any longer.

a potential bug i found in the scenario dialog is that you cannot reference external xml files, eventhough you can choose them through the file chooser which returns the correct path. he only accepts xml files within the workspace.
the amazing thing is, that you can transform, but only when using the debugger the system throws the error message to use xml files within the workspace.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

claus wrote:i cannot copy paste out of the tool tip box where the message is displayed
You can copy the error message: right click on the error in the Problems view, select the action Copy from the popup menu, press Ctrl + V (Paste) in any text editor.
claus wrote:then for this, and only for this document the errors are not set any longer.
It solves the error for this document and for all the documents associated with the same scenario. If you use ${currentFileURL} in the URL field of the scenario you can use the same scenario with different documents.
claus wrote:you cannot reference external xml files, eventhough you can choose them through the file chooser which returns the correct path. he only accepts xml files within the workspace.
There are two buttons for opening a file dialog: a blue button that displays only workspace files and a yellow button that displays all the files from the disk. With the yellow button you can reference external files.

claus wrote:the amazing thing is, that you can transform, but only when using the debugger the system throws the error message to use xml files within the workspace.
That is a limitation of Eclipse that cannot place markers (breakpoints, errors, etc) in an editor panel which contains an external file.


Regards,
Sorin
claus
Posts: 5
Joined: Tue Nov 06, 2007 3:05 pm

Post by claus »

hi sorin,

thanks for your reply.
uupps, i forgot about the problems menu - here the paste from the problems view:

Severity and Description Path Resource Location Creation Time Id
XPath syntax error at char 17 on line 47 in {log:debug('test')}:
Cannot find a matching 1-argument function named {misc.XsltLogger}debug()
@see: http://www.w3.org/TR/xpath20/#ERRXPST0003 XTest/saxon replace1.xsl line 47 1194602035920 329774

setting the scenario only solves the problem when you let it run. different files need different scenarios - . this really does not solve the problem professionally. whenever editing new files and using the extensions i still have everything "red".
to bring this to an end: did the above aproach by editing the plugin.xml and throwing the jar file into the lib folder work for anybody so far??? it definetly does not work for me and seems not to have worked for george.
only the proceeding for handling private extensions for the standalone oxygen works as described.

as i implied in my post before about referencing xml files in the scenario dialog, i used the button for files from anywhere, the other button for files from the workspace does not give me the choice to select files from elsewhere. i should have explanained that more explicitly.
thanks for the explanation with the eclipse limitation - that makes sense.

regards, claus
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

claus wrote:did the above aproach by editing the plugin.xml and throwing the jar file into the lib folder work for anybody so far??? it definetly does not work for me and seems not to have worked for george.
Yes, that approach should work. What is your version of Eclipse and your version of the oXygen plugin?
claus wrote:as i implied in my post before about referencing xml files in the scenario dialog, i used the button for files from anywhere
claus wrote:a potential bug i found in the scenario dialog is that you cannot reference external xml files
In that case I do not understand the potential bug. Do you get an error when you run a transformation and an XML file that is not in the workspace (it is external to the workspace) is specified in the transformation scenario?


Regards,
Sorin
claus
Posts: 5
Joined: Tue Nov 06, 2007 3:05 pm

Post by claus »

sorin wrote:
claus wrote:did the above aproach by editing the plugin.xml and throwing the jar file into the lib folder work for anybody so far??? it definetly does not work for me and seems not to have worked for george.
Yes, that approach should work. What is your version of Eclipse and your version of the oXygen plugin?
[/quote]

i am using eclipse:
Version: 3.2.2
Build id: M20070212-1330

and oxygen 8.1.0 plugin

what do you mean by "should work" ? did you test it yourself?
if this is the case i would like to find out why it does not work in my installation, while it is no problem elsewhere.

sorin wrote:
claus wrote:as i implied in my post before about referencing xml files in the scenario dialog, i used the button for files from anywhere
claus wrote:a potential bug i found in the scenario dialog is that you cannot reference external xml files
In that case I do not understand the potential bug. Do you get an error when you run a transformation and an XML file that is not in the workspace (it is external to the workspace) is specified in the transformation scenario?
the potential bug i meant the fact, that i could not debug a file that was choosen from outside the workspace. when i made that first statement i did not have your explanation about the eclipse limitations on external files.

He comes with this message when trying to debug:
Cannot find the specified file
file:/C:/.../test.xml in the Eclipse's workspace.
Please create a project that includes the file.


it is just a little confusing to allow the user choose files that cannot be used in some cases, like this debug session - thats all - nothing worth discussing further. for me the above problem with declaring the extensions is far more important.

regards, claus
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

claus wrote:what do you mean by "should work" ? did you test it yourself?
if this is the case i would like to find out why it does not work in my installation, while it is no problem elsewhere.
Yes, I tested it today with an installed oXygen plugin and it worked correctly in the same way as it worked when it was documented in the User Manual. If you followed all the steps from the User Manual I think it should work also on your computer. Did you add the correct relative file path of your jar file with the Java extensions classes in the runtime section of the plugin.xml file from the oXygen plugin subfolder in the Eclipse plugins folder? Can you post here the lines that you added in the plugin.xml file? What is the exact location of the jar file with your Java extensions? Does the jar file contain the correct directory structure for the Java packages of your classes? Also if you are sure that the error is not in these details which I am asking you please send us some sample files for reproducing the problem: XML and XSL files, a jar file with your extensions.


Regards,
Sorin
claus
Posts: 5
Joined: Tue Nov 06, 2007 3:05 pm

Post by claus »

i think i did all that path stuff correct. i postet above already what i added to the xml file and where i put the jar. if those paths would be wrong my debug scenarios etc. should not work either. to where in the user manuall do you refer - i did not find the infos in the user manual, but here in this thread.
anyway, i will create a test scenario in the next days which is better to follow.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

claus wrote:to where in the user manuall do you refer - i did not find the infos in the user manual, but here in this thread.
The section Configuring the XSLT processor extensions paths of the chapter Transforming documents in the oXygen plugin User Manual which you can find also in Eclipse from menu Help -> Help Contents -> oXygen XML Editor User Manual for Eclipse.


Regards,
Sorin
stephen lawson
Posts: 3
Joined: Thu Jan 10, 2008 12:40 pm

Post by stephen lawson »

Hi all, I am experincing the same problems with red 'X's against xsl files.

The XSL works fine when debugging (doing a code based transformation) so the class can be resolved. I would like to get rid of the Red 'X's.
I can see that it may be possible to add Jars to the buildpath. However is it possible to add a Classpath. The XSL I use is contained in the same folder (or there abouts) as the Class with the extension functions. Building a Jar file everytime I need to add/edit/delete a function from the class path is time consuming.

It would useful to have a way of adding the project you are working in as a Classpath to the XSL validation (not the scenario based validation). This way the changes to a class you are writing would be immeaditely reflected in the XSL file you are calling the Class from.

If there is a way of resolving this please let me know.

Stephen...
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

If you want to have no XSLT validation errors for XSLT stylesheets edited with the oXygen plugin you have to set your Java extensions in a validation scenario. You should set the folder(s) containing the .class files for avoiding a rebuild of the jar file(s) containing these .class files. Every validation action reloads the .class files / jar files from the location set in the validation scenario so the most recent version generated by your Java compiler on disk is always used for a validation operation.



Regards,
Sorin
stephen lawson
Posts: 3
Joined: Thu Jan 10, 2008 12:40 pm

Post by stephen lawson »

Thanks for your response.
This solution is fine when working as a solo developer. On a team this solution this could be a bit cumbersome. This is because every developer will be expected to configure a validation scenario per xsl file (of which there is many) to avoid validation errors.

Stephen
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Why don't you store the scenarios at project level instead of global level and share the project with the other developers? Just select the Project Scenarios in the Configure Validation Scenarios dialog.


Regards,
Sorin
stephen lawson
Posts: 3
Joined: Thu Jan 10, 2008 12:40 pm

Post by stephen lawson »

Hi Sorin,
I hae now managed to configure the validation scenrio. Where do the files gets stored for the scenario? Could you also recommend a way of sourcecontrolling this scenario?

Many thanks for the assistance so far....
Regards, Stephen
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

The settings of a global scenario are stored in the user preferences. If you want to manage the scenario with a source control system you should use a project level scenario instead of a global one, by selecting the Project Scenarios option in the Configure Transformation Scenario dialog and add the current oXygen project file to the source control system. The current oXygen project is the one displayed in the Project view.The default one is [oXygen-install-folder]/samples/sample.xpr.


Regards,
Sorin
Post Reply