Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-2676

Degredation: Custom class generation templates are not working anymore

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 4.1
    • Fix Version/s: 4.1.1, 4.2.M2
    • Component/s: cgen, Modeler
    • Labels:
    • Environment:
      Windows 10
    • Flags:
      Patch, Important

      Description

      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

      rootPath.getURL().getPath()

      anymore and causes the exception. The pattern 

      rootPath.getURL().toURI()
      

      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

      org.apache.cayenne.gen.ClassGenerationAction.java#285, getTemplate(...)
      if (cgenConfiguration.getRootPath() != null) {
           props.put("cayenne.resource.loader.path", cgenConfiguration.getRootPath().toString());
      }
      

       

      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)

        Attachments

          Activity

            People

            • Assignee:
              ntimofeev Nikita Timofeev
              Reporter:
              sITo Stefan S.
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: