I would do two things (the first of which, you have probably done).
1) double-check that the build process for the JAR is correctly
putting the velocity.properties file into the root of the jar and that
the jar is in the classpath  2) try finding it elsewhere in the
classloader heirarchy:

InputStream stream =
Thread.currentThread().getContextClassLoader().getResourceAsStream("velocity.properties");
if (stream == null) {
  stream = 
ThisClass.class.getClassLoader().getResourceAsStream("velocity.properties");
  if (stream == null) {
      stream = ThisClass.class.getResourceAsStream("velocity.properties");
      if (stream == null) {
         throw new RuntimeException("WTF?  i'm not sure the resource
is really there.");
      }
  }
}

On Thu, Jul 21, 2011 at 9:37 AM, laredotornado <laredotorn...@gmail.com> wrote:
>
> Hi,
>
> I'm using Java 1.6, Velocity 1.6.2.  I have a Maven JAR project, in which
> the "velocity.properties" gets packaged at the root of the JAR.  When I
> include this JAR in other projects, I'm not able to initialize velocity,
> using ...
>
>                VelocityEngine ve = new VelocityEngine();
>                final InputStream resourceStream =
> Thread.currentThread().getContextClassLoader().getResourceAsStream("velocity.properties");
>                final Properties velocityProps = new Properties();
>                velocityProps.load(resourceStream);
>                ve.init( velocityProps );
>
> The above dies because the "resourceStream" is null.  Any ideas how I
> reference this file?  Keep in mind that it is packaged within the JAR.
> Thanks, - Dave
> --
> View this message in context: 
> http://old.nabble.com/Trouble-finding-velocity.properties-in-a-jar-tp32108932p32108932.html
> Sent from the Velocity - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
> For additional commands, e-mail: user-h...@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
For additional commands, e-mail: user-h...@velocity.apache.org

Reply via email to