I don't really know which forum to put this under as it covers all these products.
I am posting to ask if anyone out there has a simple working example of a app (WAR) using the above with annotations, as I have tried and tried and tried, but just can not get anywhere and my attempts are now such a mess I don't know where to go from here.
It seems all the examples I find on the Internet just don't work, people tell you to do things in a different way or JARs are wrong, etc etc etc.
I have worked my way through Manning's Struts2 in Action which is an excellent book.
They however, work with Struts 2.0.x. The annotation configuration is quite simple.
You need to pass the FilterDispatcher in the web.xml a param called 'actionPackages' and as the value the packages that contain Action classes.
The Action classes themselves need to either end in Action (e.g. RegisterAction) or implement the Action interface (typically by extending ActionSupport).
The framework then scans the corresponding classes for annotations, which are generated like this
Note that you do not specify a namespace. This is done by convention.
The namespace goes together by the package name + the Action class name minus the Action.
Without saying what's wrong it's completely impossible to help.
I'm running several apps under Struts 2.1, Hibernate 3, and Spring 2.5, so it's possible. For my money it'd be easier to approach it piecemeal: get a simple S2.1 app working, add Spring, then add Hibernate.
Kevin P Smith
Joined: Feb 18, 2005
After a relentless number of errors regarding missing classses or JAr files I have decided to dicth the Spring part for now as to be honest I don't really understand what it offers me that I can't do with just Struts & Hibernate.
I found this link which shows a basic Struts/Hibernate app which I have followed but made a couple of minor changes as I am looking to use annotations over XML
However when running this app I get the following error on the line (HibernateUtils.java)
[sessionFactory = (new AnnotationConfiguration()).configure().buildSessionFactory();]
I have attached teh war file as it stands
Cheers in advance for anything that anyone can add to help with this issue.
No, that looks to be more or less the right list of jars. Have you checked for the root cause of the exception?
Spring offers quite a bit more than just S2/Hibernate; it can handle all the DI/IoC chores (although S2 uses an early, hacked verison of Guice IMO the current Spring stuff is preferable), allows declarative transactions, can handle security tasks, blah blah blah.
Kevin P Smith
Joined: Feb 18, 2005
Sorry thought I included that, there is nothing in the server logs.
That's unusual--do you have logging configured correctly and the logging levels turned up?
Stack traces usually include information, like... well, the stack trace.
One thing Spring would let you do, btw, is inject the service DAO being used in your action. Using DI/IoC *greatly* improves the testability of your actions. Services should generally be coded to an interface, not a specific implementation, for this to be the most versatile. The S2 Spring plugin makes Spring integration seamless and essentially invisible for many (most?) usecases.
Also note that in S2.1 you'll want to use one of the .ng package dispatchers, although the earlier versions may still work.
I don't know the full dependency tree for Hibernate; that's one reason why something like Maven and/or Ivy is really handy.