Amitkumar Dhama

Ranch Hand
+ Follow
since Feb 14, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Amitkumar Dhama

Hi all ranchers,
i could not differtiate in which forum to post my previous question which was on classloader, thats why i posted it in two forums.
And i am appending the answers which i got from both of the forums..

FROM SERVLET FORUM....
This is not a Servlet question, moving to the Java in General (advanced) forum.

Dave

FROM Java in General (advanced)

Please do not post the same question to several forums, like you have done here. It leads to duplicated effort, and doesn't really increase your audience. Let's continue the discussion in the other thread, since this is a servlet-related topic.


This not the way to answer the question if you don't know you can simply tell me any ways my problem has been solved....
Tell me what to do..IN such type of cases...
15 years ago
Hi All Ranchers,

I am getting while creating classloader for my servlet container.
What I have done is that i have created a URLClassloader as bootstrap loader for all container classes.
Now whenever i try to create a new classloader for a deployed web application taking this bootstrap classloader as parent.
The web app classloader is again a URLClassloader which is gives first priorty to the classes availble in WEB-INF/classes to the WEB-INF/lib classes as shown below
=============================================================

final static String WEBAPP_CLASSES = "WEB-INF/classes";

final static String WEBAPP_LIB = "WEB-INF/lib";

public static ClassLoader forWebApp(File webAppDirPath) {
ClassLoader parent = Thread.currentThread().getContextClassLoader();
ClassLoader classesDirLoader = createLoader(webAppDirPath,
WEBAPP_CLASSES, parent);

ClassLoader libDirLoader = createLoader(webAppDirPath, WEBAPP_LIB,
classesDirLoader);

return libDirLoader;
}

private static URLClassLoader createLoader(File webAppDirPath,
String forDir, ClassLoader parent) {
String path;
URL urls[] = new URL[] {};
try {
path = webAppDirPath.getCanonicalPath() + "/" + forDir;
urls = createClassPathURLs(path);
} catch (IOException e) {
; // IGNORE and return not a valid path
log.error("Invalid DD path [" + webAppDirPath + "]!", e);
}

return new URLClassLoader(urls, parent);
}

private static URL[] createClassPathURLs(String path) {
URL urls[] = new URL[] {};
File webAppCls = new File(path);
if (webAppCls.exists() && webAppCls.isDirectory()) {
File conLibFiles[] = webAppCls.listFiles(new FileFilter() {
public boolean accept(File file) {
String fileName = file.getName().toLowerCase();
boolean isDir = file.isDirectory();
boolean isJar = fileName.endsWith(".jar");
boolean isZip = fileName.endsWith(".zip");
return !isDir && (isJar || isZip);
}
});

urls = new URL[conLibFiles.length + 1];
try {
urls[0] = webAppCls.toURL();
} catch (MalformedURLException e) {
; // IGNORE can't come now
}
for (int i = 0; i < conLibFiles.length; i++) {
try {
urls[i + 1] = conLibFiles[i].toURL();
} catch (MalformedURLException e) {
; // IGNORE
log.error("Invalid Class Path URL found [" + conLibFiles[i]
+ "]", e);
}
}
}
return urls;
}

==========================================================================
I am facing following problem
i.e The Web APP is having a class called a.b.Test
that is available in WEB-INF/classes dir and its referring to some
other class x.y.SomeJarClass in WEB-INF/lib dir.
But a java.lang.NoClassDefFoundError: is thrown for x.y.SomeJarClass in WEB-INF/lib dir.

thanking u in advance..
15 years ago
Hi All Ranchers,

I am getting while creating classloader for my servlet container.
What I have done is that i have created a URLClassloader as bootstrap loader for all container classes.
Now whenever i try to create a new classloader for a deployed web application taking this bootstrap classloader as parent.
The web app classloader is again a URLClassloader which is gives first priorty to the classes availble in WEB-INF/classes to the WEB-INF/lib classes as shown below
=============================================================

final static String WEBAPP_CLASSES = "WEB-INF/classes";

final static String WEBAPP_LIB = "WEB-INF/lib";

public static ClassLoader forWebApp(File webAppDirPath) {
ClassLoader parent = Thread.currentThread().getContextClassLoader();
ClassLoader classesDirLoader = createLoader(webAppDirPath,
WEBAPP_CLASSES, parent);

ClassLoader libDirLoader = createLoader(webAppDirPath, WEBAPP_LIB,
classesDirLoader);

return libDirLoader;
}

private static URLClassLoader createLoader(File webAppDirPath,
String forDir, ClassLoader parent) {
String path;
URL urls[] = new URL[] {};
try {
path = webAppDirPath.getCanonicalPath() + "/" + forDir;
urls = createClassPathURLs(path);
} catch (IOException e) {
; // IGNORE and return not a valid path
log.error("Invalid DD path [" + webAppDirPath + "]!", e);
}

return new URLClassLoader(urls, parent);
}

private static URL[] createClassPathURLs(String path) {
URL urls[] = new URL[] {};
File webAppCls = new File(path);
if (webAppCls.exists() && webAppCls.isDirectory()) {
File conLibFiles[] = webAppCls.listFiles(new FileFilter() {
public boolean accept(File file) {
String fileName = file.getName().toLowerCase();
boolean isDir = file.isDirectory();
boolean isJar = fileName.endsWith(".jar");
boolean isZip = fileName.endsWith(".zip");
return !isDir && (isJar || isZip);
}
});

urls = new URL[conLibFiles.length + 1];
try {
urls[0] = webAppCls.toURL();
} catch (MalformedURLException e) {
; // IGNORE can't come now
}
for (int i = 0; i < conLibFiles.length; i++) {
try {
urls[i + 1] = conLibFiles[i].toURL();
} catch (MalformedURLException e) {
; // IGNORE
log.error("Invalid Class Path URL found [" + conLibFiles[i]
+ "]", e);
}
}
}
return urls;
}

==========================================================================
I am facing following problem
i.e The Web APP is having a class called a.b.Test
that is available in WEB-INF/classes dir and its referring to some
other class x.y.SomeJarClass in WEB-INF/lib dir.
But a java.lang.NoClassDefFoundError: is thrown for x.y.SomeJarClass in WEB-INF/lib dir.

thanking u in advance..
15 years ago
Hi all ranchers,
this is my first mail to this section and my question is...

how to send an object through the socket

there are two members, string and int (name and age)in the class and i have receive the object and print the name and age on the server side...

tell me hw to solve the problem..
I know that this is not a very big problem. if u will give me some clue of hw to solve it or which good material to follow for this. i shall be thankfull to you..

thanking in advance...
15 years ago
Hello Ranchers,
can anybody tell me the exact def for debugging and a bug??
Thanking in advance..
15 years ago
Hi all can anybody explain me what are the

1.weakHashMap
2.softHashMap

Please explain me

thanking in advance!!!
15 years ago
i wanna know,

Object returned by the invocation of

connect.createStatment();

Like
1. Prepared stmt
2. collable stmt

i think that now it is clear to you...
SSL
Hi all, can anybody tell me how SSL is implemented on the site, orelse tell me the link where can i get the softcopy of this..

Thanking in advance...
[ January 16, 2006: Message edited by: Bear Bibeault ]
15 years ago
JSP
Hi david,

i need only that much, all the four driver with explanation and the statments with clear explanation, i would be happy if you could tell me the link where i can get the explanation of these.

The explanation given in the previous link are not enough for me.

Please help me out
Thanking in advance
Hi all ranchers,

I need the material in which jdbc drivers (all the 4 types) and the statments are specified clearly.
could you tell me the link on which i can get the soft copy of that....

i need it very urgently..

Please help me out in this..

Thanking in advance...
Hi all,

can anybody tell me,

1.Why wait() notify() and notifyAll() are declared in the Object class instead of Thread class.

Thanking in advance....
Hi all,

can anybody help me out in this, my question is..

Can we use "HashMap" for locking in synchronized block and invoke methods on the same HashMap instance.

Thanking in advance
HI all,
How will a controller servlet will deside to which servlet or jsp component it has to forward the request at run time in mvc archi. if possible give me some coding for that

&

How do we handle the validation of request.

thanking in advance....
15 years ago
Hi all

please clarify my following boubts

Why hashcode is protected in object class?
why don't we have multiple inheritence?
What are the differences between HashMap & HashTable?

Thanking in advance.
Hi all,

I have some doubts about binding infact i am not getting clear picture of it.

1st ques
Can anybody give the clear idea of binding which (methods & fields) takes place at what time?

2nd Ques
Methods are binded at runtime, how they can be resolved at compile time which metnod has to

Thanking in advance.