views:

54

answers:

1

hi, i am developing a plug in which deals with hibernate project.I get some classes which contain Session and Session factory .Then i want to instantiate an object of these classes using reflections which i am not able to do it even after including the hibernate jars in the classpath of my plug in.What is the problem?Help

Here is the code

String hibernate_jars = "C:\\Documents and Settings\\Administrator\\My Documents\\hibernate_jars\\lib.folder\\lib";

URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader();

Class sysclass = URLClassLoader.class ;

Method method = sysclass.getDeclaredMethod("addURL",URL.class);

method.invoke(sysloader, new Object[] { new File(hibernate_jars).toURI().toURL() });

clss = Class.forName("test.Example", false, ClassLoader);

Object myobj =  clss.newInstance();

unable to create the instance and its not giving any exceptions either.

A: 

You may need to call method.setAccessible(true); before you invoke it

Maurice Perry