can a webservice load jars during run time

Posted by KItis on Stack Overflow See other posts from Stack Overflow or by KItis
Published on 2010-04-16T06:12:48Z Indexed on 2010/04/16 6:23 UTC
Read the original article Hit count: 247

I have created a simple web-service using Java. i want to load jars related to web-service during runtime. I have done this task for normal Java application. there what I did was

            JarFile jar = new JarFile(f.getPath());

final Manifest manifest = jar.getManifest();
final Attributes mattr = manifest.getMainAttributes();

// Read the manifset in jar files and get the Name attribute
// whare it specified the class that need to load
//for (Object a : mattr.keySet()) {
for (Iterator iter = mattr.keySet().iterator(); iter.hasNext();) {
 Object obj = (Object)iter.next();
 if ("ServiceName".equals(obj.toString()))
  className = mattr.getValue((Name) obj);
 //System.out.println(className);
}

/*
 * Create the jar class loader and use the first argument passed
 * in from the command line as the jar file to use.
 */
JarClassLoader jarLoader = new JarClassLoader(f.getPath());

/* Load the class from the jar file and resolve it. */
Class c = jarLoader.loadClass(className, true);

My problem is

  1. can I put jars that need to be loaded during run time in to separate folder rather than putting in to WEBINF folder.

  2. do i have to put jars both in axis and web-application.

thanks in advance for any contribution for this question.

© Stack Overflow or respective owner

Related posts about java

Related posts about web-development