Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

RMI with Log4J

Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Y'all,
So here's my little story...
We're building a fairly large app Servlet/Applet
Our servlet classes all uses log4j with no problems.
obviously this couldn't be that perfect so when I tried to do some RMI call to the classes on the Server the Log4J class aren't found.
I'm pretty sure that I have a classpath problem, but I have no idea where to set it to get the Deamon to see my log4j.jar. I tried the Env classpath. I tried to put a -classpath on the rmid call. Nothing seems to work and I'm getting pretty desparate.
Please somebody heeeeeeeeeeeeeeeeeeeeeeeeeeeeeelp.

Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you will have to use the socketAppender on ur client side.
On the server side you will run a socketserver (e.g. SimpleSocketServer) to listen for the messages logged from the client. And use a file/console appender to log those messages. Since they are in different JVMs they will have diff setups. The socketAppender will send the messages to the server side.
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Log4J with my RMI application, where my applet uses RMI to communicate with the server. The applet uses the log4J package, and the server also uses it.
I found 2 ways, one was to unjar the log4j.jar, then include it in the .jar for your applet.
A better approach was to build the classpath into the manifest of your applet's .jar. Then specify it in your HTML, such as the following Plug-In Object tag:
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"<br /> WIDTH = 612 HEIGHT = 393<br /> codebase=",2,0,0">;
<PARAM NAME = CODE VALUE = spi.client.gui.LicenseeApplet.class >
<PARAM NAME="scriptable" VALUE="true">
<PARAM NAME = ARCHIVE VALUE = log4j.jar,licenseApp.jar >
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.2">
<PARAM NAME="cache_option" VALUE="Plugin">
<PARAM NAME="cache_archive" VALUE="licenseApp.jar, log4j.jar">
This allows my applet to use the log4j classes to log to the client's machine.
I also created an RMI class to pass strings from the client to the server, then the server implementation of the class calls the Log4J classes to get the Strings logged. This allows my applet to log to the server's log.
Hope that helps.
    Bookmark Topic Watch Topic
  • New Topic