Package org.datanucleus.exceptions

Examples of org.datanucleus.exceptions.ClassNotResolvedException


        {
            return registry.loadClass(pluginId, className);
        }
        catch(ClassNotFoundException ex)
        {
            throw new ClassNotResolvedException(ex.getMessage(),ex);
        }
    }
View Full Code Here


    {
        if (name == null)
        {
            // Avoid the NPE and just throw a "not resolved"
            String msg = LOCALISER.msg("001000", name);
            throw new ClassNotResolvedException(msg);
        }
        if (name.equals(ClassNameConstants.BYTE))
        {
            return byte.class;
        }
        else if (name.equals(ClassNameConstants.CHAR))
        {
            return char.class;
        }
        else if (name.equals(ClassNameConstants.INT))
        {
            return int.class;
        }
        else if (name.equals(ClassNameConstants.LONG))
        {
            return long.class;
        }
        else if (name.equals(ClassNameConstants.DOUBLE))
        {
            return double.class;
        }
        else if (name.equals(ClassNameConstants.FLOAT))
        {
            return float.class;
        }
        else if (name.equals(ClassNameConstants.SHORT))
        {
            return short.class;
        }
        else if (name.equals(ClassNameConstants.BOOLEAN))
        {
            return boolean.class;
        }
        else if (name.equals(ClassNameConstants.JAVA_LANG_STRING))
        {
            return String.class;
        }

        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        String cacheKey = newCacheKey(name, primary, contextClassLoader);

        //lookup in loaded and unloaded classes cache
        Class cls = loadedClasses.get(cacheKey);
        if (cls != null)
        {
            return cls;
        }

        cls = unloadedClasses.get(cacheKey);
        if (cls != null)
        {
            return cls;
        }

        if (cls == null)
        {
            // Try the supplied loader first
            cls = classOrNull(name, primary);
        }
        if (cls == null && this.primary.get() != null)
        {
            // Try the primary for this current thread
            cls = classOrNull(name, (ClassLoader) this.primary.get());
        }
        if (cls == null)
        {
            // Try the loader for the current thread
            cls = classOrNull(name, contextClassLoader);
        }
        if (cls == null)
        {
            // Try the loader for the PM context
            cls = classOrNull(name, pmContextLoader);
        }
        if (cls == null && runtimeLoader != null)
        {
            // Try the registered loader for runtime created classes
            cls = classOrNull(name, runtimeLoader);
        }
        if (cls == null && userRegisteredLoader != null)
        {
            // Try the user registered loader for classes
            cls = classOrNull(name, userRegisteredLoader);
        }

        if (cls == null)
        {
            if (NucleusLogger.CLASSLOADING.isDebugEnabled())
            {
                // Log the class loading failure in case its of use in debugging
                StackTraceElement[] traceElements = new Exception().getStackTrace();
                StackTraceElement element = null;
                int i = 0;
                boolean processingClassLoaderResolverCalls = false;
                while (element == null)
                {
                    if (processingClassLoaderResolverCalls &&
                        traceElements[i].getClassName().indexOf(this.getClass().getName()) < 0)
                    {
                        // Next class in the stack trace after the JDOClassLoaderResolver calls
                        element = traceElements[i];
                    }
                    else if (traceElements[i].getClassName().startsWith("org.datanucleus"))
                    {
                        processingClassLoaderResolverCalls = true;
                    }
                    i++;
                }
                // Don't give stack trace, just the method that asked for class-resolving
                NucleusLogger.CLASSLOADING.debug(LOCALISER.msg("001004", name,
                    element.getClassName() + "." + element.getMethodName(), "" + element.getLineNumber()));
            }
            String msg = LOCALISER.msg("001000", name);
            throw new ClassNotResolvedException(msg);
        }

        //put in unloaded cache, since it was not loaded here
        unloadedClasses.put(cacheKey, cls);
View Full Code Here

    {
        if (name == null)
        {
            // Avoid the NPE and just throw a "not resolved"
            String msg = LOCALISER.msg("001000", name);
            throw new ClassNotResolvedException(msg);
        }
        if (name.equals(ClassNameConstants.BYTE))
        {
            return byte.class;
        }
        else if (name.equals(ClassNameConstants.CHAR))
        {
            return char.class;
        }
        else if (name.equals(ClassNameConstants.INT))
        {
            return int.class;
        }
        else if (name.equals(ClassNameConstants.LONG))
        {
            return long.class;
        }
        else if (name.equals(ClassNameConstants.DOUBLE))
        {
            return double.class;
        }
        else if (name.equals(ClassNameConstants.FLOAT))
        {
            return float.class;
        }
        else if (name.equals(ClassNameConstants.SHORT))
        {
            return short.class;
        }
        else if (name.equals(ClassNameConstants.BOOLEAN))
        {
            return boolean.class;
        }
        else if (name.equals(ClassNameConstants.JAVA_LANG_STRING))
        {
            return String.class;
        }

        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        String cacheKey = newCacheKey(name, primary, contextClassLoader);
        //only lookup in loaded classes cache
        Class cls = loadedClasses.get(cacheKey);

        if (cls != null)
        {
            return cls;
        }

        if (cls == null)
        {
            // Try the supplied loader first
            cls = ClassOrNullWithInitialize(name, primary);
        }
        if (cls == null && this.primary.get() != null)
        {
            // Try the primary for this current thread
            cls = ClassOrNullWithInitialize(name, (ClassLoader) this.primary.get());
        }
        if (cls == null)
        {
            // Try the loader for the current thread
            cls = ClassOrNullWithInitialize(name, contextClassLoader);
        }
        if (cls == null)
        {
            // Try the loader for the PM context
            cls = ClassOrNullWithInitialize(name, pmContextLoader);
        }
        if (cls == null && runtimeLoader != null)
        {
            // Try the loader for runtime created classes
            cls = ClassOrNullWithInitialize(name, runtimeLoader);
        }
        if (cls == null && userRegisteredLoader != null)
        {
            // Try the user provided loader
            cls = ClassOrNullWithInitialize(name, userRegisteredLoader);
        }

        if (cls == null)
        {
            String msg = LOCALISER.msg("001000", name);
            throw new ClassNotResolvedException(msg);
        }
        loadedClasses.put(cacheKey, cls);

        return cls;
    }
View Full Code Here

            {
                return clr.classForName(fullClassName);
            }
        }

        throw new ClassNotResolvedException("Class " + className + " for query has not been resolved. Check the query and any imports specification");
    }
View Full Code Here

            {
                return clr.classForName(fullClassName);
            }
        }

        throw new ClassNotResolvedException("Class " + className + " for query has not been resolved. Check the query and any imports specification");
    }
View Full Code Here

        {
            return registry.loadClass(pluginId, className);
        }
        catch(ClassNotFoundException ex)
        {
            throw new ClassNotResolvedException(ex.getMessage(),ex);
        }
    }
View Full Code Here

    {
        if (name == null)
        {
            // Avoid the NPE and just throw a "not resolved"
            String msg = LOCALISER.msg("001000", name);
            throw new ClassNotResolvedException(msg);
        }
        if (name.equals(ClassNameConstants.BYTE))
        {
            return byte.class;
        }
        else if (name.equals(ClassNameConstants.CHAR))
        {
            return char.class;
        }
        else if (name.equals(ClassNameConstants.INT))
        {
            return int.class;
        }
        else if (name.equals(ClassNameConstants.LONG))
        {
            return long.class;
        }
        else if (name.equals(ClassNameConstants.DOUBLE))
        {
            return double.class;
        }
        else if (name.equals(ClassNameConstants.FLOAT))
        {
            return float.class;
        }
        else if (name.equals(ClassNameConstants.SHORT))
        {
            return short.class;
        }
        else if (name.equals(ClassNameConstants.BOOLEAN))
        {
            return boolean.class;
        }
        else if (name.equals(ClassNameConstants.JAVA_LANG_STRING))
        {
            return String.class;
        }

        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        String cacheKey = newCacheKey(name, primary, contextClassLoader);

        //lookup in loaded and unloaded classes cache
        Class cls = loadedClasses.get(cacheKey);
        if (cls != null)
        {
            return cls;
        }

        cls = unloadedClasses.get(cacheKey);
        if (cls != null)
        {
            return cls;
        }

        if (cls == null)
        {
            // Try the supplied loader first
            cls = classOrNull(name, primary);
        }
        if (cls == null && this.primary.get() != null)
        {
            // Try the primary for this current thread
            cls = classOrNull(name, (ClassLoader) this.primary.get());
        }
        if (cls == null)
        {
            // Try the loader for the current thread
            cls = classOrNull(name, contextClassLoader);
        }
        if (cls == null)
        {
            // Try the loader for the PM context
            cls = classOrNull(name, pmContextLoader);
        }
        if (cls == null && runtimeLoader != null)
        {
            // Try the registered loader for runtime created classes
            cls = classOrNull(name, runtimeLoader);
        }
        if (cls == null && userRegisteredLoader != null)
        {
            // Try the user registered loader for classes
            cls = classOrNull(name, userRegisteredLoader);
        }

        if (cls == null)
        {
            if (NucleusLogger.CLASSLOADING.isDebugEnabled())
            {
                // Log the class loading failure in case its of use in debugging
                StackTraceElement[] traceElements = new Exception().getStackTrace();
                StackTraceElement element = null;
                int i = 0;
                boolean processingClassLoaderResolverCalls = false;
                while (element == null)
                {
                    if (processingClassLoaderResolverCalls &&
                        traceElements[i].getClassName().indexOf(this.getClass().getName()) < 0)
                    {
                        // Next class in the stack trace after the JDOClassLoaderResolver calls
                        element = traceElements[i];
                    }
                    else if (traceElements[i].getClassName().startsWith("org.datanucleus"))
                    {
                        processingClassLoaderResolverCalls = true;
                    }
                    i++;
                }
                // Don't give stack trace, just the method that asked for class-resolving
                NucleusLogger.CLASSLOADING.debug(LOCALISER.msg("001004", name,
                    element.getClassName() + "." + element.getMethodName(), "" + element.getLineNumber()));
            }
            String msg = LOCALISER.msg("001000", name);
            throw new ClassNotResolvedException(msg);
        }

        //put in unloaded cache, since it was not loaded here
        unloadedClasses.put(cacheKey, cls);
View Full Code Here

    {
        if (name == null)
        {
            // Avoid the NPE and just throw a "not resolved"
            String msg = LOCALISER.msg("001000", name);
            throw new ClassNotResolvedException(msg);
        }
        if (name.equals(ClassNameConstants.BYTE))
        {
            return byte.class;
        }
        else if (name.equals(ClassNameConstants.CHAR))
        {
            return char.class;
        }
        else if (name.equals(ClassNameConstants.INT))
        {
            return int.class;
        }
        else if (name.equals(ClassNameConstants.LONG))
        {
            return long.class;
        }
        else if (name.equals(ClassNameConstants.DOUBLE))
        {
            return double.class;
        }
        else if (name.equals(ClassNameConstants.FLOAT))
        {
            return float.class;
        }
        else if (name.equals(ClassNameConstants.SHORT))
        {
            return short.class;
        }
        else if (name.equals(ClassNameConstants.BOOLEAN))
        {
            return boolean.class;
        }
        else if (name.equals(ClassNameConstants.JAVA_LANG_STRING))
        {
            return String.class;
        }

        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        String cacheKey = newCacheKey(name, primary, contextClassLoader);
        //only lookup in loaded classes cache
        Class cls = loadedClasses.get(cacheKey);

        if (cls != null)
        {
            return cls;
        }

        if (cls == null)
        {
            // Try the supplied loader first
            cls = ClassOrNullWithInitialize(name, primary);
        }
        if (cls == null && this.primary.get() != null)
        {
            // Try the primary for this current thread
            cls = ClassOrNullWithInitialize(name, (ClassLoader) this.primary.get());
        }
        if (cls == null)
        {
            // Try the loader for the current thread
            cls = ClassOrNullWithInitialize(name, contextClassLoader);
        }
        if (cls == null)
        {
            // Try the loader for the PM context
            cls = ClassOrNullWithInitialize(name, pmContextLoader);
        }
        if (cls == null && runtimeLoader != null)
        {
            // Try the loader for runtime created classes
            cls = ClassOrNullWithInitialize(name, runtimeLoader);
        }
        if (cls == null && userRegisteredLoader != null)
        {
            // Try the user provided loader
            cls = ClassOrNullWithInitialize(name, userRegisteredLoader);
        }

        if (cls == null)
        {
            String msg = LOCALISER.msg("001000", name);
            throw new ClassNotResolvedException(msg);
        }
        loadedClasses.put(cacheKey, cls);

        return cls;
    }
View Full Code Here

                    }
                }

                if (c == null)
                {
                    throw new ClassNotResolvedException(classDecl);
                }

                if (NucleusLogger.GENERAL.isDebugEnabled())
                {
                    NucleusLogger.GENERAL.debug(LOCALISER.msg("021010", classDecl, c.getName()));
View Full Code Here

            {
                return clr.classForName(fullClassName);
            }
        }

        throw new ClassNotResolvedException("Class " + className + " for query has not been resolved. Check the query and any imports specification");
    }
View Full Code Here

TOP

Related Classes of org.datanucleus.exceptions.ClassNotResolvedException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.