1. define a class variable
private static org.apache.log4j.Category log = org.apache.log4j.Category.getInstance(MyBean.class);
2. anywhere in your bean use it:
log.debug("bean is going to access db");
hope this helps.
U can also enable the logging of the CMP engine in jaws.xml or jbosscmp-jdbc.xml in order to view the jdbc calls the server is making to the DB.
thanks for your suggestion, now it is working. i have another question. i should use another logger for my beans. in terms i do the same as with the log4j, that means i create a instance of the logger and then run the logger, but i always get the following error:
java.rmi.ServerException:RemoteException occured in Server thread; nested exception is: javax.transaction. TransactionRolledback.Exception: MyLogger/Ima9Logger;nested exception is:java.lang.NoClassDefFoundError: MyLogger/Ima9Logger.
does this mean, that it is only possible to log out of a bean with RMI?
Do you mean the command <call-logging>true</call-logging> in the jbossstandard.xml? or the true in dthe jbosscmp-jdbc.xml? or is there another one?
ClassNotFoundException just says that your class loader(s) can't find
your logger class anywhere (seriously).
I have never heard anything about this logger class not to mention how to
initialize and/or to use it. At least you have to put the jar containing
the logging system in your appserver.jar/.ear or JBoss/lib/ext directory
in order to make JBoss possible to find it. I hope it's not too
complicated to integrate Ima9Logger system ;-)
If you don't have serious restrictions better take log4j
or the build-in logging mechanism.
you were right, in my jar File there was one class missing, thanks, i thought i included all.
is it right that beans are unable to communicate with the file system? if i have to create a file out of a Bean, how am i supposed to do that?
Thanks. You were right. I included the jar file but the Ima9Logger class was not in there. it was a silly mistake.
just ignore my last question, i already found out how to do that.
beans have a lot of restrictions. deny to access files is one of them. afaik you can do a loadResourceAsStream(...). I think you need a workaround.