Hi Erando,

No, I can't really say where the problem is based on your description... it 
sounds to me like you got it right.

Here's something you could do, try instantiating the command directly within 
groovy:

mgnl> command = new commands.TestCommand();
mgnl> command.getClass().getName();

The first line will instantiate a new TestCommand object. The second line tries 
to call a method on it, to make sure it is properly loaded.
You would expect the output to be "commands.TestCommand", the name of the 
loaded class.

This should give you some more information about where to look for the problem:
- If the class cannot be found, then there is a problem with your compiled 
class, or the folder-names, or some other reason the class cannot be found or 
loaded.
- If the class is found, then the compilation and installation in tomcat was 
fine, and the problem lies with the command catalogue configuration in magnolia.

One possibility: I have observed in the past that some versions of magnolia 
only load the command if there is a command of the same name in the default 
catalogue. Maybe try to move your command to the default catalogue, and see if 
it works then?

Regards from Vienna,

Richard




-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] 
Im Auftrag von Erando (via Magnolia Forums)
Gesendet: Mittwoch, 09. Oktober 2013 14:21
An: Magnolia User List
Betreff: [magnolia-user] Re: Running custom command

Hello again,

big thank you to both of you! You really shed some light for me on that issue.
I have been working with Java and Eclipse already, but I have problems with 
importing my own custom java code to Magnolia and compiling it correctly. So 
you really helped me already here.

I have been following these steps of you, Richard:
[quote]Create a new Java Project.
Edit your Project's "Build Path" and add all the libraries from Magnolia's 
WEB-INF/lib folder using the "Add external JARs" button.
Add your class to the project.
Your class should now compile.
Find the .class file within the project folder (usually in a folder called 
"bin") and copy it to WEB-INF/classes.
Restart tomcat.[/quote]

In Eclipse I created a package "commands" so my class looks like this now:

[code]
package commands;

import info.magnolia.commands.MgnlCommand;
import info.magnolia.context.Context;

public class TestCommand extends MgnlCommand {
        public boolean execute(Context ctx) {
                System.out.println("TEST COMMAND");
                return true;
        }

}
[/code]

Note that the method is boolean now as the super class and its interfaces need 
me to implement the method like that. The class is compiling without errors and 
I copied both files in here:

/opt/magnolia-4.5.2/apache-tomcat-6.0.32/webapps/magnoliaAuthor/WEB-INF/classes/commands/TestCommand.class
/opt/magnolia-4.5.2apache-tomcat-6.0.32/webapps/magnoliaAuthor/WEB-INF/classes/commands/TestCommand.java

Then I adapted the "class" node to "commands.TestCommand" (but it's still in 
the "myModule" and "myCatalog" folder).
Unfortunately it's still not working:

[code]mgnl> cm = info.magnolia.commands.CommandsManager.getInstance()
===> 
info.magnolia.commands.CommandsManager@1f701045<mailto:info.magnolia.commands.CommandsManager@1f701045>
mgnl> command = cm.getCommand("myCatalog", "myCommand")
===> null[/code]

So I still return null. Why is that...do you have a clue?

Thanks once again!

--
Context is everything: 
http://forum.magnolia-cms.com/forum/thread.html?threadId=487971f2-483f-4373-a929-b5f1f50edc05


----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: 
<[email protected]<mailto:[email protected]>>
----------------------------------------------------------------





----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to