Class Reloader limitations

3 views
Skip to first unread message

DavidNia

unread,
Feb 20, 2010, 5:20:59 PM2/20/10
to Induction Framework
I understand that the class reloader can not reload classes if the
application is deployed using a war file.

But is it the reloader that loads classes the first time classes are
accessed (like when the servlet container is started for the first
time)?

I am having the issue where I can't even deploy my application (which
is in WAR form) because the class reloader can't find a class inside
my WAR. The fact that it can't find the class is not the surprise. I
am surprised that the reloader is 'reloading' a class when this is the
first time the class is being accessed.

I got around this by adding the class path to the exploded directory
on the server - but this makes the induction xml much less portable.

Is the class reloader the only way classes are loaded into induction?

If so, then is it the case that no application should be deployed in
WAR format for now?

thanks,
david

Adinath

unread,
Feb 20, 2010, 11:24:57 PM2/20/10
to induction...@googlegroups.com
On Sat, Feb 20, 2010 at 3:20 PM, DavidNia <da...@3dex.com> wrote:
I understand that the class reloader can not reload classes if the
application is deployed using a war file.

Yes, since it does not really make sense to reload from a .war, since when a war is deployed the application gets redeployed anyways.


But is it the reloader that loads classes the first time classes are
accessed (like when the servlet container is started for the first
time)?
I am having the issue where I can't even deploy my application (which
is in WAR form) because the class reloader can't find a class inside
my WAR.  The fact that it can't find the class is not the surprise.  I
am surprised that the reloader is 'reloading' a class when this is the
first time the class is being accessed.

I got around this by adding the class path to the exploded directory
on the server - but this makes the induction xml much less portable.

Is the class reloader the only way classes are loaded into induction?

Induction is designed so that the reloading classloader does not even activate if you omit the <java-class-path> or leave it empty. Are you leaving <java-class-path> section empty?
  

If so, then is it the case that no application should be deployed in
WAR format for now?

Absolutely not! Induction is designed and has been tested and deployed in production with .WAR files!

Regards,
Adi

--
Acciente, LLC
Systems Architecture and Software Design

www.acciente.com
www.inductionframework.org

DavidNia

unread,
Feb 21, 2010, 12:47:40 PM2/21/10
to Induction Framework
Yes, I do have a <java-class-path>.
My application loads resources (property file) through the
ClassLoader.getResourceAsStream().

I think I can get around this by putting the resource I am accessing
the 'classes' folder. That way I can get rid of the <java-class-path>
altogether.

I will submit the result of what happens when I put the resource in
the 'classes' folder.

david

Adinath

unread,
Feb 21, 2010, 3:04:33 PM2/21/10
to induction...@googlegroups.com
On Sun, Feb 21, 2010 at 10:47 AM, DavidNia <da...@3dex.com> wrote:
Yes, I do have a <java-class-path>.
My application loads resources (property file) through the
ClassLoader.getResourceAsStream().

I think I can get around this by putting the resource I am accessing
the 'classes' folder.  That way I can get rid of the <java-class-path>
altogether.

I will submit the result of what happens when I put the resource in
the 'classes' folder.

Correct, you do not need a an Induction classpath (specified in <java-class-path>) for ClassLoader.getResourceAsStream() to work, that works via any classloader.

Adi

DavidNia

unread,
Feb 21, 2010, 4:08:39 PM2/21/10
to Induction Framework
I still have problems...here is a detailed description of what I did
and the result:

To describe the scenario visually i also draw 'stick' figures

Scenario 1:
- I had all my resources (including induction.xml) in the WEB-INF
folder.
- In inductionl.xml I had in <java-class-path> the paths to WEB-INF,
WEB-INF/classes


visual representation of scenario 1:

---------------------------------------------------------
\WEB-INF (java-class-path points here)

[xml resources here, induction.xml here]

\classes (java-class-path points here)
---------------------------------------------------------

this WORKS, but I want to get rid of all java-class-path entries

Scenario 2:
- I put all resources (including induction.xml) in WEB-INF\classes
folder
- I removed all <java-class-path> entries from induction.xml

visual representation of scenario 2:

---------------------------------------------------------
\WEB-INF

\classes

[xml resources here, induction.xml here (induction.xml could
not be found!) ]
---------------------------------------------------------

this DID NOT work - I got an error from the XMLConfigLoader when it
tried to load induction.xml..it could not find induction.xml

Scenario 3:
- I moved induction.xml to WEB-INF without changing anything else.
- So at this point there is still no <java-class-path> entries in
Induction.xml
- Also all my other resources are in the WEB-INF classes folder

visual representation of scenario 3:

---------------------------------------------------------
\WEB-INF

[induction.xml here]

\classes

[xml resources here]
(error - could not find application classes!)
---------------------------------------------------------

this DID NOT work - it could not find my application class files (even
though they are in the WEB-INF/classes folder)

Scenario 4:
- i added <java-class-path> for WEB-INF/classes only

visual representation of scenario 3:

---------------------------------------------------------
\WEB-INF

[induction.xml here]

\classes (java-class-path points here)

[xml resources here]

---------------------------------------------------------

this WORKS

This is a big improvement over scenario 1 where I only have java-class-
path for WEB-INF classes.
All resources except for induction.xml are in resources.


Summary:

- if resources are in WEB-INF you need java-class-path to WEB-INF
- i could not find a scenario where i did not need to specify WEB-INF
classes in java-class-path

david

Reply all
Reply to author
Forward
0 new messages