0

I've some problem printing the exception stack trace for Alfresco Exception.

On debug mode, step by step under Eclipse IDE I'm able to see the message when the exception is raised inspecting the Exception object but, when I send the error message to console output it's always null.

The exception is raised by this instruction:

try {
    UpdateResult[] results = WebServiceFactory.getRepositoryService().update(cml);
}
catch (Exception ex) {
    System.out.println(" " + ex.getStackTrace());           
    System.out.println("ERROR - createContent : " + ex.getMessage());
}

(in that case I tryed to write on a folder that not exists on repository) and inspecting the ex object on eclipse I can see the message:

java.lang.IllegalStateException: Failed to resolve to a single NodeRef with parameters (store=workspace:SpacesStore uuid=null path=/app:company_home/cm:UploadFromJava), found 0 nodes.

but ex.getMessage() returns null

Anyone could help me?

thanks, Andrea

Andrea Girardi
  • 4,337
  • 13
  • 69
  • 98
  • How do you "send" the exception to the console? – skuro Sep 27 '11 at 22:34
  • Tryed with Ex.toString() / ex.getStackTrace() / Ex.getMessage() [sorry for my bad english ;) ] – Andrea Girardi Sep 27 '11 at 22:36
  • I'm sorry, I still think some more details would help here. Could you post for instance the code that throws the exception? Or the stack trace as you collect it from the debugger? Or which method are you using to pipe the results of those `toString` calls to the console? – skuro Sep 28 '11 at 11:57

2 Answers2

1

Implementing a method in this way:

NamedValue setNameProperty(String name) throws AlfrescoRuntimeException
{
    try {
        return Utils.createNamedValue(Constants.PROP_NAME, name);
    }
    catch (Exception ex) {
        throw new AlfrescoRuntimeException(ex.getMessage());
    }
}

The message is correclty printed with e.printStackTrace();

Andrea Girardi
  • 4,337
  • 13
  • 69
  • 98
0

Try to replace your package in the log4j.properties from debug to error

Mohammed Amr
  • 307
  • 5
  • 15