You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Sachin Dharmapurikar <sa...@akanksha.com> on 2006/06/01 14:58:46 UTC

CustomResourceLoader Not Found in Tomcat 4.x

Hi Everybody,
 
I am novice user of Velocity. I am using Velocity 1.4 in my application. I wrote a custom Resource Loader which loads the template from String. I tested my application in Eclipse with,
 
velocity-dep-1.4.jar
velocity-1.4.jar
 
Files in the classpath. My program just works fine in Eclipse. Then I created a war file for my application. My Resource Loader is our application war file. 
 
I put velocity-dep-1.4.jar in the Tomcat_home/common/lib directory and started the container.
 
I am getting ClassNotFoundException for my Resource Loader class. I do not understand why that’s happening. There are many classes in the same application jar and those works fine, except the custom class loader.
 
My initialization code for Velocity is as follows –
 
Properties p = new Properties();
p.put("resource.loader", "string");
p.put("string.loader.description", "Database String Loader");
p.put("string.resource.loader.class", "com.myapp.util.StringResourceLoader");
Velocity.init(p);
 
StringResourceLoader resides in the application directory.
 
Thanks,
Sachin
 

RE: CustomResourceLoader Not Found in Tomcat 4.x

Posted by mailmur <ma...@yahoo.com>.
About copying velocity.jar to tomcat/common/lib
folder. Did you put StringResourceLoader.class to
webapps/mywebapp/WEB-INF/lib/xxx.jar package (or
WEB-INF/classes folder)?

If yes then maybe it was about the ClassLoader
instance that was giving your problems. common/lib
classes are loaded by a globally shared ClassLoader
instance. All webapps will see classes found in
common/lib folder.

Then each webapp gets a dedicated ClassLoader instance
to load WEB-INF/lib packages.

Maybe Velocity could not found it because core
Velocity classes were loaded by a shared classloader
but your StringResourceLoader.class was read by a
dedicated classloader.

If you put velocity.jar and StringResourecLoader.class
to the same place (common/lib or web-inf/lib) then it 
should work.

--- Sachin Dharmapurikar <sa...@akanksha.com> wrote:
> Hi Nathan,
> 
> Thanks for your suggestion. I copied the jar from
> Tomcat common lib to WEB-INF/lib. In addition to
> that I called
> 
>
Class.forName("com.myapp.util.StringResourceLoader");
> 
> Now my code works absolutely fine.
> 
> Thanks for support.
> 
> Regards,
> Sachin
> 
> -----Original Message-----
> From: Nathan Bubna [mailto:nbubna@gmail.com] 
> Sent: Thursday, June 01, 2006 11:35 PM
> To: Velocity Users List
> Subject: Re: CustomResourceLoader Not Found in
> Tomcat 4.x
> 
> try putting the velocity-dep-1.4.jar in with your
> application's
> library jars instead of in Tomcat's common lib.
> 
> On 6/1/06, Sachin Dharmapurikar
> <sa...@akanksha.com> wrote:
> > Hi Everybody,
> >
> > I am novice user of Velocity. I am using Velocity
> 1.4 in my application. I wrote a custom Resource
> Loader which loads the template from String. I
> tested my application in Eclipse with,
> >
> > velocity-dep-1.4.jar
> > velocity-1.4.jar
> >
> > Files in the classpath. My program just works fine
> in Eclipse. Then I created a war file for my
> application. My Resource Loader is our application
> war file.
> >
> > I put velocity-dep-1.4.jar in the
> Tomcat_home/common/lib directory and started the
> container.
> >
> > I am getting ClassNotFoundException for my
> Resource Loader class. I do not understand why
> that's happening. There are many classes in the same
> application jar and those works fine, except the
> custom class loader.
> >
> > My initialization code for Velocity is as follows
> –
> >
> > Properties p = new Properties();
> > p.put("resource.loader", "string");
> > p.put("string.loader.description", "Database
> String Loader");
> > p.put("string.resource.loader.class",
> "com.myapp.util.StringResourceLoader");
> > Velocity.init(p);
> >
> > StringResourceLoader resides in the application
> directory.
> >
> > Thanks,
> > Sachin

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


RE: CustomResourceLoader Not Found in Tomcat 4.x

Posted by Sachin Dharmapurikar <sa...@akanksha.com>.
Hi Nathan,

Thanks for your suggestion. I copied the jar from Tomcat common lib to WEB-INF/lib. In addition to that I called

Class.forName("com.myapp.util.StringResourceLoader");

Now my code works absolutely fine.

Thanks for support.

Regards,
Sachin

-----Original Message-----
From: Nathan Bubna [mailto:nbubna@gmail.com] 
Sent: Thursday, June 01, 2006 11:35 PM
To: Velocity Users List
Subject: Re: CustomResourceLoader Not Found in Tomcat 4.x

try putting the velocity-dep-1.4.jar in with your application's
library jars instead of in Tomcat's common lib.

On 6/1/06, Sachin Dharmapurikar <sa...@akanksha.com> wrote:
> Hi Everybody,
>
> I am novice user of Velocity. I am using Velocity 1.4 in my application. I wrote a custom Resource Loader which loads the template from String. I tested my application in Eclipse with,
>
> velocity-dep-1.4.jar
> velocity-1.4.jar
>
> Files in the classpath. My program just works fine in Eclipse. Then I created a war file for my application. My Resource Loader is our application war file.
>
> I put velocity-dep-1.4.jar in the Tomcat_home/common/lib directory and started the container.
>
> I am getting ClassNotFoundException for my Resource Loader class. I do not understand why that's happening. There are many classes in the same application jar and those works fine, except the custom class loader.
>
> My initialization code for Velocity is as follows –
>
> Properties p = new Properties();
> p.put("resource.loader", "string");
> p.put("string.loader.description", "Database String Loader");
> p.put("string.resource.loader.class", "com.myapp.util.StringResourceLoader");
> Velocity.init(p);
>
> StringResourceLoader resides in the application directory.
>
> Thanks,
> Sachin
>
>
>

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



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


Re: CustomResourceLoader Not Found in Tomcat 4.x

Posted by Nathan Bubna <nb...@gmail.com>.
try putting the velocity-dep-1.4.jar in with your application's
library jars instead of in Tomcat's common lib.

On 6/1/06, Sachin Dharmapurikar <sa...@akanksha.com> wrote:
> Hi Everybody,
>
> I am novice user of Velocity. I am using Velocity 1.4 in my application. I wrote a custom Resource Loader which loads the template from String. I tested my application in Eclipse with,
>
> velocity-dep-1.4.jar
> velocity-1.4.jar
>
> Files in the classpath. My program just works fine in Eclipse. Then I created a war file for my application. My Resource Loader is our application war file.
>
> I put velocity-dep-1.4.jar in the Tomcat_home/common/lib directory and started the container.
>
> I am getting ClassNotFoundException for my Resource Loader class. I do not understand why that's happening. There are many classes in the same application jar and those works fine, except the custom class loader.
>
> My initialization code for Velocity is as follows –
>
> Properties p = new Properties();
> p.put("resource.loader", "string");
> p.put("string.loader.description", "Database String Loader");
> p.put("string.resource.loader.class", "com.myapp.util.StringResourceLoader");
> Velocity.init(p);
>
> StringResourceLoader resides in the application directory.
>
> Thanks,
> Sachin
>
>
>

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