8 Replies Latest reply on Jul 16, 2002 5:11 PM by tthiele

    I need some help

    jacktr

      How can I logg out of a bean in Jboss 3? I found out, that Jboss uses log4j, but how can I e.g. log when a Bean enters the DB?
      could someone give me an answer?

        • 1. Re: I need some help
          tthiele

          Very simple:

          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");
          prepstmt.executeUpdate();

          hope this helps.
          Tilo

          • 2. Re: I need some help
            seven

            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.

            • 3. Re: I need some help
              jacktr

              To: Tilo
              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?


              To Seven:

              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?

              • 4. Re: I need some help
                tthiele

                Hi J,

                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.

                Tilo

                • 5. Re: I need some help
                  jacktr

                  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?

                  • 6. Re: I need some help
                    jacktr

                    Thanks. You were right. I included the jar file but the Ima9Logger class was not in there. it was a silly mistake.

                    • 7. Re: I need some help
                      jacktr

                      just ignore my last question, i already found out how to do that.

                      • 8. Re: I need some help
                        tthiele

                        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.