浏览 7723 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2006-06-28
由于代码过多,我只把最主要的贴出来。 hivemind.xml <?xml version="1.0" encoding="gb2312"?> <module id="com.HelloWorld" version="1.0.0"> <implementation service-id="hivemind.lib.DefaultSpringBeanFactoryHolder"> <invoke-factory> <construct autowire-services="false" class="com.HelloWorld.TapestrySpringBeanFactoryHolderImpl"> <event-listener service-id="hivemind.ShutdownCoordinator" /> <set-object property="context" value="service:tapestry.globals.WebContext" /> </construct> </invoke-factory> </implementation> </module> applicationContext.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close"> <property name="driverClassName"> <value>org.gjt.mm.mysql.Driver</value> </property> <property name="url"> <value>jdbc:mysql://localhost:3306/test</value> </property> <property name="username"> <value></value> </property> <property name="password"> <value></value> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref local="dataSource" /> </property> <property name="mappingResources"> <list> <value>com/HelloWorld/Users.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean> <bean id="iUtilDao" class="com.HelloWorld.UtilDao"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <!-- Begin ShopService --> <bean id="utilServiceTarget" class="com.HelloWorld.UtilServiceImpl"> <property name="utilDao"> <ref local="iUtilDao"/> </property> </bean> <bean id="UtilService" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"> <value>com.HelloWorld.UtilService</value> </property> <property name="interceptorNames"> <list> <value>utilServiceTarget</value> </list> </property> </bean> </beans> NewHelloWorld.xml <?xml version="1.0" encoding="gb2312"?> <module id="com.HelloWorld" version="1.0.0"> <implementation service-id="hivemind.lib.DefaultSpringBeanFactoryHolder"> <invoke-factory> <construct autowire-services="false" class="com.HelloWorld.TapestrySpringBeanFactoryHolderImpl"> <event-listener service-id="hivemind.ShutdownCoordinator" /> <set-object property="context" value="service:tapestry.globals.WebContext" /> </construct> </invoke-factory> </implementation> </module> web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>NewHelloWorld</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <filter> <filter-name>redirect</filter-name> <filter-class>org.apache.tapestry.RedirectFilter</filter-class> </filter> <filter-mapping> <filter-name>redirect</filter-name> <url-pattern>/</url-pattern> </filter-mapping> <servlet> <servlet-name>NewHelloWorld</servlet-name> <servlet-class>org.apache.tapestry.ApplicationServlet</servlet-class> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>NewHelloWorld</servlet-name> <url-pattern>/app</url-pattern> </servlet-mapping> </web-app> SpringContextFactory.java package com.HelloWorld; import javax.servlet.ServletContext; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; public class SpringContextFactory { private ServletContext servletContext; private WebApplicationContext appContext; public WebApplicationContext getAppContext() { return appContext; } public ServletContext getServletContext() { return servletContext; } public void setServletContext(ServletContext servletContext) { this.servletContext = servletContext; appContext = WebApplicationContextUtils.getWebApplicationContext (getServletContext()); } } TapestrySpringBeanFactoryHolderImpl.java package com.HelloWorld; import org.apache.hivemind.events.RegistryShutdownListener; import org.apache.hivemind.lib.impl.SpringBeanFactoryHolderImpl; import org.apache.tapestry.web.WebContext; import org.springframework.beans.factory.BeanFactory; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.web.context.WebApplicationContext; public class TapestrySpringBeanFactoryHolderImpl extends SpringBeanFactoryHolderImpl implements RegistryShutdownListener { private WebContext context; public BeanFactory getBeanFactory() { if(super.getBeanFactory()==null) { super.setBeanFactory(getWebApplicationContext(this.getContext())); } return super.getBeanFactory(); } public void registryDidShutdown() { ((ConfigurableApplicationContext) super.getBeanFactory()).close(); } private static WebApplicationContext getWebApplicationContext(WebContext wc) { Object obj = wc .getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (obj == null) { return null; } if (obj instanceof RuntimeException) { throw (RuntimeException) obj; } if (obj instanceof Error) { throw (Error) obj; } if (!(obj instanceof WebApplicationContext)) { throw new IllegalStateException("获取不到WebApplicationContext对象:" + obj); } return (WebApplicationContext) obj; } public WebContext getContext() { return context; } public void setContext(WebContext context) { this.context = context; } } 我在启动tomcat时 它说 严重:Context:[/NewHelloWorld] startup faile due to previous errors. 响应的。JAR文件也导入到lib文件夹下 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2006-06-29
where is the previous errors?
|
|
返回顶楼 | |
发表时间:2006-06-29
还是没解决,那位能帮一下忙!
|
|
返回顶楼 | |
发表时间:2006-06-30
兄弟,去http://howardlewisship.com/tapestry-javaforge/tapestry-spring/下载一个包吧。
|
|
返回顶楼 | |
发表时间:2006-07-03
把model去掉换成普通的应用呢?
Log也贴出来看下吧 |
|
返回顶楼 | |
发表时间:2006-07-05
如果把web.xml
换成 <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>NewHelloWorld</display-name> </filter> <filter-mapping> <filter-name>redirect</filter-name> <url-pattern>/</url-pattern> </filter-mapping> <servlet> <servlet-name>NewHelloWorld</servlet-name> <servlet-class>org.apache.tapestry.ApplicationServlet</servlet-class> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>NewHelloWorld</servlet-name> <url-pattern>/app</url-pattern> </servlet-mapping> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/classes/applicationContext.xml</param-value> </context-param> <servlet> <servlet-name>context</servlet-name> <servlet-class> org.springframework.web.context.ContextLoaderServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>context</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> </web-app> 时 启动TOMCAT时没错 但打开URL时 interface org.springframework.web.context.WebApplicationContext.ROOT 这一行显示 org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'iUtilDao' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Class that bean class [com.HelloWorld.UtilDao] depends on not found; nested exception is java.lang.NoClassDefFoundError: org/hibernate/Session 上面错误说的好象很明白 也找了N个人查看,当看了代码之后,找不出具体错误? 希望各位GG帮忙看一下,上面的代码已贴的很详细。 至于楼上各位朋友所说的 tapestry-spring.jar没找到,还希望给个具体位置。 Giv3n所说的:把model去掉换成普通的应用呢? 在下确实不知怎么换,还希望明确点,因为在下对T还是初学者。 查过LOG, 严重: Error listenerStart 2006-6-29 22:23:46 org.apache.catalina.core.StandardContext start 严重: Context [/NewHelloWorld] startup failed due to previous errors 2006-6-29 22:24:31 org.apache.coyote.http11.Http11BaseProtocol start 就这么一点错误! 希望各位GG,能解决一下问题。 |
|
返回顶楼 | |
发表时间:2006-07-25
我看错了。sorry
web.xml里面的 ContextLoaderListener 还是要加上的。 hivemind.xml还是别用gb2312吧。 <?xml version="1.0"?> <module id="NewHelloWorld.service" version="4.1.0"> <implementation service-id="hivemind.lib.DefaultSpringBeanFactoryHolder"> <invoke-factory> <construct autowire-services="false" class="com.HelloWorld.TapestrySpringBeanFactoryHolderImpl"> <event-listener service-id="hivemind.ShutdownCoordinator" /> <set-object property="context" value="service:tapestry.globals.WebContext" /> </construct> </invoke-factory> </implementation> </module> 另外,你的SpringContextFactory改成extends org.springframework.web.context.support.WebApplicationContextUtils并覆盖他的getWebApplicationContext(WebContext wc)和WebApplicationContext getRequiredWebApplicationContext(WebContext wc)吧,不用在TapestrySpringBeanFactoryHolderImpl里写成private。 |
|
返回顶楼 | |
发表时间:2006-07-31
为什么要加个i
DAO代码在哪里帖出来看看 |
|
返回顶楼 | |