Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use ModelloCLI to convert .mdo files into *.java files - Unable to load java plugin #15

Open
wltjr opened this issue Oct 18, 2017 · 2 comments

Comments

@wltjr
Copy link

wltjr commented Oct 18, 2017

I am doing abnormal things! I have modello built and running fine. I am trying to use the java plugin. I am seeing some really strange stuff. It seems to initialize twice, and only on the first is the plugins populated. Such that when it goes to getPlugin, the hashmap is empty. I added some debug code.

--- a/src/main/java/org/codehaus/modello/plugin/AbstractPluginManager.java
+++ b/src/main/java/org/codehaus/modello/plugin/AbstractPluginManager.java
@@ -42,6 +42,17 @@ public abstract class AbstractPluginManager<T>

     public void initialize()
     {
+        System.out.println("init");
+        printMap();
+    }
+
+    public void printMap()
+    {
+        for (String name: plugins.keySet()){
+            String key = name.toString();
+            String value = plugins.get(name).toString();
+            System.out.println(key + " " + value);
+        }
     }

     public Map<String, T> getPlugins()
@@ -56,6 +67,8 @@ public abstract class AbstractPluginManager<T>

     public T getPlugin( String name )
     {
+        printMap();
+        System.out.println("getPlugin = "+name);
         T plugin = plugins.get( name );

         if ( plugin == null )

Here is the output,and you can see the plugins are available at first. But then it inits again, not sure why. Seems that is where the empty hashmap comes from. Next I will throw an exception so I can see what is calling that each time. Not sure if this is a bug, or usability issues. Maybe order of plexus jars on classpath? I am doing this via command line, ModelloCLI.

You can see the 2 inits, and by the time it calls getPlugin method, its empty.

init
model org.codehaus.modello.plugin.model.ModelMetadataPlugin@52d455b8
java org.codehaus.modello.plugin.java.metadata.JavaMetadataPlugin@6956de9
init
getPlugin = java
Exception in thread "main" org.codehaus.modello.ModelloRuntimeException: No such plugin: java
        at org.codehaus.modello.plugin.AbstractPluginManager.getPlugin(AbstractPluginManager.java:76)
        at org.codehaus.modello.core.DefaultGeneratorPluginManager.getGeneratorPlugin(DefaultGeneratorPluginManager.java:38)
        at org.codehaus.modello.core.DefaultModelloCore.generate(DefaultModelloCore.java:374)
        at org.codehaus.modello.Modello.generate(Modello.java:65)
        at org.codehaus.modello.ModelloCli.main(ModelloCli.java:49)
@wltjr
Copy link
Author

wltjr commented Jun 14, 2018

Looks like this is a long time known issue since 2009...

@wltjr
Copy link
Author

wltjr commented Jun 14, 2018

That issue is unrelated, as it was from a missing jar/cnfe. I believe I am having a Generator issue. It seems to find and list the MetaDataPlugins JavaMetaDataPlugin, but not sure about the Generators, JavaModelloGenerator.

If I add the following to modello-core components.xml. Which I know is incorrect, but it is the only change that seems to have any effect. Also what makes me think my problem is something related to Generators, that plugin manager or something.

--- a/src/main/resources/META-INF/plexus/components.xml
+++ b/src/main/resources/META-INF/plexus/components.xml
@@ -41,5 +41,10 @@
       <role-hint>model</role-hint>
       <implementation>org.codehaus.modello.plugin.model.ModelMetadataPlugin</implementation>
     </component>
+    <component>
+      <role>org.codehaus.modello.plugin.ModelloGenerator</role>
+      <role-hint>model</role-hint>
+      <implementation>org.codehaus.modello.core.DefaultGeneratorPluginManager</implementation>
+    </component>
   </components>
 </component-set>

I get the following output. Without I do not get the lines with DefaultGeneratorPluginManager

# modello extension.mdo java src/main/java 4.0.0 false true

DefaultPlexusContainer
AbstractPluginManager.initialize()
plugins = 2
model : org.codehaus.modello.plugin.model.ModelMetadataPlugin@2b4a2ec7
java : org.codehaus.modello.plugin.java.metadata.JavaMetadataPlugin@62e136d3
AbstractPluginManager.initialize()
plugins = 3
AbstractPluginManager.initialize()
plugins = 0
model : org.codehaus.modello.core.DefaultGeneratorPluginManager@2c34f934
ModelloCore
new Modello()
parsed args
generatorId =java
plugins = 3
model : org.codehaus.modello.core.DefaultGeneratorPluginManager@2c34f934
getPlugin = java
Exception in thread "main" org.codehaus.modello.ModelloRuntimeException: No such plugin: java
        at org.codehaus.modello.plugin.AbstractPluginManager.getPlugin(AbstractPluginManager.java:73)
        at org.codehaus.modello.core.DefaultGeneratorPluginManager.getGeneratorPlugin(DefaultGeneratorPluginManager.java:39)
        at org.codehaus.modello.core.DefaultModelloCore.generate(DefaultModelloCore.java:374)
        at org.codehaus.modello.Modello.generate(Modello.java:67)
        at org.codehaus.modello.ModelloCli.main(ModelloCli.java:51)

Then if I pass model as the argument instead of java.

modello extension.mdo model src/main/java 1.0.0 false true

DefaultPlexusContainer
AbstractPluginManager.initialize()
plugins = 2
model : org.codehaus.modello.plugin.model.ModelMetadataPlugin@7fe8ea47
java : org.codehaus.modello.plugin.java.metadata.JavaMetadataPlugin@1dd92fe2
AbstractPluginManager.initialize()
plugins = 2
AbstractPluginManager.initialize()
plugins = 0
model : org.codehaus.modello.core.DefaultGeneratorPluginManager@176d53b2
ModelloCore
new Modello()
parsed args
generatorId =model
plugins = 2
model : org.codehaus.modello.core.DefaultGeneratorPluginManager@176d53b2
getPlugin = model
Exception in thread "main" java.lang.ClassCastException: org.codehaus.modello.core.DefaultGeneratorPluginManager cannot be cast to org.codehaus.modello.plugin.ModelloGenerator
        at org.codehaus.modello.core.DefaultGeneratorPluginManager.getGeneratorPlugin(DefaultGeneratorPluginManager.java:39)
        at org.codehaus.modello.core.DefaultModelloCore.generate(DefaultModelloCore.java:374)
        at org.codehaus.modello.Modello.generate(Modello.java:67)
        at org.codehaus.modello.ModelloCli.main(ModelloCli.java:51)

@wltjr wltjr changed the title Unable to load java plugin Cannot use ModelloCLI to convert .mdo files into *.java files - Unable to load java plugin Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant