-
Jan 23rd, 2008, 01:15 AM
#1
spring transaction error,help!
where does the mistake happen?
applicatonContext.xml:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
<property name="dataSource">
<ref bean="datasource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql" >
true
</prop >
</props>
</property>
<property name="mappingResources">
<list>
<value>com/zw/hibernate/TFile.hbm.xml</value></list>
</property>
<property name="lobHandler">
<ref local="lobHandler" />
</property>
</bean>
<bean id="datasource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url"
value="jdbc:mysql://localhost:3306/skybase">
</property>
<property name="username" value="root"></property>
<property name="password" value="accp"></property>
</bean>
<bean id="TFileDAO" class="com.zw.hibernate.TFileDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="lobHandler"
class="org.springframework.jdbc.support.lob.Defaul tLobHandler"
abstract="false" lazy-init="true" autowire="default"
dependency-check="default">
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.Hibernat eTransactionManager"
abstract="false" lazy-init="default" autowire="default"
dependency-check="default">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<bean id="txProxyTemplate"
class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean"
abstract="false" lazy-init="default" autowire="default"
dependency-check="default">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="save">PROPAGATION_REQUIRED</prop>
<prop key="write">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
<property name="target">
<ref bean="fileService"/>
</property>
<property name="proxyTargetClass" value="true"></property>
</bean>
<bean id="fileService" class="com.zw.hibernate.FileServiceImpl">
<property name="tfileDAO">
<ref bean="TFileDAO"/>
</property>
</bean>
</beans>
FileServiceImpl.java:
public class FileServiceImpl {
private TFileDAO tfileDAO;
public String getFileName(String fileId) {
return tfileDAO.findById(fileId).getFileName();
}
public void save(FileActionForm fileForm) {
TFile tfile=new TFile();
try{
tfile.setFileContent(fileForm.getFileContent().get FileData());
}
catch(FileNotFoundException ex)
{
throw new RuntimeException(ex);
}
catch(IOException ex)
{
throw new RuntimeException(ex);
}
tfile.setFileName(fileForm.getFileName());
tfile.setRemark(fileForm.getRemark());
tfileDAO.save(tfile);
}
public void write(OutputStream os, String fileId) {
TFile tfile = tfileDAO.findById(fileId);
try
{
os.write(tfile.getFileContent());
os.flush();
}
catch (IOException ex)
{
throw new RuntimeException(ex);
}
}
public List getAllFile()
{
return tfileDAO.findAll();
}
public TFileDAO getTfileDAO() {
return tfileDAO;
}
public void setTfileDAO(TFileDAO tfileDAO) {
this.tfileDAO = tfileDAO;
}
public byte[] getFileContent(String fileId) {
return tfileDAO.findById(fileId).getFileContent();
}
}
when i start up the "tomcat",the errors happen:
严重: StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'txProxyTemplate' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError
Caused by: java.lang.NoClassDefFoundError
could you tell me where the errors?thank you!
-
Jan 23rd, 2008, 02:15 AM
#2
Please use [ code][/code ] tags when posting code, that way your code remains readable.
Your error is a missing jar on your classpath, which I cannot determine as you didn't post the full stacktrace. However the 'java.lang.NoClassDefFoundError' should trigger you that a certain class cannot be found and that you have a incomplete classpath.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules