Discussion:
[Middlegen-user] getClass().getResource("...") returns null?
Joel Hillacre
2004-09-29 19:07:04 UTC
Permalink
My plugin is having trouble finding it's resources in the jar file.
I am trying to add a fileproducer with:
<code>
addConfiguredFileproducer(new FileProducer(getDestinationDir(),
"{0}SpringServiceImpl.java",
getClass().getResource("SpringServiceImpl.vm")));
</code>
However, when this code executes (built using the middlegen build.xml and
executed using a custom project build.xml), I receive a <code>template can't
be null</code> error message from the file producer constructor.
I checked my middlegen-spring-plugin-2.1.jar, and the SpringServiceImpl.vm is
sitting beside my SpringPlugin.class. What did i miss here? :s
Thank you for any help,
Joel Hillacre
Eivind Waaler
2004-09-30 07:22:14 UTC
Permalink
Hmm, sounds like some kind of classloader issue. Are you sure your plugin
class is not found multiple places in the classpath? For instance if
there's an old version of your jar file without the .vm file somewhere?

Try a clean build of everything. Compare your jar file with one that
works, see if there are any differences.

BTW: Your Spring plugin sounds interesting, what are you generating? A
DAO? Hibernate support?

Cheers
.eivind
Post by Joel Hillacre
My plugin is having trouble finding it's resources in the jar file.
<code>
addConfiguredFileproducer(new FileProducer(getDestinationDir(),
"{0}SpringServiceImpl.java",
getClass().getResource("SpringServiceImpl.vm")));
</code>
However, when this code executes (built using the middlegen build.xml and
executed using a custom project build.xml), I receive a <code>template can't
be null</code> error message from the file producer constructor.
I checked my middlegen-spring-plugin-2.1.jar, and the SpringServiceImpl.vm is
sitting beside my SpringPlugin.class. What did i miss here? :s
Thank you for any help,
Joel Hillacre
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Joel Hillacre
2004-09-30 12:13:06 UTC
Permalink
I figured it out. I was adding multiple file producers and had a ID-10-T error
while I was typing in the file name of the last vm template... :[

We are moving our project to a new architecture using struts, spring and
hibernate. With middlegen having a hibernate plugin and a struts plugin, we
decided to just write the spring plugin ourselves. My boss also seems
interested in releasing it back out to the middlegen project, since it can
only get better from there. :) Right now, the spring plugin a very simple
DAO using hibernate, and an interface for use in a struts action, which would
include business rules. It has been coming together nicely, even though I
have only started poking around in w/middlegen this last week. I am hoping
to have something more solid next week.

Thanks for your interest
Joel Hillacre
Post by Eivind Waaler
Hmm, sounds like some kind of classloader issue. Are you sure your plugin
class is not found multiple places in the classpath? For instance if
there's an old version of your jar file without the .vm file somewhere?
Try a clean build of everything. Compare your jar file with one that
works, see if there are any differences.
BTW: Your Spring plugin sounds interesting, what are you generating? A
DAO? Hibernate support?
Cheers
.eivind
Post by Joel Hillacre
My plugin is having trouble finding it's resources in the jar file.
<code>
addConfiguredFileproducer(new FileProducer(getDestinationDir(),
"{0}SpringServiceImpl.java",
getClass().getResource("SpringServiceImpl.vm")));
</code>
However, when this code executes (built using the middlegen build.xml and
executed using a custom project build.xml), I receive a <code>template
can't be null</code> error message from the file producer constructor. I
checked my middlegen-spring-plugin-2.1.jar, and the SpringServiceImpl.vm
is sitting beside my SpringPlugin.class. What did i miss here? :s
Thank you for any help,
Joel Hillacre
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out
more http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Eivind Waaler
2004-09-30 12:58:02 UTC
Permalink
Sounds very interesting. We have a very similar architecture on my current
project, using WebWork2 instead of Struts:

WW2 Action -> Facade (POJI/POJO) -> DAO (Spring/Hibernate)

Maybe we could include something in a later version. Guess it would
require some rewrites of existing plugins. I'd like to refactor/remove the
adapter plugin to be more like the above mentioned architecture. That way
we could have a generic interface with different implementations for the
different persistence mechanisms (Hibernate, CMP, Torque, JDO..). The
Struts/WW plugin could generate code targeted towards the interface, using
Spring to actually instantiate the wanted implementation for us :-)

I'd like to continue this discussion later..
.eivind
Post by Joel Hillacre
I figured it out. I was adding multiple file producers and had a ID-10-T error
while I was typing in the file name of the last vm template... :[
We are moving our project to a new architecture using struts, spring and
hibernate. With middlegen having a hibernate plugin and a struts plugin, we
decided to just write the spring plugin ourselves. My boss also seems
interested in releasing it back out to the middlegen project, since it can
only get better from there. :) Right now, the spring plugin a very simple
DAO using hibernate, and an interface for use in a struts action, which would
include business rules. It has been coming together nicely, even though I
have only started poking around in w/middlegen this last week. I am hoping
to have something more solid next week.
Thanks for your interest
Joel Hillacre
Post by Eivind Waaler
Hmm, sounds like some kind of classloader issue. Are you sure your plugin
class is not found multiple places in the classpath? For instance if
there's an old version of your jar file without the .vm file somewhere?
Try a clean build of everything. Compare your jar file with one that
works, see if there are any differences.
BTW: Your Spring plugin sounds interesting, what are you generating? A
DAO? Hibernate support?
Cheers
.eivind
Post by Joel Hillacre
My plugin is having trouble finding it's resources in the jar file.
<code>
addConfiguredFileproducer(new FileProducer(getDestinationDir(),
"{0}SpringServiceImpl.java",
getClass().getResource("SpringServiceImpl.vm")));
</code>
However, when this code executes (built using the middlegen build.xml and
executed using a custom project build.xml), I receive a <code>template
can't be null</code> error message from the file producer constructor. I
checked my middlegen-spring-plugin-2.1.jar, and the SpringServiceImpl.vm
is sitting beside my SpringPlugin.class. What did i miss here? :s
Thank you for any help,
Joel Hillacre
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out
more http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Loading...