hivemind-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jean-Francois Poilpret" <jfpoilp...@hcm.vnn.vn>
Subject RE: Hivetranse/Hibernate/Tapestry troubles
Date Thu, 23 Feb 2006 15:33:00 GMT
Hi Andreas,

I hope it is not too late for me to try answering your questions!

1. Difference between <service> and <set-service>: this is the difference
between constructor-injection and setter-injection in HiveMind:
- if you use <service> in your config file, then your constructor must have
an argument of the expected service type (be also careful that the order of
arguments in the config should match the order of args in your constructor)
- if you use <set-service property="myService".../>, then you should have
setter/getter for "myService property, ie setMyService/getMyService
(according to standard JavaBean specs).

Note1: if you don't use constructor injection at all, make sure you provide
a default constructor (ie with no args), this is done automatically by the
compiler provided that you did not define ANY constructor on your own).

Note2: on hivetranse web site, all examples use constructor-injection
because that is my preferred way, so if you want setter-injection, you have
to adapt them: configuration, constructors, setters/getters.

Note3 (IMPORTANT): from the message you get from HiveMind, it might be good
for you to set auto-wire="false" in the <construct class tag.

2. [Almost same as before]
If you want only setter-injection, make sure you have a default constructor.
Make sure you have setter/getter that are correct: 
- setter takes the same type as getter returned type
- arg type is the interface type of the service to be injected

For auto-wiring (personnally I don't like auto-wiring) , this will work only
if for each service that you want to inject, there is only one such service
(defined by its INTERFACE not by its name) in your config.

My suggestion: for putting everything into place, remove auto-wiring, and
put in place the first thing that will work;-) Refactor later!

3. By default hivemodule.xml files are expected in META-INF by HiveMind,
there is normally no need to change them.
It seems that your hivemodule.xml (the one which contains the transaction
defaults for hivetranse) cannot be found at registry building time:
- did you check that your file has the correct name and path
(META-INF/hivemodule.xml)
- did you check that after the build, the jar for your module includes your
config file (that is a common mistake...)?

Other question: for building registry, do you use HiveMindFilter? Or do you
use your own sevlet filter?

4. For your config in WEB-INF, do you have some more info (in your LOG file
for instance) about the "Could not build SessionFactory" error?
What I suspect is that the "../META-INF/hibernate.cfg.xml" cannot point to
your Hibernate config file any more (because from WEB-INF,../META-INF points
nowhere at all).

I think that to simplify things, you should try to stick with a HiveMind
config file in META-INF rather than in WEB-INF.

Hope this helps

Cheers

	Jean-Francois



-----Original Message-----
From: Andreas Bulling [mailto:andreas@phoenix.hadiko.de] On Behalf Of
Andreas Bulling
Sent: Wednesday, February 22, 2006 6:31 PM
To: hivemind-user@jakarta.apache.org
Subject: Hivetranse/Hibernate/Tapestry troubles

Hi everybody,

after trying to get Hivetranse/Hibernate/Tapestry to work for days
I'm in great despair now because it just doesn't work :(

As the subject says I want to use Hivetranse with Hibernate and
Tapestry as frontend but I wasn't able to find any document describing
this setup. So I hope somebody on this list can help me - Thanks in
advance!

What I did so far:

I followed the descriptions on the Hivetranse site to setup Hibernate3
(http://hivetranse.sourceforge.net/quickstart.html#start.config.hibernate3)

I've put several POJOs and corresponding DAO classes in hivemodule.xml.
For example:
---
<service-point id="PersonDao" interface="de.test.plattform.dao.PersonDao">
    <invoke-factory>
		<construct class="de.test.plattform.dao.PersonDaoImpl">
			<set-service property="session"
service-id="hibernateSession" />
		</construct>
    </invoke-factory>
    <interceptor service-id="hivetranse.core.TransactionInterceptor"/>
</service-point>
---

I also want to have one "operations" class which makes use of all the
different
DAOs, so I added:
---
<service-point id="Operations" interface="de.test.plattform.dao.Operations">
    <invoke-factory>
		<construct class="de.test.plattform.dao.OperationsImpl">
			<set-service property="personDao"
service-id="PersonDao" />
			...
        </construct>
    </invoke-factory>
    <interceptor service-id="hivetranse.core.TransactionInterceptor"/>
</service-point>
---
The first problem was, that the <service> element mentioned in the document
didn't seem to work that's why you can see all these <set-service> elements.

1) What's the difference between <service> and <set-service> and can I
add serveral <service> element below the <construct> element?

Another problem was autowiring. First I got errors that 
---
Exception invoking listener method attemptLogin of component Login: Unable
to 
construct service plattform.Operations: Error building service 
plattform.Operations: Unable to find constructor applicable for autowiring. 
Use explicit constructor parameters.
---

2) But I didn't set the constructor method by purpose, autowiring should
be used by default, shouldn't it? What do I need to use autowiring?
My DAO classes have corresponding setter methods (setSession() and
setPersonDao() in operations)

3) Putting hivemodule.xml in META-INF yields the following error:
---
javax.servlet.ServletException: Unable to initialize application servlet:
Error at
jar:file:/home/andreas/workspace/plattform/context/WEB-INF/lib/hivetranse.co
re.jar!/META-INF/hivemodule.xml, line 20, column 59: Configuration point
hivetranse.core.TransactionDefaults contains no contributions but expects
exactly one contribution.
	
org.apache.tapestry.ApplicationServlet.init(ApplicationServlet.java:206)
	
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118
)
	
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
	
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
	
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:705)
	
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
	
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:683)
	java.lang.Thread.run(Thread.java:595)
---

So I've put it in WEB-INF but then I have to set config-file to:
---
<service-point id="hibernateSession" interface="org.hibernate.Session">
    <invoke-factory service-id="hivetranse.hibernate3.SessionFactory"
model="singleton">
    	<config file="../META-INF/hibernate.cfg.xml">
	        <property name="hibernate.connection.driver_class"
value="org.gjt.mm.mysql.Driver" />
		<property name="hibernate.connection.password"
value="password" />
	        <property name="hibernate.connection.url"
value="jdbc:mysql://localhost/plattform" />
	        <property name="hibernate.connection.username"
value="plattform" />
	        <property name="dialect"
value="org.hibernate.dialect.MySQLDialect" />
	        <property name="show_sql" value="false" />
	        <property name="hbm2ddl.auto" value="create" />
        </config>
    </invoke-factory>
</service-point>
---

This works but then I get
---
Unable to construct service plattform.hibernateSession: Could not build
SessionFactory
---

4) What's wrong here?

Thanks a lot in advance for any help!
Sincerly,
  Andreas

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




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


Mime
View raw message