You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Darryl Stoflet <ds...@calweb.com> on 2000/03/15 14:27:42 UTC

Re: cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/context DefaultCMSetter.java

shachor,

	This doesn't completely fix this problem as my fix did I sent
in last week. Reason being the path sent to loader.addRepository
is relative and thus the AdaptiveServletLoader will look for that path
relative to the directory where you started tomcat, which in the
current snapshot is from the bin directory which will fail with a
path like the following:
D:\usr\cvs\src\build\tomcat\bin\webapps\examples\WEB-INF\lib\MyEJBBeanClient.jar 
.............................^

The line below:
loader.addRepository( new File( base + "/WEB-INF/lib/" +jarfile ));

should be:
loader.addRepository( new File(f,jarfile ));


Regards,
	Darryl Stoflet

shachor@locus.apache.org wrote:
> 
> shachor     00/03/15 01:42:20
> 
>   Modified:    src/share/org/apache/tomcat/context DefaultCMSetter.java
>   Log:
>   Fix for the jar@lib directory problem.
>   Thanks for Kevin Jones (kevinj@develop.com) for providing the fix.
> 
>   Revision  Changes    Path
>   1.23      +22 -13    jakarta-tomcat/src/share/org/apache/tomcat/context/DefaultCMSetter.java
> 
>   Index: DefaultCMSetter.java
>   ===================================================================
>   RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/DefaultCMSetter.java,v
>   retrieving revision 1.22
>   retrieving revision 1.23
>   diff -u -r1.22 -r1.23
>   --- DefaultCMSetter.java      2000/03/01 21:06:05     1.22
>   +++ DefaultCMSetter.java      2000/03/15 09:42:19     1.23
>   @@ -55,7 +55,7 @@
>     *
>     * [Additional notices, if required by prior licensing conditions]
>     *
>   - */
>   + */
> 
> 
>    package org.apache.tomcat.context;
>   @@ -118,7 +118,7 @@
>         ctx.setAttribute(Constants.ATTRIB_WORKDIR , ctx.getWorkDir());
> 
>         // Set default session manager if none set
>   -     if( ctx.getSessionManager() == null )
>   +     if( ctx.getSessionManager() == null )
>             ctx.setSessionManager(new org.apache.tomcat.session.StandardSessionManager());
>         //  Alternative: org.apache.tomcat.session.ServerSessionManager.getManager();
> 
>   @@ -149,7 +149,7 @@
>             throw new TomcatException( "Error loading default error servlet ", ex );
>         }
>        }
>   -
>   +
>        private void initURLs(Context context) {
>         ServletLoader loader=context.getServletLoader();
>         if( loader==null) return;
>   @@ -158,19 +158,19 @@
> 
>         String base = context.getDocBase();
>         File dir = new File(base + "/WEB-INF/classes");
>   -        if (!dir.isAbsolute()) {
>   -            // evaluate repository path relative to the context's home directory
>   -            ContextManager cm = context.getContextManager();
>   -         dir = new File(cm.getHome(), base + "/WEB-INF/classes");
>   -        }
>   +
>   +        // GS, Fix for the jar@lib directory problem.
>   +        // Thanks for Kevin Jones for providing the fix.
>   +        dir = getAbsolute(dir, context);
>         if( dir.exists() ) {
>             loader.addRepository( dir );
>         }
> 
>         File f =  new File(base + "/WEB-INF/lib");
>   +        f = getAbsolute(f, context);
>         Vector jars = new Vector();
>         getJars(jars, f);
>   -
>   +
>         for(int i=0; i < jars.size(); ++i) {
>             String jarfile = (String) jars.elementAt(i);
>             loader.addRepository( new File( base + "/WEB-INF/lib/" +jarfile ));
>   @@ -183,7 +183,7 @@
>                 public boolean accept(File dir, String fname) {
>                     if(fname.endsWith(".jar"))
>                         return true;
>   -
>   +
>                     return false;
>                 }
>             };
>   @@ -192,11 +192,11 @@
>                     File f1 = new File(dir, fname);
>                     if(f1.isDirectory())
>                         return true;
>   -
>   +
>                     return false;
>                 }
>             };
>   -
>   +
>            if(f.exists() && f.isDirectory() && f.isAbsolute()) {
>                String[] jarlist = f.list(jarfilter);
> 
>   @@ -213,12 +213,21 @@
>            }
>        }
> 
>   +    private File getAbsolute(File f, Context c) {
>   +        if (!f.isAbsolute()) {
>   +            // evaluate repository path relative to the context's home directory
>   +            ContextManager cm = c.getContextManager();
>   +         return new File(cm.getHome(), f.getPath());
>   +        }
>   +        return f;
>   +    }
>   +
>        // -------------------- implementation
>        /** Encoded ContextManager.getWorkDir() + host + port + path
>         */
>        private void setWorkDir(Context ctx ) {
>         ContextManager cm=ctx.getContextManager();
>   -
>   +
>         StringBuffer sb=new StringBuffer();
>         sb.append(cm.getWorkDir());
>         sb.append(File.separator);
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org

-- 
Darryl Stoflet
http://dstoflet.calweb.com