Stefan S. created CAY-2676:
------------------------------
Summary: Degredation: Custom class generation templates are not
working anymore
Key: CAY-2676
URL: https://issues.apache.org/jira/browse/CAY-2676
Project: Cayenne
Issue Type: Bug
Components: cgen, Modeler
Affects Versions: 4.1
Environment: Windows 10
Reporter: Stefan S.
Attachments:
cayenne_patch_class_generation_template_selection_exception.diff
When selecting a custom class generation template in Modeler, DataMap - Class
Generation panel, the exception as below occurs.
1) As root cause, line URI/URL to Path conversion in line #170 of
org.apache.cayenne.modeler.CodeTemplateManager.java could be identified: The
prior conversion from the data map 'root path' to an URI inserts a trailing '/'
in front of the drive letter on Windows systems. This slash is not removed by
the used sequence
{code:java}
rootPath.getURL().getPath(){code}
anymore and causes the exception. The pattern
{code:java}
rootPath.getURL().toURI()
{code}
works (on Windows).
2) After fixing the issue above, the template selection worked but the template
files have not been loaded by cgen. Root cause: Modeler creates template paths
relative to the location of the DataMap.xml file. This relative path cannot be
resolved by cgen.
Possible solution: Add DataMap root path to the base path map of the generator
action
{code:java}
org.apache.cayenne.gen.ClassGenerationAction.java#285, getTemplate(...)
if (cgenConfiguration.getRootPath() != null) {
props.put("cayenne.resource.loader.path",
cgenConfiguration.getRootPath().toString());
}
{code}
Please see attached patch addressing both tightly related issues for details.
*Exception* in thread "AWT-EventQueue-0" java.nio.file.InvalidPathException:
Illegal char <:> at index 2: /K:/Work/some/path/mydata.map.xmlException in
thread "AWT-EventQueue-0" java.nio.file.InvalidPathException: Illegal char <:>
at index 2: /K:/Work/some/path/mydata.map.xml at
sun.nio.fs.WindowsPathParser.normalize(Unknown Source) at
sun.nio.fs.WindowsPathParser.parse(Unknown Source) at
sun.nio.fs.WindowsPathParser.parse(Unknown Source) at
sun.nio.fs.WindowsPath.parse(Unknown Source) at
sun.nio.fs.WindowsFileSystem.getPath(Unknown Source) at
java.nio.file.Paths.get(Unknown Source) at
org.apache.cayenne.modeler.CodeTemplateManager.getTemplatePath(CodeTemplateManager.java:170)
at
org.apache.cayenne.modeler.editor.cgen.CustomModePanel$2.updateModel(CustomModePanel.java:78)
at
org.apache.cayenne.modeler.editor.cgen.CustomModePanel$2.updateModel(CustomModePanel.java:74)
at
org.apache.cayenne.modeler.util.ComboBoxAdapter.updateModel(ComboBoxAdapter.java:70)
at
org.apache.cayenne.modeler.util.ComboBoxAdapter.lambda$new$0(ComboBoxAdapter.java:39)
at javax.swing.JComboBox.fireActionEvent(Unknown Source) at
javax.swing.JComboBox.setSelectedItem(Unknown Source) at
javax.swing.JComboBox.setSelectedIndex(Unknown Source) at
javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(Unknown Source) at
java.awt.AWTEventMulticaster.mouseReleased(Unknown Source) at
java.awt.Component.processMouseEvent(Unknown Source) at
javax.swing.JComponent.processMouseEvent(Unknown Source) at
javax.swing.plaf.basic.BasicComboPopup$1.processMouseEvent(Unknown Source) at
java.awt.Component.processEvent(Unknown Source) at
java.awt.Container.processEvent(Unknown Source) at
java.awt.Component.dispatchEventImpl(Unknown Source) at
java.awt.Container.dispatchEventImpl(Unknown Source) at
java.awt.Component.dispatchEvent(Unknown Source) at
java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at
java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at
java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at
java.awt.Container.dispatchEventImpl(Unknown Source) at
java.awt.Window.dispatchEventImpl(Unknown Source) at
java.awt.Component.dispatchEvent(Unknown Source) at
java.awt.EventQueue.dispatchEventImpl(Unknown Source) at
java.awt.EventQueue.access$500(Unknown Source) at
java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown
Source) at java.security.AccessController.doPrivileged(Native Method) at
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown
Source) at
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown
Source) at java.awt.EventQueue$4.run(Unknown Source) at
java.awt.EventQueue$4.run(Unknown Source) at
java.security.AccessController.doPrivileged(Native Method) at
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown
Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at
java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at
java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at
java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at
java.awt.EventDispatchThread.pumpEvents(Unknown Source) at
java.awt.EventDispatchThread.pumpEvents(Unknown Source) at
java.awt.EventDispatchThread.run(Unknown Source)
--
This message was sent by Atlassian Jira
(v8.3.4#803005)