2

Recently we deployed one struts application into production, after sometime if we try to find out the list of jar files opened, it showing two many jar files opened can anybody tell me why this happening?

lsof | grep struts

java       9762      root  mem       REG              253,1   2326673   31850728 /smanne/feat-01/app/WEB-INF/lib/struts2-core-2.0.14.jar
java       9762      root  mem       REG              253,1   2326673   16121954 /smanne/dev-01/app/WEB-INF/lib/struts2-core-2.0.14.jar
java       9762      root   47r      REG              253,1   2326673   16121954 /smanne/dev-01/app/WEB-INF/lib/struts2-core-2.0.14.jar
java       9762      root   50r      REG              253,1   2326673   16121954 /smanne/dev-01/app/WEB-INF/lib/struts2-core-2.0.14.jar
java       9762      root   51r      REG              253,1   2326673   16121954 /smanne/dev-01/app/WEB-INF/lib/struts2-core-2.0.14.jar
java       9762      root   53r      REG              253,1   2326673   16121954 /smanne/dev-01/app/WEB-INF/lib/struts2-core-2.0.14.jar
java       9762      root   54u      REG              253,1   2326673   16121954 /smanne/dev-01/app/WEB-INF/lib/struts2-core-2.0.14.jar
java       9762      root   56r      REG              253,1   2326673   16121954 /smanne/dev-01/app/WEB-INF/lib/struts2-core-2.0.14.jar
java       9762      root   57r      REG              253,1   2326673   16121954 /smanne/dev-01/app/WEB-INF/lib/struts2-core-2.0.14.jar
java       9762      root   58r      REG              253,1   2326673   16121954 /smanne/dev-01/app/WEB-INF/lib/struts2-core-2.0.14.jar
java       9762      root   59r      REG              253,1   2326673   16121954 /smanne/dev-01/app/WEB-INF/lib/struts2-core-2.0.14.jar
java       9762      root   60r      REG              253,1   2326673   16121954 /smanne/dev-01/app/WEB-INF/lib/struts2-core-2.0.14.jar
java       9762      root  113r      REG              253,1   2326673   31850728 /smanne/feat-01/app/WEB-INF/lib/struts2-core-2.0.14.jar
java       9762      root  120r      REG              253,1   2326673   16121954 /smanne/dev-01/app/WEB-INF/lib/struts2-core-2.0.14.jar
java      23871      root  mem       REG              253,1   2326674    6324271 /reports/dev-01/libs/struts2-core-2.0.14.jar
java      23871      root    6r      REG              253,1   2326674    6324271 /reports/dev-01/libs/struts2-core-2.0.14.jar

is there any method to share the jar files?

Sandeep Manne
  • 6,030
  • 5
  • 39
  • 55
  • Do you deploy several apps into same tomcat and same jar files are loaded several times? – fmucar Jan 14 '11 at 11:31
  • can u confirm that if a jar file is placed in web-inf/lib it will be loaded for each request? – Sandeep Manne Jan 14 '11 at 11:55
  • No, not per request but per application. – fmucar Jan 14 '11 at 12:01
  • then /smanne/dev-01/app/WEB-INF/lib/struts2-core-2.0.14.jar is same application but its loaded several times any problem in configuration – Sandeep Manne Jan 14 '11 at 12:04
  • 2
    this jar is **not** "loaded" - someone reads a resource from it... – mtraut Jan 14 '11 at 12:18
  • @mtraut is there any way to make this resource available centrally and make all of them read from the same resource instead of opening again and again – Sandeep Manne Jan 14 '11 at 12:42
  • I dont get the question. The "file resource" is unique. But any reader of the file (if this is the reason for the output you see) needs a platform handle to the file itself. This is a different resource, an operating system handle that holds things like "current pointer into file". Why don't you just try and write a little app that gets two or more entries in a Jar and gets the input stream. If you make lsof at this moment in time, you should see two entries of the above kind (if lsof does what i think it does) – mtraut Jan 14 '11 at 12:49

2 Answers2

1
TOMCAT_HOME\lib\

You can place shared libraries into above dir.

fmucar
  • 14,361
  • 2
  • 45
  • 50
0

Maybe

  • Multiple resources are read from the file
  • You do hot deploy and handles are still open from previous application context

EDIT

Well, i'm not a unix guru but i assume "lsof" shows open handles. So, every time a file stream is opened or closed, this will change.

mtraut
  • 4,720
  • 3
  • 24
  • 33
  • lsof | grep struts - this command is giving different results at different times, some times number of opened files are less and some times its increasing? any input why – Sandeep Manne Jan 14 '11 at 12:01