Doxia APT support coming closer
Written on August 16, 2009 by Allan Lykke Christensen
This and last weekend I’ve been working on improving the Doxia APT support in NetBeans. Namely I’ve been trying to integrate the Doxia APT parser with the NetBeans Lexer classes and secondly I’ve been implementing multi view support in the editor.
Doxia APT Parser integration
Last weekend a spend several hours trying to get my head around the Doxia Apt Parser and how it could be integrated with the NetBeans Lexer classes. Unfortunately I never found a way to do the integration. The NetBeans Lexer require that you implement the org.netbeans.spi.lexer.Lexer interface including a method, nextToken(), where each token is extracted as the file is being read. The Doxia AptParser on the other hand provide a simple parse method completing the parsing in one step. The two paradigms of parsing doesn’t seem to be compatible. If anyone got an idea on how to integrate the two I’d love to hear from you.
Multi View
The purpose of the multi view is to let Apt writers switch between the source code of an APT file and its rendered representation. So far I’ve managed to set up the NetBeans plumbing for displaying the two views and their components.
Unfortunately I’ve run into a Classloader problem when using the Doxia Converter classes for turning APT files into XHTML files. Outside NetBeans the converter is working perfectly, but when I use it with the multi view inside NetBeans I get the following exception:
WARNING [org.netbeans.ProxyClassLoader]: Will not load class org.codehaus.plexus.container.initialization.InitializeResourcesPhase arbitrarily from one of ModuleCL@57a41eae[dk.i2m.netbeans.langsupport.apt] and ModuleCL@4ba805a3[org.netbeans.modules.maven.embedder] starting from SystemClassLoader[511 modules]; see http://wiki.netbeans.org/DevFaqModuleCCE
SEVERE [org.openide.util.Exceptions]
java.lang.ClassNotFoundException: org.codehaus.plexus.container.initialization.InitializeResourcesPhase
WARNING [org.netbeans.ProxyClassLoader]: Will not load class org.codehaus.plexus.container.initialization.InitializeResourcesPhase arbitrarily from one of ModuleCL@57a41eae[dk.i2m.netbeans.langsupport.apt] and ModuleCL@4ba805a3[org.netbeans.modules.maven.embedder] starting from SystemClassLoader[511 modules]; see http://wiki.netbeans.org/DevFaqModuleCCE
SEVERE [org.openide.util.Exceptions]
java.lang.ClassNotFoundException: org.codehaus.plexus.container.initialization.InitializeResourcesPhase
...
I am still to look into what can be done about the classloader problem. I’ve checked the suggested link (http://wiki.netbeans.org/DevFaqModuleCCE), but it seems to only explain the problem, without providing a solution or workaround.
That’s all for now!
If you enjoyed this post Subscribe to our feed

What exactly does the Doxia Converter contain for classes? It seems to contains the complete plexus container. It’s probably the first occasion where 2 plexus containers are used in the module system. It seems to use the context classloader for component discovery. I might have defeated that by tweaking the classworlds library that handles classloading for plexus. I’ll take a look at your code, maybe I can make it go away.. If not, then it might make sense to rip off all plexus related stuff from the doxia converter jar and only use the doxia specific stuff. Either directly or add a dependency to maven.embedder to have the plexus container classes included.
http://kenai.com/jira/browse/NB_GOODIES-4
I was not sure how to test, but I haven’t got any exception when testing the module..
Thanks you very much mkleint! Got the patch integrated and now got the render view working. I believe that I still need to exclude some of the many Plexus libraries as I’m only using the APT-to-XHTML converter.