Class A is Loading Class B Using Reflection

Hi,
I am facing the below problem.
Class A is loading Class B By Using Reflection package.
Class B is one jar (Eg: B.jar) ,Class A is one Jar (Eg: A.jar)
Class B internally using Class A variables and methods. When ever loading the class B from Class A it is
giving the exception is NoClassDefFoundError of Class A.
We are loading the Class B from Class A only, Why Class A reference is not available in Class B
Please help me on this
Thanks
T. Shankar Reddy

ShankarReddyT wrote:
Hi,
I am facing the below problem.
Class A is loading Class B By Using Reflection package.
Class B is one jar (Eg: B.jar) ,Class A is one Jar (Eg: A.jar)
Class B internally using Class A variables and methods. Myself I don't consider circular references a great idea.
Presumably you are not using reflection solely because it is circular.
When ever loading the class B from Class A it is
giving the exception is NoClassDefFoundError of Class A.
We are loading the Class B from Class A only, Why Class A reference is not available in Class B
Several possibilities.
1. Because you are attempting to load B in the static block of A. In that case the class A has not yet been loaded. And the VM will not try to reload A once it is in the process of loading. Which is pretty smart of the VM.
2. Because there is a custom class loader involved.
You might want to post the stack trace of the exception.

Similar Messages

  • Javax.faces.FacesException: Missing Class: Can't load class

    Hi,
    I want to implement in process wizard using JSF. I have created a button panel which have "Back", "Next","Finish","Cancel" and "Help" button and also have create a process indicator which indicate the current page by highlighting.
    Both Buttonbar class and ProcessBar are interacting with a Model.
    I have declared a static variable to indicate the current page no, default value is zero. This static variable is getting updated by "Back" (-1) and "Next"(+1) button action.
    For the first time wizardPage is loaded fine but in pressijng of "Next" button, it throws me
    javax.faces.FacesException: Missing Class: Can't load class
    'com.cassiopae.framework.demo.faces.uicomponent.WizardProcessTrain'
    But WizardProcessTrain class and WizardButtonBar class are loading properly when screen is loading.
    Any one know the reason, please help me out.
    Thanks in advance.

    I solve this problem by doing a remote deployment via creator2 remote deployment server.. first you must take care of JNDI stuff..
    I hope this help.. give me feedback

  • Can't load class problems migrating from PE 8.1 to PE 8.2

    Hi. I'm in the process of migrating an application from an old server that runs PE 8.1_02 to a new server that runs PE 8.2.
    The application is coded and built in Creator 2.0; the resulting .war file deploys alright into both servers, and operates correctly on the 8.1 server, but throws various "Can't load class" errors on my 8.2 server. One of them looks like this:
    exception
    javax.servlet.ServletException: Missing Class: Can't load class 'com.talentmap.talentexitadmintool.fields.TextBoxField'.
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
         sun.reflect.GeneratedMethodAccessor157.invoke(Unknown Source)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:585)
         org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
         java.security.AccessController.doPrivileged(Native Method)
         javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
         org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
         java.security.AccessController.doPrivileged(Native Method)
         com.sun.rave.web.ui.util.UploadFilter.doFilter(UploadFilter.java:194)
         java.security.AccessController.doPrivileged(Native Method)
         com.talentmap.talentexitadmintool.utils.security.SecurityCheckFilter.doFilter(SecurityCheckFilter.java:91)
    root cause
    javax.faces.FacesException: Missing Class: Can't load class 'com.talentmap.talentexitadmintool.fields.TextBoxField'.
         com.sun.faces.util.TreeStructure.createComponent(TreeStructure.java:130)
         com.sun.faces.application.StateManagerImpl.restoreComponentTreeStructure(StateManagerImpl.java:464)
         com.sun.faces.application.StateManagerImpl.restoreComponentTreeStructure(StateManagerImpl.java:466)
         com.sun.faces.application.StateManagerImpl.restoreComponentTreeStructure(StateManagerImpl.java:466)
         com.sun.faces.application.StateManagerImpl.restoreComponentTreeStructure(StateManagerImpl.java:466)
         com.sun.faces.application.StateManagerImpl.restoreComponentTreeStructure(StateManagerImpl.java:466)
         com.sun.faces.application.StateManagerImpl.restoreComponentTreeStructure(StateManagerImpl.java:466)
         com.sun.faces.application.StateManagerImpl.restoreComponentTreeStructure(StateManagerImpl.java:466)
         com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:314)
         com.sun.faces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:230)
         com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:337)
         com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:157)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:225)
         com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:193)
         sun.reflect.GeneratedMethodAccessor157.invoke(Unknown Source)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:585)
         org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
         java.security.AccessController.doPrivileged(Native Method)
         javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
         org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
         java.security.AccessController.doPrivileged(Native Method)
         com.sun.rave.web.ui.util.UploadFilter.doFilter(UploadFilter.java:194)
         java.security.AccessController.doPrivileged(Native Method)
         com.talentmap.talentexitadmintool.utils.security.SecurityCheckFilter.doFilter(SecurityCheckFilter.java:91)
    The class that is "missing" (TextBoxField) is very definitely there in the usual place under WEB-INF/classes. I can't figure out why it can't be loaded. The weird part is that a lot of the code still works, but these errrors have broken many of the major functions of our software.
    On a hunch I realized that perhaps Creator 2.0 was using some 8.1 specific libraries to build, so I replaced the following libraries with versions found in my appserv tree:
    activation.jar
    appserv-jstl.jar
    appserv-tags.jar
    commons-logging.jar
    j2ee.jar
    jax-qname.jar
    jaxr-api.jar
    jaxr-impl.jar
    jaxrpc-api.jar
    jaxrpc-impl.jar
    jsf-api.jar
    jsf-impl.jar
    mail.jar
    saaj-api.jar
    saaj-impl.jar
    Rebuilding with those copied libraries made no difference.
    Anyone know what could be causing this? Is there a workaround or fix? Do I need to update Creator with something? Should I revert to 8.1? Should I try moving to 9.0?

    I solve this problem by doing a remote deployment via creator2 remote deployment server.. first you must take care of JNDI stuff..
    I hope this help.. give me feedback

  • How can i get all java class names from a package using reflection?

    hi,
    can i get all classes name from a package using reflection or any other way?
    If possible plz give the code with example.

    You can't, because the package doesn't have to be on the local machine. It could be ANYWHERE.
    For example, via a URLClassLoader (ie from the internet) I could load a class called:
    com.paperstack.NobodyExpectsTheSpanishInquisitionI haven't written it yet. But I might tomorrow. How are you going to determine if that class is in the package?
    This subject comes up a lot. If you want to do something a bit like what you're asking for (but not quite) there are plenty of threads on the subject. Use google and/or the forum search facility to find them.
    But the answer to your question, as you asked it, is "you can't do that".

  • Using TextSnapshot class on a loaded SWF on an iPad

    Hello, I am creating an iPad app. I am loading SWF files using a Loader object, then placing them in a movieclip and setting a SWFLoaders source property to this clip. Before I add the clip to the SWFLoader control I am using the TextSnapshot class on it, to retrieve an array with the getTextRunInfo method.
    All this works fine when I test it on my desktop machine. However, on the iPad it causes the app to crash when a control using this clip is added to the stage. Can you still use TextSnapshot with an iPad, is there a workaround for this? Thanks for your help.

    We are a university. most of our books are SWF files. We have been using iPad/FlexBuilder 4.5 to successfully view the contents of these books.
    All navigation (i.e gotoandstop(page), etc work fine. Gestures for pageforward/pageback, zoom, pan work fine also.
    Not sure I understand your comment.
    However, there IS a specific problem with text snapshot. Below is a short code piece used to highlight text on a page.
    If you remove the failing line everything works fine.
    If you "debug" the iPad device everything works fine when you execute the code on the iPad
    if you create a release build, when the application starts and the "findtext" line is executed the "app" freezes. No error message. The try/catch does not seem to catch any error.
    This is something we really need for our app. If this is a bug how should we report it.
    Thanks for your help.
      public function highlightText(txt:String):void {
       var start_pos:int = 0;
       try {
        if (txt == null || txt.length == 0) { return; }
        infoMessage("highlightText: " + txt);
        allText = _libMC.textSnapshot;      
        allTexts.push(allText);  // no reason for this but must do to make work 
        start_pos = allText.findText(start_pos, txt, false);     <<<<<< Failing line ====================================
        infoMessage("start_pos: " + start_pos);
       catch (err:Error) {
        infoMessage("error: " + err.message);   
       finally {
        infoMessage("finally");

  • Using Reflection on classes outside the classpath

    Hi all,
    Im writing a tool that takes a directory containing class files (from other internal projects) and returns information such as the Class name, package, parent, constructors and public methods. These projects will not be on the classpath and will also use jars that are not on the classpath.
    I decided that ClassLoaders were the way to go. So I created a SimpleClassLoader class that takes a file, reads it in as an array of bytes and calls defineClass:
    public class SimpleClassLoader extends ClassLoader
         public SimpleClassLoader()
         public synchronized Class loadClass(String name, boolean resolveIt) throws ClassNotFoundException
              System.out.println("1) loading class:   " + name);
              return super.loadClass(name, resolveIt);
         public synchronized Class loadClass(File classFile) throws ClassNotFoundException
              System.out.println("2) Loading class: " + classFile.getName());
              try
                   byte[] data = getClassData(classFile);
                   return defineClass(name, data, 0, data.length);
              catch (IOException e)
                   throw new ClassNotFoundException();
         byte[] getClassData(File classFile) throws IOException
              byte result[];
              try
                   FileInputStream in = new FileInputStream(classFile);
                   result = new byte[in.available()];
                   in.read(result);
                   in.close();
                   return result;
              catch (IOException e)
                   throw new IOException();
    public class ClassParser
         public Class parse (File classFile)
              SimpleClassLoader loader = new SimpleClassLoader();
              Class reflectClass = null;
              try {
                   return loader.loadClass(classFile);
              } catch (ClassNotFoundException cnfe) {
                   System.out.println("Error loading class: " + classFile.getName() + "\n" + cnfe);
                   return null;
    }This worked for simple classes but when the superclass was in a jar or another file in the directory that hadnt already been loaded a ClassNotFoundException was thrown. So I then decided to try using URLClassLoader and loading in the jars and the entire source directory before calling findClass on it.
    class MyURLClassLoader extends URLClassLoader
         public MyURLClassLoader(URL[] urls)
              super(urls);
         public Class findClass(String classname) throws ClassNotFoundException
              return super.findClass(classname);
    public class ClassParser {
         private URL[] _classpath;
         private String _root;
         public ClassParser(File[] files, String root) {
              _root = root;
              _classpath = new URL[files.length];
              for (int i = 0; i < files.length; i++) {
                   try {
                        URL url = new URL("jar", "", files.toURL() + "!/");
                        this._classpath[i] = url;
                   } catch (MalformedURLException e) {
                        e.printStackTrace();
         public Class parse (File classFile)      {
              MyURLClassLoader urlLoader = new MyURLClassLoader(_classpath);
              Class reflectClass = null;
              String classname = "";
              // Try to load a Class instance from the file
              try {
                   classname = getClassName(classFile);
                   return urlLoader.findClass(classname);
              } catch (ClassNotFoundException cnfe) {
                   System.out.println("Error loading class: " + classname + "\n" + cnfe);
                   return null;
         String getClassName (File file) throws ClassNotFoundException {
              if (file.getAbsolutePath().startsWith(_root)) {
                   String packagePath = file.getAbsolutePath().substring(_root.length(), file.getAbsolutePath().lastIndexOf("."));
                   packagePath = packagePath.replace(File.separatorChar, '.');
                   return packagePath;
              } else {
                   throw new ClassNotFoundException();
         public static void main(String args[]) {
    File [] files = new File [] {
    new File("C:\\Projects\\app\lib\\jacob-1.6.jar"),
    new File("C:\\Projects\\app\\lib\\xalan.jar"),
    new File("C:\\Projects\\app\\lib\\xmlunit1.0.jar"),
    new File("C:\\Projects\\app\\classes\\com\\foo\\bar\\swing\\")
    parser = new ClassParser(files, "C:\\Projects\\app\\classes\\");
    This seems to work when I call findClass on a class thats in one of the jars but not on a class in the classes directory.
    Does anyone have any ideas what im doing wrong or whether im barking up the wrong tree completely??
    Thanks,
    Conor

    The URLs that you supply to an URLClassLoader each define the location of the default package for that portion of the classpath for the ClassLoader.
    This is the problem line
    new File("C:\\Projects\\app\\classes\\com\\foo\\bar\\swing\\")I suspect that it should be..
    new File( "C:\\Projects\\app\classes" )as this is the location of that default package.

  • Using Reflection can we find out details of inner classes in a class

    Hello All,
    Thanx in advance.
    I intend to figure out the name of the inner class and methods declared inside it. How can this be done using reflection API's.
    I need the above information to make an automated java doc creation tool for the project I am working in.
    Thanx again...
    VIkas

    Thanx silkm,
    Actually suggestion # 1 I have already tried. I used
    getClasses() method which returned me a Class[] of
    length = 0. i dunno Why?Because you are not using the reflection API correctly. If you read the javadocs you would know that it is structured so that all getXXX() methods return all XXX things that are public and are either declared by the target class or possibly inherited from superclasses.
    As contrasted to that, getDeclaredXXX() methods can return all XXX things (including private) but only declared by the target class (not inherited).
    You got an empty result back in your case most likely because all your nested/inner classes were non-public. Use getDeclaredClasses() instead.
    As to suggestion # 2, the exercise I am doing is a
    step before using the java doc tool. One has to insert
    a javadoc comment before the method begins in order to
    create a java doc. So thats it.This is independent of the reflection API but you might consider using the doclet API for this.

  • How to access private method of an inner class using reflection.

    Can somebody tell me that how can i access private method of an inner class using reflection.
    There is a scenario like
    class A
    class B
    private fun() {
    now i want to use method fun() of an inner class inside third class i.e "class c".
    Can i use reflection in someway to access this private method fun() in class c.

    I suppose for unit tests, there could be cases when you need to access private methods that you don't want your real code to access.
    Reflection with inner classes can be tricky. I tried getting the constructor, but it kept failing until I saw that even though the default constructor is a no-arg, for inner classes that aren't static, apparently the constructor for the inner class itself takes an instance of the outer class as a param.
    So here's what it looks like:
            //list of inner classes, if any
            Class[] classlist = A.class.getDeclaredClasses();
            A outer = new A();
            try {
                for (int i =0; i < classlist.length; i++){
                    if (! classlist.getSimpleName().equals("B")){
    //skip other classes
    continue;
    //this is what I mention above.
    Constructor constr = classlist[i].getDeclaredConstructor(A.class);
    constr.setAccessible(true);
    Object inner = constr.newInstance(outer);
    Method meth = classlist[i].getDeclaredMethod("testMethod");
    meth.setAccessible(true);
    //the actual method call
    meth.invoke(inner);
    } catch (Exception e) {
    throw new RuntimeException(e);
    Good luck, and if you find yourself relying on this too much, it might mean a code redesign.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to use reflection to get base classes protected field

    I have one base Base classes which have protected fields and public get method to get the field.
    class Base
    protected int proField;
    public int getProField(){return proField;}
    Class Derive extends base class Base
    class Derive extends Base implements OtherInterface
    public void funtion(){};
    Now I have an instance of Derive, how can I use reflection to get the protected field inherited from Base. It seems Java Reflection only give runtime accessibility to public field and decleared field, protected-inherited field is excluded.
    Thanks
    Lei

    as the last poster said, traverse up the class hierarchy.
    ex:
    private void doSumfinToField(String fieldName throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException {
    Class clazz = getClass();
    Field field = findFieldInClass(clazz, fieldName);
    //field.doSumfin;
    private Field findFieldInClass(Class clazz, String fieldName) throws NoSuchFieldException {
    try { // to find the field in this class    
    return clazz.getDeclaredField(fieldName);
    } catch (NoSuchFieldException e) {
    // if we don't have a superclass, continue
    if (clazz.getSuperclass().equals(Object.class)) {
    throw e;
    // check in the superclass
    return findFieldInClass(clazz.getSuperclass(), fieldName);
    }

  • Does resteasy API have class loader issues when using via OSGi

    Does resteasy API have class loader issues when using via OSGi

    Hi Scott,
    THis isnt an answer to ur Question, but could u tell me which jar files are needed for the packages:
    com.sap.portal.pcm.system.ISystems
    com.sap.portal.pcm.system.ISystem
    and under which path I coul dfind them.
    Thnx
    Regards
    Meesum.

  • Loading .class files for reflection

    I'm trying to write a program that lets the user select thier .class files to gather
    information about those classes with reflection.
    I can't figure out how to get ClassLoader to load .class files outside the program
    directory.

    I've tried both these options, and spent some time on it too,
    but failed. If can't find a class that can load clases form a URL
    how can I write my own ClassLoader that does it.
    The ClassLoaders all seem to assume that they already know where
    to look for the class files. Perhaps if I could tell them where to look,
    but I don't see how.

  • Using reflection on passed classes

    Hello,
    I have been trying to write a common function to return the variables and values of a class passed into it. The function uses reflection to iterate through the Fields and returns a string of the variables and values. Is it anything to do with scope, as the same code works when I paste the method into the class I am looking at (See below)?
    I have pasted the code fragments below.
    Thanks
    stuart
    * Returns XML fragment of name value pairs of member/value
    * @param iClass the class under inspection
    * @return XML fragment of name value pairs of member/value
    public static String inspectMemberVariables(Class iClass)
    String oStr = new String();
    try
    Class c = iClass.getClass();
    Field[] f = c.getFields();
    System.out.println(f.length);
    for (int i=0; i < f.length; i++)
    // identify the field
    Field fld = c.getField( f.getName());
    //get the field name and grab the field value from the class
    oStr += f.getName()
    + "=\""
    + fld.get(c)
    + "\" ";
    } // for (int i=0; i < f.length; i++)
    oStr = "classname=\""
    + c.getName()
    + "\" "
    + oStr;
    } //end of try
    catch (NoSuchFieldException e)
    System.out.println(e);
    catch (SecurityException e)
    System.out.println(e);
    catch (IllegalAccessException e)
    System.out.println(e);
    } //end of catch
    return oStr;
    } // end ofinspectMemberVariables
    Where the code is called:
    public class ReflectionTest extends PPSpposEBCore
    public String strg;
    public ReflectionTest()
    String str2 = new String ();
    str2 = ClassProperties.inspectMemberVariables(this.getClass());
    System.out.println(str2);
    public static void main(String[] args)
    String str = new String ();
    try
    ReflectionTest rt = new ReflectionTest();
    // set dummy values to test
    rt.mPossessionId = 12;
    rt.mBusinessPossRef = "look it works";
    rt.mCreatedTs = new Date();
    //ClassProperties cp = new ClassProperties();
    //str2 = ClassProperties.inspectMemberVariables(rt.getClass());
    Class c = rt.getClass() ;
    Field[] f = c.getFields();
    System.out.println(f.length);
    for (int i=0; i < f.length; i++)
    // identify the field
    Field fld = c.getField( f.getName());
    //grab the field name and field value from the class
    str += f.getName()
    + "=\""
    + fld.get(rt)
    + "\" ";
    } // for (int i=0; i < f.length; i++)
    str = "classname=\""
    + c.getName()
    + "\" "
    + str;
    System.out.println(str);
    } //try
    catch (NoSuchFieldException e)
    System.out.println(e);
    catch (SecurityException e)
    System.out.println(e);
    catch (IllegalAccessException e)
    System.out.println(e);

    sorry it doesn't work, interface cannot have method body, i didn't know it. You couldn't access to private and protected datas with an exterior method. You can make a package with classes you want to inspect and a class who inspect. The classes of a package can access to protected datas.

  • Need Help Loading Sqlbase Driver Using Class.forName(...

    I'm having trouble connecting to a Sqlbase database on my PC. The problem seems to be with loading the driver with the "Class.forName" method. My source code (listed below) is in the "C:\My Documents\java" folder. I installed the Sqlbase driver in "C:\com\centurasoft\java\sqlbase" folder. The driver installation modified my autoexec.bat file to include the line "SET CLASSPATH=C:\com\centurasoft\java\sqlbase".
    The epdmo database is in a folder on my D:\ drive.
    It seems to find the SqlbaseDriver.class file, but for some reason it can't load it. I would greatly appreciate any suggestions as to how I can fix this.
    With the line -- Class.forName("centura.java.sqlbase.SqlbaseDriver");
    The SqlbaseEx.java program will compile, but I get the following error
    when I try to run it:
    Exception in thread "main" java.lang.NoClassDefFoundError: SqlbaseDriver (wrong name: com/centurasoft/java/sqlbase/SqlbaseDriver)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    ... [several more lines like these]
    at SqlbaseEx.main(SqlbaseEx.java:25)
    With the line -- DriverManager.registerDriver(new SqlbaseDriver());
    The SqlbaseEx.java program will NOT compile. I get the following error:
    SqlbaseEx.java:21: cannot access SqlbaseDriver
    bad class file: C:\com\centurasoft\java\sqlbase\SqlbaseDriver.class
    class file contains wrong class: com.centurasoft.java.sqlbase.SqlbaseDriver
    Please remove or make sure it appears in the correct subdirectory of the classpath.
    Also, does the line -- String url = "jdbc:sqlbase:epdmo";
    look OK? I've seen numerous examples and they all have some values separated by slashes //. Am I
    missing something here that will bite me when I get past this driver loading error?
    import java.sql.*;
    // Create the ...
    public class SqlbaseEx {
    public static void main(String args[]) {
    String url = "jdbc:sqlbase:epdmo";
    Connection con;
    String createString;
    createString = "create table COFFEES " +
    "(COF_NAME varchar(32), " +
    "SUP_ID int, " +
    "PRICE float, " +
    "SALES int, " +
    "TOTAL int)";
    Statement stmt;
    try {
    Class.forName("centura.java.sqlbase.SqlbaseDriver");
    // DriverManager.registerDriver(new SqlbaseDriver());
    } catch(java.lang.ClassNotFoundException e) {
    System.err.print("ClassNotFoundException: ");
    System.err.println(e.getMessage());
    try {
    con = DriverManager.getConnection(url, "SYSADM", "SYSADM");
    stmt = con.createStatement();
    stmt.executeUpdate(createString);
    stmt.close();
    con.close();
    } catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());

    Thanks for the reply.
    Upon further testing, I think my original post was slightly incorrect: if I use either of the following lines --
    Class.forName("com.centurasoft.java.sqlbase.SqlbaseDriver");
    or
    Class.forName("centura.java.sqlbase.SqlbaseDriver");
    I get the following error at runtime:
    ClassNotFoundException: com.centurasoft.java.sqlbase.SqlbaseDriver
    or
    ClassNotFoundException: centura.java.sqlbase.SqlbaseDriver
    It is when I use the line -- Class.forName("SqlbaseDriver");
    that I get the long error message in my original post.
    I don't understand why it can't find/load the driver. I feel like I've covered all the bases -- I've tried numerous variations of the driver name in the Class.forName method, my classpath variable seems to be set correctly. Does it matter what folder I compile my program in? Right now, I've just been compiling it in the same folder as the driver file -- c:\com\centurasoft\java\sqlbase.

  • Using JARs without loading classes

    I have a situation where several JARs have had their classes loaded into a schema but now I have other JARs of which cause version collision issues if implemented inside the same schema. Is there a way to actually call a JAR and execute its classes within PL/SQL without actually loading all of it's classes into the schema? In other words our current setup which has all of the needed JAR classes loaded into the schema not have to change, but simply load the new JARs in as JARs and not Java classes, and call their classes without them being loaded into the schema (avoiding the version issues we are experiencing)?
    Thanks.

    871357 wrote:
    I have a situation where several JARs have had their classes loaded into a schema but now I have other JARs of which cause version collision issues if implemented inside the same schema. Is there a way to actually call a JAR and execute its classes within PL/SQL without actually loading all of it's classes into the schema? In other words our current setup which has all of the needed JAR classes loaded into the schema not have to change, but simply load the new JARs in as JARs and not Java classes, and call their classes without them being loaded into the schema (avoiding the version issues we are experiencing)?
    Presumably you are referring to putting java into Oracle itself via loadjava.
    The traditional solution for this is to use a class loader. That won't work for this case.
    However there is one obvious solution. I am rather certain that cross schema calls are possible in oracle. So load them into difference schemas.

  • Loading classes with reflection

    hello,
    I have a package named CSP with an Interface A.
    this package(distributed as jar) may change during time, so I would like that my gui updates its components list, which consists in all CSP's classes implementing interface A.
    How can I determine what are all classes, inside CSP, implementing A?
    Thanks.
    Paolo

    Since I have done that a couple years ago :-)
    * Finds all classes from any given set of locations that implement any given interface.
    * @author Jean-Francois Briere
    import java.io.*;
    import java.util.*;
    import java.util.zip.*;
    import java.net.*;
    import java.lang.reflect.*;
    public class InterfaceFinder
        public InterfaceFinder()
         * Finds all classes from any given set of locations that implement any given interface.
         * @param interfaceName Name of interface to search for classes that implement it.
         * @param classPath String of folder and/or archive name, separated by the classpath separator,
         *                  that represents the locations to search the classes.
         * @return An array of 0 to more InterfaceFinder.Result objects,
         *         one per location that has implemented classes.
        public InterfaceFinder.Result[] findImplementingClasses(String interfaceName, String classPath)
            return findImplementingClasses(interfaceName, readClassPath(classPath));
         * Finds all classes from any given set of locations that implement any given interface.
         * @param interfaceName Name of interface to search for classes that implement it.
         * @param fileArr Array of folder and/or archive File objects that represents the locations to search the classes.
         * @return An array of 0 to more InterfaceFinder.Result objects,
         *         one per location that has implemented classes.
        public InterfaceFinder.Result[] findImplementingClasses(String interfaceName, File[] fileArr)
            URL[] urlArr = convertToUrls(fileArr);
            URLClassLoader ucl = new URLClassLoader(urlArr);
            ArrayList resList = new ArrayList();
            for (int i = 0; i < urlArr.length; i++)
                File file = new File(urlArr.getPath());
    String ext = file.getName().toLowerCase();
    ArrayList classList = new ArrayList();
    if (ext.endsWith(".jar"))
    findInZip(file, ucl, interfaceName, classList);
    else if (ext.endsWith(".zip"))
    findInZip(file, ucl, interfaceName, classList);
    else // dir
    findInDir(file, ucl, interfaceName, classList);
    if (classList.size() > 0)
    InterfaceFinder.Result result = new InterfaceFinder.Result();
    Class[] classArr = new Class[classList.size()];
    classList.toArray(classArr);
    result.interfaceName = interfaceName;
    result.location = file;
    result.implementingClasses = classArr;
    resList.add(result);
    InterfaceFinder.Result[] resArr = new InterfaceFinder.Result[resList.size()];
    resList.toArray(resArr);
    return resArr;
    private File[] readClassPath(String classPath)
    StringTokenizer strTok = new StringTokenizer(classPath, File.pathSeparator);
    List fileList = new ArrayList();
    while (strTok.hasMoreTokens())
    fileList.add(new File(strTok.nextToken()));
    File[] fileArr = new File[fileList.size()];
    fileList.toArray(fileArr);
    return fileArr;
    * This converts to URL objects only File objects that represents existing files
    * which are directories, jar or zip files. So any other File objects are skipped.
    private URL[] convertToUrls(File[] fileArr)
    List urlList = new ArrayList();
    for (int i = 0; i < fileArr.length; i++)
    try
    if (fileArr[i].isDirectory())
    urlList.add(fileArr[i].toURL());
    else if (fileArr[i].exists())
    String ext = fileArr[i].getName().toLowerCase();
    if (ext.endsWith(".jar"))
    urlList.add(fileArr[i].toURL());
    else if (ext.endsWith(".zip"))
    urlList.add(fileArr[i].toURL());
    catch (MalformedURLException e)
    URL[] urlArr = new URL[urlList.size()];
    urlList.toArray(urlArr);
    return urlArr;
    private void findInDir(File dir, URLClassLoader ucl, String interfaceName, ArrayList classList)
    FileFilter filter = new FileFilter()
    public boolean accept(File pathname)
    if (pathname.isDirectory())
    return true;
    else if (pathname.getName().toLowerCase().endsWith(".class"))
    return true;
    return false;
    findInDir0(dir, dir, ucl, interfaceName, filter, classList);
    private void findInDir0(File root, File dir, URLClassLoader ucl, String interfaceName, FileFilter filter, ArrayList classList)
    File[] fileArr = dir.listFiles(filter);
    if (fileArr == null)
    return;
    for (int i = 0; i < fileArr.length; i++)
    if (fileArr[i].isDirectory())
    findInDir0(root, fileArr[i], ucl, interfaceName, filter, classList);
    else // .class files
    String fileName = fileArr[i].getPath().substring(root.getPath().length() + 1);
    String className = convertFileToClassName(fileName);
    verifyInterface(className, ucl, interfaceName, classList);
    private void findInZip(File file, URLClassLoader ucl, String interfaceName, ArrayList classList)
    ZipFile zipFile = null;
    try
    zipFile = new ZipFile(file);
    Enumeration enum = zipFile.entries();
    while (enum.hasMoreElements())
    ZipEntry entry = (ZipEntry)enum.nextElement();
    String entryName = entry.getName();
    if (entryName.endsWith(".class"))
    String className = convertFileToClassName(entryName);
    verifyInterface(className, ucl, interfaceName, classList);
    catch (IOException e)
    finally // be sure to close the archive
    if (zipFile != null)
    try { zipFile.close(); }
    catch (IOException e) {}
    private String convertFileToClassName(String fileName)
    String className = fileName.substring(0, fileName.length() - 6); // remove .class
    className = className.replace('/', '.');
    className = className.replace('\\', '.');
    return className;
    private void verifyInterface(String className, URLClassLoader ucl, String interfaceName, ArrayList classList)
    try
    Class cls = Class.forName(className, false, ucl);
    if (cls.isInterface())
    return;
    Class cls0 = cls;
    while (cls0 != null)
    if (verifyInterface0(cls0, interfaceName))
    classList.add(cls);
    break;
    cls0 = cls0.getSuperclass(); // search for possible parent class
    catch (Exception e)
    private boolean verifyInterface0(Class cls0, String interfaceName)
    Class[] interfaceArr = cls0.getInterfaces();
    for (int i = 0; i < interfaceArr.length; i++)
    if (interfaceArr[i].getName().equals(interfaceName))
    return true;
    else
    return verifyInterface0(interfaceArr[i], interfaceName); // search for possible parent interfaces
    return false;
    * Holder of the location and its classes found to implement the named interface.
    public class Result
    public String interfaceName;
    public File location;
    public Class[] implementingClasses;
    This is very easy to use.
    For instance if you want to look for the a.b.c.TestIf interface on different folder/jar locations:
    InterfaceFinder.Result[] resultArray = new InterfaceFinder().findImplementingClasses("a.b.c.TestIf", "someFolder;someJarFile;someOtherJarFile");

Maybe you are looking for

  • Web template changes are not saved.

    Hello Experts, I making a small change to an existing Web Template namely changing the tab page 1 to tab page 2 and  vice versa. I could see the message Changes are saved but at the end web template is same like as it was. Any idea why changes are no

  • Partition Hard Disk without reformating! Please!

    Hi i just bought a macbook pro and I target firewired my macbook to old g4, got all my apps. But all my video and audio is on a 2nd drive and I need to partion my new macbook to copy over those files but I dont want reformat my macbooks HD. I have te

  • Fax the output type and convert to PDF and then to save in UNIX Directory

    Hi,   I wan to Fax the my sales order acknowldement and at the same time I want to convert that output into PDF and save in the UNIX Directory . I also need the code for faxing the sales order acknowledgement. Thanks in Advance Moderator message: ple

  • How to have profile thumbnails image appear in a SharePoint 2013 list?

    Hello, I am not using MySites, but have a SharePoint 2013 list with profiles in them.  They were imported from Active Directory, where I do have thumbnail images for each profile.  I am using SharePoint 2013.  How would I get these images from AD int

  • HTML (XI) adapter port

    Hi, I have configured scenario with sender HTML adapter and RFC receiver adapter. When I run the test tool in ID, everything seems to be fine. My problem is, how (or where) I can find out the port value, on which third-party application should send a