[Fuge-devel] Hibernate-stk dependencies

3 views
Skip to first unread message

Woodbridge, Mark R

unread,
Sep 4, 2008, 11:35:29 AM9/4/08
to fuge-...@lists.sourceforge.net
Hi,

I've built the stk and run the tests... But I'm wondering what happens
when you want to use the generated jars outside of mvn?

I've got a simple example (see below) in Eclipse and I've added the 2
stk jars (core and mapping) that are required to make it build.

The problem is when I run it: I've got it to work by just adding lots of
random jars from my .m2 repository to the classpath. But I guess this
isn't the best approach - especially as there is often more than one
version of each dependency available.

Is there a better way to manage the dependencies at runtime? Is there a
mvn task to build a fuge-hibernate distributable that contains a
consistent set of required jars?

Any ideas gratefully accepted,

Mark.

Organization organization = ( Organization )
DatabaseObjectHelper.getOrCreate( "saveIdentifiable:Organization:" +
String.valueOf( Math.random() ), "saveIdentifiableWithPerformer",
"net.sourceforge.fuge.common.audit.Organization" );
organization.setName("Acme Corp.");
organization = ( Organization ) DatabaseObjectHelper.save(
"net.sourceforge.fuge.common.audit.Organization", organization, null );
assert ( organization.getId() != null ) : "organization must have a
database id.";

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Fuge-devel mailing list
Fuge-...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fuge-devel

Allyson Lister

unread,
Sep 5, 2008, 7:39:38 AM9/5/08
to fuge-...@lists.sourceforge.net
Hi Mark,

Sorry to take so long to reply - I've been at the MGED conference in Italy, and am only back at work today.

I'll run your example below on my own system this afternoon - I'm in the wrong OS to do it right now. You are correct, that you shouldn't have to mess about with the maven repo to use the code outside maven. I can use code outside maven: for instance, when maven packages the SyMBA war for me, it includes all required jars and runs perfectly well as a standalone application. For the running of specific main methods, however, I do tend to run them using the "mvn exec:java" command (http://mojo.codehaus.org/exec-maven-plugin/java-mojo.html), which allows command-line running and automatically makes use of the maven classpaths. You have to build your classpath manually otherwise.

Are you trying to run this within Eclipse? Did you build the eclipse project files with the mvn eclipse command (e.g. http://byteworksinc.blogspot.com/2008/01/summary-this-post-covers-setting-up.html)? Or, are you trying to run from the command line, or within a completely different java project?

Are you using maven to build the jar for your code shown below, e.g. in a different standalone project? If so, it should be that if you create that jar using maven and with the appropriate dependencies in the pom, then you'll be able to use that jar (containing the code below) as a standalone thing: all necessary jars will be pulled out by maven and put into your new jarfile. Make sense? Sorry, it's been a long week!

2008/9/4 Woodbridge, Mark R <m.wood...@imperial.ac.uk>



--
Thanks,
Allyson :)

Allyson Lister
Research Associate
Centre for Integrated Systems Biology for Ageing and Nutrition
Newcastle University
http://www.cisban.ac.uk
School of Computing Science
Newcastle University
Newcastle upon Tyne, NE1 7RU

Woodbridge, Mark R

unread,
Sep 8, 2008, 6:01:18 AM9/8/08
to fuge-...@lists.sourceforge.net
I don't think my original message was very clear! I guess what I really asking is: if I want to write some stand-alone code to populate a FuGE database using the Hibernate STK, then how do I build my classpath? In this case I am running my code in Eclipse, outside of the FuGE STK project.
 
I don't really want a run-time dependency on maven (i.e. mvn:java). I suppose I could build my project using maven (though I'm not keen on that because I don't really understand maven). Perhaps the easiest thing to do is add the lib directory from the SyMBA war to my classpath! That would ensure that I have the required jars (plus a few more).
 
Another way of asking the same question is: is there a hibernate-sdk distributable? i.e. can maven build a zip containing the relevant jars?
 
Mark.
 
 


From: fuge-deve...@lists.sourceforge.net [mailto:fuge-deve...@lists.sourceforge.net] On Behalf Of Allyson Lister
Sent: 05 September 2008 12:40
To: fuge-...@lists.sourceforge.net
Subject: Re: [Fuge-devel] Hibernate-stk dependencies

Allyson Lister

unread,
Sep 8, 2008, 6:20:53 AM9/8/08
to fuge-...@lists.sourceforge.net
Hi Mark,

Ok - so, unless you're using maven, you'd have to build your classpath manually. That's why I suggested building your own project as a maven project - then just writing in your own pom.xml that you require one or more of the fuge-hibernate jars as a dependency would then pull down all of the other required dependencies automatically - that's the great benefit of maven: you don't have to worry about classpaths or anything. Then, once your own jar is made, that works perfectly well as a standalone jar, irrespective of how it was built.

Now, in theory, each fuge-hibernate jar contains within it all jars it needs to run. The only time you would need maven's dependency resolution as described above would be if there was some reason the fuge-hibernate jars needed updating (e.g. if you changed the database connection details in them).

I'm not sure what's going on with your example - I don't really do anything outside of maven these days, unless it's to copy a maven-built war to a tomcat server, for example. But I am sure that maven-built jars are just jars, and as such can be used in a standalone manner. I'll be switching over to my linux partition later today, and will be able to test out your piece of code.

The problem with a "distributable" is that each sub-project of a maven project has its own set of dependencies, and would therefore lead to its own distributable. Further, I don't think it would be too helpful of FuGE people to provide such things, as all of the database connection details are currently stored within the jars, so you'd have to unpack them to modify the properties file. I'm sure there's a way around this, but I am not really all that up on the usage of properties files. There must be a way of layering such files, such that a user-supplied one is used in preference to one in the jars. Perhaps someone on this mailing list that knows how to do this could help in this respect with an addition to the STK?

I'll get back to you later on your specific issue.

2008/9/8 Woodbridge, Mark R <m.wood...@imperial.ac.uk>
I don't think my original message was very clear! I guess what I really asking is: if I want to write some stand-alone code to populate a FuGE database using the Hibernate STK, then how do I build my classpath? In this case I am running my code in Eclipse, outside of the FuGE STK project.
 
I don't really want a run-time dependency on maven (i.e. mvn:java). I suppose I could build my project using maven (though I'm not keen on that because I don't really understand maven). Perhaps the easiest thing to do is add the lib directory from the SyMBA war to my classpath! That would ensure that I have the required jars (plus a few more).
 
Another way of asking the same question is: is there a hibernate-sdk distributable? i.e. can maven build a zip containing the relevant jars?
 
Mark.
 
 


From: fuge-deve...@lists.sourceforge.net [mailto:fuge-deve...@lists.sourceforge.net] On Behalf Of Allyson Lister
Sent: 05 September 2008 12:40
To: fuge-...@lists.sourceforge.net
Subject: Re: [Fuge-devel] Hibernate-stk dependencies

Allyson Lister

unread,
Sep 8, 2008, 6:24:55 AM9/8/08
to fuge-...@lists.sourceforge.net
I think the answer may lie within this maven plugin:

http://maven.apache.org/plugins/maven-assembly-plugin/

However, I haven't used it before, and would need to have a good read of it. Perhaps if you have a look at it and see if you think this meets your needs? Then I'll know if it's worth implementing within the stk.

:) thanks!

2008/9/8 Allyson Lister <a.l.l...@newcastle.ac.uk>
Hi Mark,

Ok - so, unless you're using maven, you'd have to build your classpath manually. That's why I suggested building your own project as a maven project - then just writing in your own pom.xml that you require one or more of the fuge-hibernate jars as a dependency would then pull down all of the other required dependencies automatically - that's the great benefit of maven: you don't have to worry about classpaths or anything. Then, once your own jar is made, that works perfectly well as a standalone jar, irrespective of how it was built.

Now, in theory, each fuge-hibernate jar contains within it all jars it needs to run. The only time you would need maven's dependency resolution as described above would be if there was some reason the fuge-hibernate jars needed updating (e.g. if you changed the database connection details in them).

I'm not sure what's going on with your example - I don't really do anything outside of maven these days, unless it's to copy a maven-built war to a tomcat server, for example. But I am sure that maven-built jars are just jars, and as such can be used in a standalone manner. I'll be switching over to my linux partition later today, and will be able to test out your piece of code.

The problem with a "distributable" is that each sub-project of a maven project has its own set of dependencies, and would therefore lead to its own distributable. Further, I don't think it would be too helpful of FuGE people to provide such things, as all of the database connection details are currently stored within the jars, so you'd have to unpack them to modify the properties file. I'm sure there's a way around this, but I am not really all that up on the usage of properties files. There must be a way of layering such files, such that a user-supplied one is used in preference to one in the jars. Perhaps someone on this mailing list that knows how to do this could help in this respect with an addition to the STK?

I'll get back to you later on your specific issue.

2008/9/8 Woodbridge, Mark R <m.wood...@imperial.ac.uk>
I don't think my original message was very clear! I guess what I really asking is: if I want to write some stand-alone code to populate a FuGE database using the Hibernate STK, then how do I build my classpath? In this case I am running my code in Eclipse, outside of the FuGE STK project.
 
I don't really want a run-time dependency on maven (i.e. mvn:java). I suppose I could build my project using maven (though I'm not keen on that because I don't really understand maven). Perhaps the easiest thing to do is add the lib directory from the SyMBA war to my classpath! That would ensure that I have the required jars (plus a few more).
 
Another way of asking the same question is: is there a hibernate-sdk distributable? i.e. can maven build a zip containing the relevant jars?
 
Mark.
 
 


From: fuge-deve...@lists.sourceforge.net [mailto:fuge-deve...@lists.sourceforge.net] On Behalf Of Allyson Lister
Sent: 05 September 2008 12:40
To: fuge-...@lists.sourceforge.net
Subject: Re: [Fuge-devel] Hibernate-stk dependencies

Woodbridge, Mark R

unread,
Sep 8, 2008, 8:01:00 AM9/8/08
to fuge-...@lists.sourceforge.net
Hi Allyson,
 
 
Now, in theory, each fuge-hibernate jar contains within it all jars it needs to run. The only time you would need maven's dependency resolution as described above would be if there was some reason the fuge-hibernate jars needed updating (e.g. if you changed the database connection details in them). 
 
I don't think that is true... the fuge-hibernate jars only contain fuge classes. When you ask Maven to build a war it adds all the dependencies for you - I'm trying to do a similar thing in Eclipse.
 
The code I sent you works fine... I just added dependencies to my classpath until it ran correctly. But to do it properly I'll look at using Maven in my project, or using the Maven Assembly Plugin in the FuGE Hibernate project.
 
Thanks (again) for all your help. My question turned out to be more about Maven than FuGE!
 
Mark.

Allyson Lister

unread,
Sep 8, 2008, 8:06:13 AM9/8/08
to fuge-...@lists.sourceforge.net
Yeah, I think it's just that, due to my only using Maven, I never really looked deeply into what was needed in terms of running it outside maven. The only thing I tend to use outside maven is my maven-built war, which must package everything, as you mentioned in one of your emails.

I'm sorry that I kept on not quite answering your question - I'm far from a maven guru myself, though I feel I'm reasonably competent..

Let me know how it goes, and if you want me to look at the assembly plugin too.

2008/9/8 Woodbridge, Mark R <m.wood...@imperial.ac.uk>
Hi Allyson,
 
 
Now, in theory, each fuge-hibernate jar contains within it all jars it needs to run. The only time you would need maven's dependency resolution as described above would be if there was some reason the fuge-hibernate jars needed updating (e.g. if you changed the database connection details in them). 
 
I don't think that is true... the fuge-hibernate jars only contain fuge classes. When you ask Maven to build a war it adds all the dependencies for you - I'm trying to do a similar thing in Eclipse.
 
The code I sent you works fine... I just added dependencies to my classpath until it ran correctly. But to do it properly I'll look at using Maven in my project, or using the Maven Assembly Plugin in the FuGE Hibernate project.
 
Thanks (again) for all your help. My question turned out to be more about Maven than FuGE!
 
Mark.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Fuge-devel mailing list
Fuge-...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fuge-devel

Reply all
Reply to author
Forward
0 new messages