Tapestrying-hibernate使用指南

tapestry 2006-12-11
一、前提:
1、使用java1.5
2、Hibernate使用annotation配置
3、Hibernate为3.x版本
二、准备:
1、hibernate的配置文件放于类路径,例如WEB-INF/classes的根目录,也就是开发时放于源码的根路径。
2、将hibernate包和依赖包、Tapestrying-hibernat.jar放于lib路径(WEB-INF/lib)。
三、例子:
1、定义service接口
@Transactional
public interface UserService{

public User findById(Long id);

    @Transactional(commit = true)
public void saveUser(User user);

//other methods
}
2、service具体实现
public class UserServiceImpl implements UserService{
private UserDAO userDAO;
public void setUserDAO(UserDAO userDAO){
   this.userDAO = userDAO;
}
public User findById(Long id){
      return userDAO.findById(id);
}
public void saveUser(User user){
  userDAO.saveUser(user);
}
//other methods
}

3、定义DAO接口
public interface UserDAO {
public User findById(Long id);
public void saveUser(User user);
//other methods
}
4、DAO具体实现
public class UserHibernateDAO implements UserDAO{
private Session session;
public void setSession(Session session) {
this.session = session;
}
public User findById(Long id){
return session.load(User.class, id);
}
public void saveUser(User user){
  session.saveOrUpdate(user);
}
}
5、Hivemind配置
<service-point id="UserDAO" interface="UserDAO">
    <invoke-factory>
      <construct class="UserHibernateDAO">
        <set-object property="session" value="infrastructure:session"/>
      </construct>
    </invoke-factory>
</service-point>
<service-point id="UserService" interface=" UserService">
    <invoke-factory>
      <construct class="UserServiceImpl">
        <service>UserDAO</service>
      </construct>
    </invoke-factory> 
    <interceptor service-id=" com.javaeye.tapestrying.TransactionInterceptor"/>
  </service-point> 
6、具体使用:

@InjectObject("service:yourModule.UserService")
public abstract UserService getUserService();

   
tapestry 2006-12-11
Tapestrying-hibernate包在共享里可以下载
zhaow8820 2006-12-11
不知道应用这个包hibernate并发量怎么样
zhaow8820 2006-12-11
和Honeycomb比有什么优势和劣势吗?
tapestry 2006-12-12
1、代码简单,条理清楚,自己可以控制
2、注释声明事务

现在应用项目www.artgle.net
Linuxboy 2006-12-14
按照上面的方法,运行时出现如下错误:
An exception has occurred. 
You may continue by restarting the session.

[ +/- ] Exception: Unable to construct service northstar.dao.UserService: Error building service northstar.dao.UserService: Unable to find constructor applicable for autowiring. Use explicit constructor parameters. 
 org.apache.hivemind.ApplicationRuntimeException 
Unable to construct service northstar.dao.UserService: Error building service northstar.dao.UserService: Unable to find constructor applicable for autowiring. Use explicit constructor parameters. 
location: context:/WEB-INF/northstar.dao.xml, line 12, column 19
7 value="infrastructure:session" /> 
8 </construct> 
9 </invoke-factory> 
10 </service-point> 
11 <service-point id="UserService" interface="org.northstar.service.UserService"> 
12 <invoke-factory> 
13 <construct class="org.northstar.service.UserServiceImpl"> 
14 <service>UserDAO</service> 
15 </construct> 
16 </invoke-factory> 
17 <interceptor 
 
   

[ +/- ] Exception: Error building service northstar.dao.UserService: Unable to find constructor applicable for autowiring. Use explicit constructor parameters. 
org.apache.hivemind.ApplicationRuntimeException 
Error building service northstar.dao.UserService: Unable to find constructor applicable for autowiring. Use explicit constructor parameters. 
location: context:/WEB-INF/northstar.dao.xml, line 12, column 19
7 value="infrastructure:session" /> 
8 </construct> 
9 </invoke-factory> 
10 </service-point> 
11 <service-point id="UserService" interface="org.northstar.service.UserService"> 
12 <invoke-factory> 
13 <construct class="org.northstar.service.UserServiceImpl"> 
14 <service>UserDAO</service> 
15 </construct> 
16 </invoke-factory> 
17 <interceptor 
 
   

[ +/- ] Exception: Error building service northstar.dao.UserService: Unable to find constructor applicable for autowiring. Use explicit constructor parameters. 
org.apache.hivemind.ApplicationRuntimeException 
Error building service northstar.dao.UserService: Unable to find constructor applicable for autowiring. Use explicit constructor parameters. 
location: context:/WEB-INF/northstar.dao.xml, line 13, column 61
8 </construct> 
9 </invoke-factory> 
10 </service-point> 
11 <service-point id="UserService" interface="org.northstar.service.UserService"> 
12 <invoke-factory> 
13 <construct class="org.northstar.service.UserServiceImpl"> 
14 <service>UserDAO</service> 
15 </construct> 
16 </invoke-factory> 
17 <interceptor 
18 service-id="com.javaeye.tapestrying.TransactionInterceptor" /> 
 
   

[ +/- ] Exception: Unable to find constructor applicable for autowiring. Use explicit constructor parameters. 
org.apache.hivemind.ApplicationRuntimeException 
Unable to find constructor applicable for autowiring. Use explicit constructor parameters. 
location: context:/WEB-INF/northstar.dao.xml, line 13, column 61
8 </construct> 
9 </invoke-factory> 
10 </service-point> 
11 <service-point id="UserService" interface="org.northstar.service.UserService"> 
12 <invoke-factory> 
13 <construct class="org.northstar.service.UserServiceImpl"> 
14 <service>UserDAO</service> 
15 </construct> 
16 </invoke-factory> 
17 <interceptor 
18 service-id="com.javaeye.tapestrying.TransactionInterceptor" /> 
 
Stack Trace: 
org.apache.hivemind.service.impl.BuilderFactoryLogic.instantiateExplicitConstructorInstance(BuilderFactoryLogic.java:138) 
org.apache.hivemind.service.impl.BuilderFactoryLogic.instantiateCoreServiceInstance(BuilderFactoryLogic.java:109) 
org.apache.hivemind.service.impl.BuilderFactoryLogic.createService(BuilderFactoryLogic.java:75) 
org.apache.hivemind.service.impl.BuilderFactory.createCoreServiceImplementation(BuilderFactory.java:42) 
org.apache.hivemind.impl.InvokeFactoryServiceConstructor.constructCoreServiceImplementation(InvokeFactoryServiceConstructor.java:62) 
org.apache.hivemind.impl.servicemodel.AbstractServiceModelImpl.constructCoreServiceImplementation(AbstractServiceModelImpl.java:108) 
org.apache.hivemind.impl.servicemodel.AbstractServiceModelImpl.constructNewServiceImplementation(AbstractServiceModelImpl.java:158) 
org.apache.hivemind.impl.servicemodel.AbstractServiceModelImpl.constructServiceImplementation(AbstractServiceModelImpl.java:140) 
org.apache.hivemind.impl.servicemodel.SingletonServiceModel.getActualServiceImplementation(SingletonServiceModel.java:69) 
$UserService_10f80085091._service($UserService_10f80085091.java) 
$UserService_10f80085091.getAllUsers($UserService_10f80085091.java) 
$UserService_10f80085090.getAllUsers($UserService_10f80085090.java) 
$$Home_0$access_userService_allUsers_10f800850ce.readProperty($$Home_0$access_userService_allUsers_10f800850ce.java) 
com.javaforge.tapestry.prop.PropertyAccessorBinding.getObject(PropertyAccessorBinding.java:59) 
org.apache.tapestry.components.Foreach.getSourceData(Foreach.java:61) 
org.apache.tapestry.components.Foreach.renderComponent(Foreach.java:87) 
org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:674) 
org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:131) 
org.apache.tapestry.BaseComponent.renderComponent(BaseComponent.java:92) 
org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:674) 
org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:129) 
org.apache.tapestry.AbstractPage.renderPage(AbstractPage.java:250) 
org.apache.tapestry.engine.RequestCycle.renderPage(RequestCycle.java:338) 
org.apache.tapestry.services.impl.DefaultResponseBuilder.renderResponse(DefaultResponseBuilder.java:117) 
org.apache.tapestry.services.impl.ResponseRendererImpl.renderResponse(ResponseRendererImpl.java:33) 
$ResponseRenderer_10f80084fc1.renderResponse($ResponseRenderer_10f80084fc1.java) 
$ResponseRenderer_10f80084fc0.renderResponse($ResponseRenderer_10f80084fc0.java) 
org.apache.tapestry.engine.HomeService.service(HomeService.java:68) 
$IEngineService_10f8008502f.service($IEngineService_10f8008502f.java) 
org.apache.tapestry.services.impl.EngineServiceInnerProxy.service(EngineServiceInnerProxy.java:77) 
org.apache.tapestry.services.impl.EngineServiceOuterProxy.service(EngineServiceOuterProxy.java:72) 
org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:241) 
org.apache.tapestry.services.impl.InvokeEngineTerminator.service(InvokeEngineTerminator.java:60) 
$WebRequestServicer_10f8008500b.service($WebRequestServicer_10f8008500b.java) 
$WebRequestServicer_10f8008500a.service($WebRequestServicer_10f8008500a.java) 
org.apache.tapestry.services.impl.DisableCachingFilter.service(DisableCachingFilter.java:48) 
$WebRequestServicerFilter_10f8008500d.service($WebRequestServicerFilter_10f8008500d.java) 
$WebRequestServicerFilter_10f8008500c.service($WebRequestServicerFilter_10f8008500c.java) 
$WebRequestServicer_10f8008500e.service($WebRequestServicer_10f8008500e.java) 
com.javaeye.tapestrying.hibernate.TransactionManagerFilter.service(TransactionManagerFilter.java:50) 
$WebRequestServicerFilter_10f80085009.service($WebRequestServicerFilter_10f80085009.java) 
$WebRequestServicerFilter_10f80085008.service($WebRequestServicerFilter_10f80085008.java) 
$WebRequestServicer_10f8008500e.service($WebRequestServicer_10f8008500e.java) 
$WebRequestServicer_10f80085005.service($WebRequestServicer_10f80085005.java) 
$WebRequestServicer_10f80085004.service($WebRequestServicer_10f80085004.java) 
org.apache.tapestry.services.impl.WebRequestServicerPipelineBridge.service(WebRequestServicerPipelineBridge.java:56) 
$ServletRequestServicer_10f80084feb.service($ServletRequestServicer_10f80084feb.java) 
$ServletRequestServicer_10f80084fea.service($ServletRequestServicer_10f80084fea.java) 
org.apache.tapestry.request.DecodedRequestInjector.service(DecodedRequestInjector.java:55) 
$ServletRequestServicerFilter_10f80084fe7.service($ServletRequestServicerFilter_10f80084fe7.java) 
$ServletRequestServicerFilter_10f80084fe6.service($ServletRequestServicerFilter_10f80084fe6.java) 
$ServletRequestServicer_10f80084fec.service($ServletRequestServicer_10f80084fec.java) 
org.apache.tapestry.multipart.MultipartDecoderFilter.service(MultipartDecoderFilter.java:52) 
$ServletRequestServicerFilter_10f80084fe5.service($ServletRequestServicerFilter_10f80084fe5.java) 
$ServletRequestServicerFilter_10f80084fe4.service($ServletRequestServicerFilter_10f80084fe4.java) 
$ServletRequestServicer_10f80084fec.service($ServletRequestServicer_10f80084fec.java) 
org.apache.tapestry.services.impl.SetupRequestEncoding.service(SetupRequestEncoding.java:53) 
$ServletRequestServicerFilter_10f80084fe9.service($ServletRequestServicerFilter_10f80084fe9.java) 
$ServletRequestServicerFilter_10f80084fe8.service($ServletRequestServicerFilter_10f80084fe8.java) 
$ServletRequestServicer_10f80084fec.service($ServletRequestServicer_10f80084fec.java) 
$ServletRequestServicer_10f80084fdf.service($ServletRequestServicer_10f80084fdf.java) 
$ServletRequestServicer_10f80084fde.service($ServletRequestServicer_10f80084fde.java) 
org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:123) 
org.apache.tapestry.ApplicationServlet.doGet(ApplicationServlet.java:104) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:689) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:802) 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) 
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) 
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) 
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) 
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) 
java.lang.Thread.run(Thread.java:595) 
 



[ +/- ] Request 
HttpServletRequest
authType <NULL> 
characterEncoding UTF-8  
contentLength -1 
contextPath /slsafety  
contentType <NULL> 
locale zh_CN  
method GET  
pathInfo <NULL> 
pathTranslated <NULL> 
protocol HTTP/1.1  
queryString <NULL> 
requestURI /slsafety/app  
scheme http  
secure false 
serverName localhost  
serverPort 8080 
servletPath /app  
userPrincipal <NULL> 
Headers 
accept */*  
accept-language zh-cn  
connection Keep-Alive  
host localhost:8080  
user-agent Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)  
Attributes 
org.apache.tapestry.Infrastructure <SingletonProxy for tapestry.Infrastructure(org.apache.tapestry.services.Infrastructure)>  


[ +/- ] Context 
HttpServlet
servletInfo  
servletName slsafety  

ServletContext
serverInfo Apache Tomcat/5.5.17  
version 2.4  
Attributes 
javax.servlet.context.tempdir E:\Eclipse\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\slsafety  
org.apache.catalina.WELCOME_FILES [Ljava.lang.String;@13dcd27  
org.apache.catalina.jsp_classpath /E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/classes/;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/antlr-2.7.6.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/asm-attrs.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/asm.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/cglib-2.1.3.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/commons-collections-3.1.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/commons-io-1.1.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/commons-logging-1.0.4.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/commons-proxy-1.0.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/dom4j-1.6.1.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/ehcache-1.2.3.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/hibernate3.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/hivemind-1.1.1.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/hivemind-lib-1.1.1.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/jta.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/log4j-1.2.11.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/proxool-0.8.3.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/spring-1.2.6.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/tapestry-annotations-4.1.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/tapestry-framework-4.1.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/tapestry-prop.jar;/E:/Eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/slsafety/WEB-INF/lib/tapestrying-hibernate.jar;/D:/WebSrv/Tomcat-5.5.17/common/classes/;/D:/WebSrv/Tomcat-5.5.17/common/i18n/tomcat-i18n-en.jar;/D:/WebSrv/Tomcat-5.5.17/common/i18n/tomcat-i18n-es.jar;/D:/WebSrv/Tomcat-5.5.17/common/i18n/tomcat-i18n-fr.jar;/D:/WebSrv/Tomcat-5.5.17/common/i18n/tomcat-i18n-ja.jar;/D:/WebSrv/Tomcat-5.5.17/common/lib/commons-codec-1.3.jar;/D:/WebSrv/Tomcat-5.5.17/common/lib/commons-el.jar;/D:/WebSrv/Tomcat-5.5.17/common/lib/commons-logging-api-1.0.4.jar;/D:/WebSrv/Tomcat-5.5.17/common/lib/jasper-compiler-jdt.jar;/D:/WebSrv/Tomcat-5.5.17/common/lib/jasper-compiler.jar;/D:/WebSrv/Tomcat-5.5.17/common/lib/jasper-runtime.jar;/D:/WebSrv/Tomcat-5.5.17/common/lib/javassist.jar;/D:/WebSrv/Tomcat-5.5.17/common/lib/jsp-api.jar;/D:/WebSrv/Tomcat-5.5.17/common/lib/mysql-connector-java-5.0.0-beta-bin.jar;/D:/WebSrv/Tomcat-5.5.17/common/lib/naming-factory-dbcp.jar;/D:/WebSrv/Tomcat-5.5.17/common/lib/naming-factory.jar;/D:/WebSrv/Tomcat-5.5.17/common/lib/naming-resources.jar;/D:/WebSrv/Tomcat-5.5.17/common/lib/ognl-2.6.9.jar;/D:/WebSrv/Tomcat-5.5.17/common/lib/oro-2.0.8.jar;/D:/WebSrv/Tomcat-5.5.17/common/lib/servlet-api.jar;/D:/WebSrv/Tomcat-5.5.17/bin/bootstrap.jar;/D:/Java/jdk1.5.0_06/lib/tools.jar;/D:/Java/jdk1.5.0_06/jre/lib/ext/dnsns.jar;/D:/Java/jdk1.5.0_06/jre/lib/ext/localedata.jar;/D:/Java/jdk1.5.0_06/jre/lib/ext/sunjce_provider.jar;/D:/Java/jdk1.5.0_06/jre/lib/ext/sunpkcs11.jar  
org.apache.catalina.resources org.apache.naming.resources.ProxyDirContext@7e5619  
org.apache.tapestry.Registry:slsafety org.apache.hivemind.impl.RegistryImpl@15c2843  


[ +/- ] Status 
tapestry.request.EnginePool
total count 0 

tapestry.page.PagePool
total count 0 

tapestry.parse.SpecificationSource
page specification count 2 
page specifications context:/WEB-INF/Home.page  
 classpath:/org/apache/tapestry/pages/Exception.page  
component specification count 10 
component specifications classpath:/org/apache/tapestry/components/If.jwc  
 classpath:/org/apache/tapestry/html/Describe.jwc  
 classpath:/org/apache/tapestry/components/Any.jwc  
 classpath:/org/apache/tapestry/link/ServiceLink.jwc  
 classpath:/org/apache/tapestry/components/Insert.jwc  
 classpath:/org/apache/tapestry/components/Delegator.jwc  
 classpath:/org/apache/tapestry/components/Foreach.jwc  
 classpath:/org/apache/tapestry/html/Shell.jwc  
 classpath:/org/apache/tapestry/html/RequestDisplay.jwc  
 classpath:/org/apache/tapestry/html/ExceptionDisplay.jwc  

tapestry.enhance.ComponentConstructorFactory
enhanced class count 12 
enhanced classes ComponentSpecification[componentClassName=null pageSpecification=true specificationLocation=context:/WEB-INF/Home.page allowBody=true allowInformalParameter=true]  
 ComponentSpecification[componentClassName=org.apache.tapestry.pages.Exception pageSpecification=true specificationLocation=classpath:/org/apache/tapestry/pages/Exception.page allowBody=true allowInformalParameter=true]  
 ComponentSpecification[componentClassName=org.apache.tapestry.components.IfBean pageSpecification=false specificationLocation=classpath:/org/apache/tapestry/components/If.jwc allowBody=true allowInformalParameter=true]  
 ComponentSpecification[componentClassName=org.apache.tapestry.components.Delegator pageSpecification=false specificationLocation=classpath:/org/apache/tapestry/components/Delegator.jwc allowBody=false allowInformalParameter=false]  
 ComponentSpecification[componentClassName=org.apache.tapestry.html.Shell pageSpecification=false specificationLocation=classpath:/org/apache/tapestry/html/Shell.jwc allowBody=true allowInformalParameter=false]  
 ComponentSpecification[componentClassName=org.apache.tapestry.components.Insert pageSpecification=false specificationLocation=classpath:/org/apache/tapestry/components/Insert.jwc allowBody=false allowInformalParameter=true]  
 ComponentSpecification[componentClassName=org.apache.tapestry.html.Describe pageSpecification=false specificationLocation=classpath:/org/apache/tapestry/html/Describe.jwc allowBody=false allowInformalParameter=false]  
 ComponentSpecification[componentClassName=org.apache.tapestry.html.RequestDisplay pageSpecification=false specificationLocation=classpath:/org/apache/tapestry/html/RequestDisplay.jwc allowBody=false allowInformalParameter=false]  
 ComponentSpecification[componentClassName=org.apache.tapestry.components.Any pageSpecification=false specificationLocation=classpath:/org/apache/tapestry/components/Any.jwc allowBody=true allowInformalParameter=true]  
 ComponentSpecification[componentClassName=org.apache.tapestry.components.Foreach pageSpecification=false specificationLocation=classpath:/org/apache/tapestry/components/Foreach.jwc allowBody=true allowInformalParameter=true]  
 ComponentSpecification[componentClassName=org.apache.tapestry.link.ServiceLink pageSpecification=false specificationLocation=classpath:/org/apache/tapestry/link/ServiceLink.jwc allowBody=true allowInformalParameter=true]  
 ComponentSpecification[componentClassName=org.apache.tapestry.html.ExceptionDisplay pageSpecification=false specificationLocation=classpath:/org/apache/tapestry/html/ExceptionDisplay.jwc allowBody=false allowInformalParameter=false]  

com.javaforge.tapestry.prop.PropertyAccessorSource
instantiated accessors 7 
accessor classes MultiKey[class $Home_0, user.work]  
 MultiKey[class $Home_0, sex]  
 MultiKey[class $Home_0, user.name]  
 MultiKey[class $Home_0, user]  
 MultiKey[class $Home_0, birthDate]  
 MultiKey[class $Home_0, userService.allUsers]  
 MultiKey[class $Home_0, user.isSuper]  

tapestry.parse.TemplateSource
parsed templates 4 
total template tokens 105 
total template characters 2436 
Parsed template token counts 
classpath:/org/apache/tapestry/pages/Exception.html 15 
classpath:/org/apache/tapestry/html/RequestDisplay.html 23 
classpath:/org/apache/tapestry/html/ExceptionDisplay.html 47 
context:/Home.html 20 

tapestry.ognl.ExpressionCache
cached expression count 32 
cached expressions index  
 exception.stackTrace  
 ''  
 exception.properties  
 ! last  
 true  
 browserLogLevel  
 dojoPath  
 dojoSource  
 beans.evenOdd.next  
 exception  
 context  
 exceptions  
 trace  
 @org.apache.tapestry.Tapestry@RESTART_SERVICE  
 activator  
 adapterFactory.getRenderableAdaptor(property.value)  
 'return toggleDisplay(\'excdisplay'+index+'\')'  
 exception.message  
 property  
 'excdisplay' + index  
 request.getSession(false) != null  
 assets.stylesheet  
 tapestrySource  
 property.name  
 reportStatusRenderer  
 last  
 exception.exceptionClassName  
 assetService  
 templateTag  
 request  
 false  


[ +/- ] System Properties 
JVM System Properties
awt.toolkit sun.awt.windows.WToolkit 
catalina.base E:\Eclipse\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 
catalina.home D:\WebSrv\Tomcat-5.5.17 
catalina.useNaming true 
common.loader ${catalina.home}/common/classes,${catalina.home}/common/i18n/*.jar,${catalina.home}/common/endorsed/*.jar,${catalina.home}/common/lib/*.jar 
file.encoding GBK 
file.encoding.pkg sun.io 
file.separator \ 
java.awt.graphicsenv sun.awt.Win32GraphicsEnvironment 
java.awt.printerjob sun.awt.windows.WPrinterJob 
java.class.path D:\WebSrv\Tomcat-5.5.17\bin\bootstrap.jar 
 D:\Java\jdk1.5.0_06\lib\tools.jar 
java.class.version 49.0 
java.endorsed.dirs D:\WebSrv\Tomcat-5.5.17\common\endorsed 
java.ext.dirs D:\Java\jdk1.5.0_06\jre\lib\ext 
java.home D:\Java\jdk1.5.0_06\jre 
java.io.tmpdir C:\DOCUME~1\NORTHS~1\LOCALS~1\Temp\ 
java.library.path D:\Java\jdk1.5.0_06\bin 
 . 
 C:\WINDOWS\system32 
 C:\WINDOWS 
 C:\WINDOWS\system32 
 C:\WINDOWS 
 C:\WINDOWS\System32\Wbem 
 D:\Java\jdk1.5.0_06\bin 
 D:\Program Files\MySQL\MySQL Server 5.0\bin 
 D:\Program Files\GTK2.0\bin 
java.naming.factory.initial org.apache.naming.java.javaURLContextFactory 
java.naming.factory.url.pkgs org.apache.naming 
java.runtime.name Java(TM) 2 Runtime Environment, Standard Edition 
java.runtime.version 1.5.0_06-b05 
java.specification.name Java Platform API Specification 
java.specification.vendor Sun Microsystems Inc. 
java.specification.version 1.5 
java.vendor Sun Microsystems Inc. 
java.vendor.url http://java.sun.com/ 
java.vendor.url.bug http://java.sun.com/cgi-bin/bugreport.cgi 
java.version 1.5.0_06 
java.vm.info mixed mode, sharing 
java.vm.name Java HotSpot(TM) Client VM 
java.vm.specification.name Java Virtual Machine Specification 
java.vm.specification.vendor Sun Microsystems Inc. 
java.vm.specification.version 1.0 
java.vm.vendor Sun Microsystems Inc. 
java.vm.version 1.5.0_06-b05 
line.separator  
org.apache.tapestry.disable-caching true 
os.arch x86 
os.name Windows XP 
os.version 5.1 
package.access sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans. 
package.definition sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper. 
path.separator ; 
server.loader ${catalina.home}/server/classes,${catalina.home}/server/lib/*.jar 
shared.loader ${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar 
sun.arch.data.model 32 
sun.boot.class.path D:\Java\jdk1.5.0_06\jre\lib\rt.jar 
 D:\Java\jdk1.5.0_06\jre\lib\i18n.jar 
 D:\Java\jdk1.5.0_06\jre\lib\sunrsasign.jar 
 D:\Java\jdk1.5.0_06\jre\lib\jsse.jar 
 D:\Java\jdk1.5.0_06\jre\lib\jce.jar 
 D:\Java\jdk1.5.0_06\jre\lib\charsets.jar 
 D:\Java\jdk1.5.0_06\jre\classes 
sun.boot.library.path D:\Java\jdk1.5.0_06\jre\bin 
sun.cpu.endian little 
sun.cpu.isalist  
sun.desktop windows 
sun.io.unicode.encoding UnicodeLittle 
sun.jnu.encoding GBK 
sun.management.compiler HotSpot Client Compiler 
sun.os.patch.level Service Pack 2 
tomcat.util.buf.StringCache.byte.enabled true 
user.country CN 
user.dir E:\Eclipse 
user.home C:\Documents and Settings\northstar 
user.language zh 
user.name northstar 
user.timezone Asia/Shanghai 
user.variant  


Linuxboy 2006-12-14
不知原因何在,请看看。
谢谢!
tapestry 2006-12-14
大体看了下,应该是UserService的构造函数不是默认的无参构造函数,你看看是不是定义了有参的构造函数,没写默认的。
还不行,可以把代码粘贴上来。
Linuxboy 2006-12-15
我的代码和配置如下:
UserService.java
package org.example.service;

import java.util.List;

import org.example.bo.User;

import com.javaeye.tapestrying.hibernate.Transactional;

@Transactional
public interface UserService {
	@Transactional(commit = true)
	public void create(User user);
	public List<User> getAllUsers();
	@Transactional(commit = true)
	public void update(User user);
        @Transactional(commit = true)
	public void delete (User user);
	public User findById(Long id);

}


UserServiceImpl.java
package org.example.service;

import java.util.List;

import org.example.bo.User;
import org.example.dao.UserDAO;

public class UserServiceImpl implements UserService {

	private UserDAO _userDAO;
	
	public void setUserDAO(UserDAO userDAO){
		_userDAO = userDAO;
	}
	public void create(User user) {
		_userDAO.create(user);

	}

	public void delete(User user) {
		_userDAO.delete(user);

	}

	public User findById(Long id) {
		
		return _userDAO.findById(id);
	}

	public List<User> getAllUsers() {
		
		return _userDAO.getAllUsers();
	}

	public void update(User user) {
		_userDAO.update(user);

	}

}


AbstractDAOImpl.java
package org.example.dao;

import org.hibernate.Session;

public class AbstractDAOImpl {

	private Session _session;
	
	
	public Session getSession(){
		return _session;
	}
	
	
	public void setSession(Session session){
		_session = session;
	}
}


UserDAO.java
package org.example.dao;

import java.util.List;

import org.example.bo.User;




public interface UserDAO {
	
	public void create(User user);
	public List<User> getAllUsers();
	
	public void update(User user);
	public void delete (User user);
	public User findById(Long id);
}


UserDAOHibernateImpl.java
package org.example.dao;

import java.util.List;

import org.example.bo.User;

public class UserDAOHibernateImpl extends AbstractDAOImpl implements UserDAO {

	public void create(User user) {
		getSession().save(user);
		
	}

	public void delete(User user) {
		getSession().delete(user);
		
	}

	@SuppressWarnings("unchecked")
	public List<User> getAllUsers() {
		
		return getSession().createCriteria(User.class).list();
	}

	public void update(User user) {
		getSession().update(user);
		
	}

	public User findById(Long id) {
		return (User) getSession().load(User.class, id);
	}
	

}


配置example.dao.xml
<?xml version="1.0" encoding="UTF-8"?>
<module id="example.dao" version="1.0.0">
	<service-point id="UserDAO" interface="org.example.dao.UserDAO">
		<invoke-factory>
			<construct class="org.example.dao.UserDAOHibernateImpl">
				<set-object property="session"
					value="infrastructure:session" />
			</construct>
		</invoke-factory>
	</service-point>
	<service-point id="UserService" interface="org.example.service.UserService">
		<invoke-factory>
			<construct class="org.example.service.UserServiceImpl">
				<service>UserDAO</service>
			</construct>
		</invoke-factory>
		<interceptor
			service-id="com.javaeye.tapestrying.TransactionInterceptor" />
	</service-point>
</module>


引用:
@InjectObject("service:example.dao.UserService")
public abstract UserService getUserService();
tapestry 2006-12-15
不好意思,是我的教程错误了,
<construct class="org.example.service.UserServiceImpl"> 
                <service>UserDAO</service> 
</construct> 
这种写法是通过构造函数注入的,改成下边的试试
<construct class="org.example.service.UserServiceImpl"> 
        <set-service property="userDAO" service-id="example.dao.UserDAO"/>
</construct> 
Global site tag (gtag.js) - Google Analytics