Package org.apache.velocity.exception

Examples of org.apache.velocity.exception.VelocityException


    catch (RuntimeException ex) {
      throw ex;
    }
    catch (Exception ex) {
      logger.error("Why does VelocityEngine throw a generic checked exception, after all?", ex);
      throw new VelocityException(ex.toString());
    }
  }
View Full Code Here


    catch (RuntimeException ex) {
      throw ex;
    }
    catch (Exception ex) {
      logger.error("Why does VelocityEngine throw a generic checked exception, after all?", ex);
      throw new VelocityException(ex.toString());
    }

    return velocityEngine;
  }
View Full Code Here

      return null;
    }

    String[] tmpArray = name.split(pluginNameAndPathSplitString);
    if (tmpArray.length < 2) {
      throw new VelocityException("视图名称[" + name + "]不符合规则:“[插件名]"
          + pluginNameAndPathSplitString + "[路径]”");
    }
    String pluginName = tmpArray[0];
    String path = tmpArray[1];
    // 对视图名称进行处理(添加前后缀)
    path = viewNamePrefix + path + viewNameSuffix;

    Bundle bundle = OsgiContext.getBundleByName(pluginName);

    if (bundle == null) {
      throw new VelocityException(String.format(
          "Can't found plugin[%s],template [%s] load failure.",
          pluginName, name));
    }
    URL url = bundle.getResource(path);
    if (url == null) {
      throw new ResourceNotFoundException(
          "BundleResourceLoader : cannot find " + name);
    }
    InputStream ufs;
    try {
      ufs = url.openStream();
    } catch (IOException ioe) {
      String msg = "Exception while loading Template " + name;
      log.error(msg, ioe);
      throw new VelocityException(msg, ioe);
    }
    templateBundles.put(name, bundle);
    return new BufferedInputStream(ufs);
  }
View Full Code Here

        {
            throw new ResourceNotFoundException( "Template not found. ( " + templateDirectory + "/" + template + " )" );
        }
        catch ( VelocityException ve )
        {
            throw new VelocityException( ve.toString() );
        }

        catch ( Exception e )
        {
            if ( e.getCause() != null )
View Full Code Here

            else
            {
                String msg = directiveClass + " does not implement "
                    + Directive.class.getName() + "; it cannot be loaded.";
                log.error(msg);
                throw new VelocityException(msg);
            }
        }
        // The ugly threesome:  ClassNotFoundException,
        // IllegalAccessException, InstantiationException.
        // Ignore Findbugs complaint for now.
        catch (Exception e)
        {
            String msg = "Failed to load Directive: " + directiveClass;
            log.error(msg, e);
            throw new VelocityException(msg, e);
        }
    }
View Full Code Here

            }
            catch(Exception e)
            {
                String msg = "RuntimeInstance.render(): init exception for tag = "+logTag;
                getLog().error(msg, e);
                throw new VelocityException(msg, e);
            }

            /*
             *  now render, and let any exceptions fly
             */
 
View Full Code Here

        if (!isVelocimacro(vmName, logTag))
        {
            String msg = "RuntimeInstance.invokeVelocimacro() : VM '" + vmName
                         + "' is not registered.";
            getLog().error(msg);
            throw new VelocityException(msg);
        }

        /* now just create the VM call, and use evaluate */
        StrBuilder template = new StrBuilder("#");
        template.append(vmName);
View Full Code Here

        catch ( Exception e)
        {
            String msg = "Exception rendering #parse(" + arg + ") at " +
                         Log.formatFileString(this);
            rsvc.getLog().error(msg, e);
            throw new VelocityException(msg, e);
        }

        if (!blockinput)
        {
            /**
             * Add the template name to the macro libraries list
             */
            List macroLibraries = context.getMacroLibraries();

            /**
             * if macroLibraries are not set create a new one
             */
            if (macroLibraries == null)
            {
                macroLibraries = new ArrayList();
            }

            context.setMacroLibraries(macroLibraries);

            macroLibraries.add(arg);
        }

        /*
         *  and render it
         */
        try
        {
            if (!blockinput) {
                context.pushCurrentTemplateName(arg);
                ((SimpleNode) t.getData()).render( context, writer );
            }
        }
        /**
         * pass through application level runtime exceptions
         */
        catch( RuntimeException e )
        {
            /**
             * Log #parse errors so the user can track which file called which.
             */
            rsvc.getLog().error("Exception rendering #parse(" + arg + ") at " +
                                Log.formatFileString(this));
            throw e;
        }
        catch ( Exception e )
        {
            String msg = "Exception rendering #parse(" + arg + ") at " +
                         Log.formatFileString(this);
            rsvc.getLog().error(msg, e);
            throw new VelocityException(msg, e);
        }
        finally
        {
            if (!blockinput)
                context.popCurrentTemplateName();
View Full Code Here

            byteArray = resource.getBody().getBytes(resource.getEncoding());
            return new ByteArrayInputStream(byteArray);
        }
        catch(UnsupportedEncodingException ue)
        {
            throw new VelocityException("Could not convert String using encoding " + resource.getEncoding(), ue);
        }
    }
View Full Code Here

            {
                repository = (StringResourceRepository) ClassUtils.getNewInstance(className);
            }
            catch (ClassNotFoundException cnfe)
            {
                throw new VelocityException("Could not find '" + className + "'", cnfe);
            }
            catch (IllegalAccessException iae)
            {
                throw new VelocityException("Could not access '" + className + "'", iae);
            }
            catch (InstantiationException ie)
            {
                throw new VelocityException("Could not instantiante '" + className + "'", ie);
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.velocity.exception.VelocityException

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.