Java开发案例全程实录 欣想商城部署失败
发表在JavaWeb图书答疑 2016-12-21
是否精华
版块置顶:

报错信息如下,不知道是为什么?跟老师请教下。
我用的是myeclipse5.5.1 sqlserver2000。已经用上你们最新的jar包了。

2016-12-21 16:47:30 org.springframework.web.servlet.FrameworkServlet initServletBean

严重: Context initialization failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/config/dao-config.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.component.PojoComponentTuplizer]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)

at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)

at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)

at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)

at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)

at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)

at javax.servlet.GenericServlet.init(GenericServlet.java:212)

at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)

at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)

at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956)

at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230)

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)

at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)

at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)

at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)

at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)

at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)

at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)

at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)

at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)

at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)

at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)

at org.apache.catalina.core.StandardService.start(StandardService.java:448)

at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)

at org.apache.catalina.startup.Catalina.start(Catalina.java:552)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)


2016-12-21 16:45:05编辑
分享到:
精彩评论 32
herocx
学分:29 LV2
2016-12-22
11L

<?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">

<property name="driverClassName"

value="com.microsoft.jdbc.sqlserver.SQLServerDriver" />

<property name="url"

value="jdbc:microsoft:sqlserver://172.18.0.242:1433;DatabaseName=db_shop" />

<property name="username" value="sa"/>

<property name="password" value="xibc.35"/>

</bean>

<bean id="sessionFactory"

class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

<property name="dataSource">

<ref local="dataSource" />

</property>

<property name="mappingDirectoryLocations">

<list>

<value>classpath:com/lzw/model</value>

</list>

</property>

<property name="hibernateProperties">

<props>

<prop key="hibernate.dialect">

org.hibernate.dialect.SQLServerDialect

</prop>

<prop key="hibernate.show_sql">false</prop>

</props>

</property>

</bean>

<bean id="dao" class="com.lzw.dao.Dao">

<property name="sessionFactory">

<ref local="sessionFactory" />

</property>

</bean>

<bean id="transactionManager"

class="org.springframework.orm.hibernate3.HibernateTransactionManager">

<property name="sessionFactory">

<ref local="sessionFactory" />

</property>

</bean>

<bean id="daoProxyFactory"

class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">

<property name="proxyTargetClass" value="true" />

<property name="target">

<ref local="dao" />

</property>

<property name="transactionManager">

<ref local="transactionManager" />

</property>

<property name="transactionAttributes">

<props>

<prop key="insert*">PROPAGATION_REQUIRED</prop>

<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>

</props>

</property>

</bean>

</beans>


herocx
学分:29 LV2
silence雪
学分:378 LV5
2016-12-22
13L

你好:

        在dao-config.xml中,找到:<value>classpath:com/lzw/model</value>这一行

改为 <value>classpath:/com/lzw/model</value> ,注意英文输入法半角输入“ / ”,保存后重新启动项目

herocx
学分:29 LV2
2016-12-22
14L

你好

改完后重新deploy,再运行,报错如下


2016-12-22 13:29:54 org.springframework.web.servlet.FrameworkServlet initServletBean

严重: Context initialization failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/config/dao-config.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.component.PojoComponentTuplizer]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)

at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)

at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)

at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)

at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)

at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)

at javax.servlet.GenericServlet.init(GenericServlet.java:212)

at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)

at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)

at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956)


silence雪
学分:378 LV5
2016-12-22
15L

把 com.lzw.dao包下的Dao.java 发一下看看。

herocx
学分:29 LV2
2016-12-22
16L

package com.lzw.dao;

import java.util.HashMap;

import java.util.Iterator;

import java.util.List;

import java.util.Map;

import org.springframework.dao.DataAccessException;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.lzw.form.ModifyMemberForm;

import com.lzw.model.TbBbs;

import com.lzw.model.TbGoods;

import com.lzw.model.TbManager;

import com.lzw.model.TbMember;

import com.lzw.model.TbOrder;

import com.lzw.model.TbSubType;

import com.lzw.model.TbSuperType;

import com.lzw.model.VGoods;

public class Dao extends HibernateDaoSupport {

// 获取特价商品

public List getShowSaleGoodsList() {

return getHibernateTemplate().find(

"from TbGoods where sale=1 order by INTime desc");

}

// 获取新品

public List getShowNewGoodsList() {

return getHibernateTemplate().find(

"from TbGoods where newGoods=1 order by INTime desc");

}

// 获取单个商品信息

public TbGoods getGoods(Long id) {

return (TbGoods) getHibernateTemplate().get(TbGoods.class, id);

}


public List getGoodsByType(Integer type) {

return getHibernateTemplate()

.find("from VGoods where id.subId=" + type);

}


public List getGoodsByQuery(String query) {

System.out.println(query+"\to");

return getHibernateTemplate().find(query);

}


// 获取用户

public TbMember getUser(String username, String pwd) {

List list = null;

TbMember user = null;

list = getHibernateTemplate().find(

"from TbMember where userName='" + username + "' and freeze=0");

if (list.size() > 0) {

user = (TbMember) list.get(0);

if (pwd != null && !user.getPassWord().equals(pwd)) {

user = null;

}

}

return user;

}


// 获取公告

public List getPlacard() {

return getHibernateTemplate().find("from TbBbs order by INTime desc");

}


// 获取指定公告

public TbBbs getPlacard(Integer id) {

return (TbBbs) getHibernateTemplate().get(TbBbs.class, id);

}


public List getSellSort() {

List list = getHibernateTemplate()

.find(

"select id.goodsId,id.goodsName from"

+ " VOrderDetail group by id.goodsId,id.goodsName order by count(id.number) desc");

return list;

}


herocx
学分:29 LV2
2016-12-22
17L

// 获取商品类别列表

public Map getTypeList() {

Map model = new HashMap();

List types = getHibernateTemplate()

.find(

"select id.id,id.superType from VType group by id.id,id.superType");

Iterator iterator = types.iterator();

while (iterator.hasNext()) {

Object[] type = (Object[]) iterator.next();

List subList = getHibernateTemplate().find(

"from VType where id.id='" + type[0] + "'");

model.put(type[1], subList);

}

return model;

}

// 获取搜索类型

public List getSearchClassify() {

return getHibernateTemplate()

.find(

"select id.id,id.superType from VType group by id.id,id.superType order by id.superType");

}


public TbSuperType getSuperType(Integer id) {

return (TbSuperType) getHibernateTemplate().get(TbSuperType.class, id);

}

// 修改并更新用户信息

public void updateUserInfo(ModifyMemberForm form) {

TbMember oldUser = (TbMember) getHibernateTemplate().get(

TbMember.class, new Integer(form.getId()));

oldUser.setAddress(form.getAddress());

oldUser.setCardNo(form.getCardno());

oldUser.setCardType(form.getCardtype());

oldUser.setCity(form.getCity());

oldUser.setEmail(form.getEmail());

oldUser.setPassWord(form.getPwd());

oldUser.setPostcode(form.getPostcode());

oldUser.setTel(form.getTel());

oldUser.setTrueName(form.getTruename());

getHibernateTemplate().update(oldUser);

}


public List getOrder(String username) {

return getHibernateTemplate().find(

"from TbOrder where username='" + username + "'");

}


public List getOrders() {

return getHibernateTemplate().loadAll(TbOrder.class);

}


public TbOrder getOrder(Long id) {

return (TbOrder) getHibernateTemplate().get(TbOrder.class, id);

}


// 获取会员折扣

public float getUserRebate(String username) {

float rebate = 1;

List list = getHibernateTemplate().find(

"select id.rebate from VMember where username='" + username

+ "'");

if (list.size() > 0) {

System.out.println(list.get(0));

rebate = Float.valueOf(list.get(0) + "").floatValue();

}

return rebate;

}


// 获得TbRebate表数据等级为ID的记录

public int getGrade(double amount) {

int grade = 0;

List list = getHibernateTemplate().find(

"select grade from TbRebate where amount<" + amount);

if (list.size() > 0) {

grade = Integer.valueOf(list.get(0) + "");

}

return grade;

}


public boolean insertObject(Object obj) {

try {

getHibernateTemplate().save(obj);

return true;

} catch (DataAccessException e) {

e.printStackTrace();

return false;

}

}


herocx
学分:29 LV2
2016-12-22
18L

// 在事物中完成订单保存和会员的更新

public void insertObject(TbMember user, TbOrder order) {

getHibernateTemplate().saveOrUpdate(user);

getHibernateTemplate().save(order);

}


// 获取管理员

public TbManager getManager(String manager) {

List list = getHibernateTemplate().find(

"from TbManager where manager='" + manager + "'");

TbManager user = null;

if (list.size() > 0)

user = (TbManager) list.get(0);

return user;

}


public List getSuperTypes() {

return getHibernateTemplate().find("from TbSuperType order by id Desc");

}


public List getSubTypes() {

return getHibernateTemplate().find("from VType order by id.id Desc");

}


public boolean delSuperType(String ids) {

String sql = "delete from TbSuperType Where id in(" + ids + ")";

boolean del = false;

try {

getHibernateTemplate().bulkUpdate(sql);

del = true;

} catch (Exception e) {

del = false;

}

return del;

}


public TbSuperType getSuperType(String typename) {

TbSuperType tst = null;

List list = getHibernateTemplate().find(

"from TbSuperType where typeName='" + typename + "'");

if (list.size() > 0)

tst = (TbSuperType) list.get(0);

return tst;

}


public boolean delSubType(String subTypeID) {

String sql = "delete from TbSubType Where id in(" + subTypeID + ")";

boolean del = false;

try {

getHibernateTemplate().bulkUpdate(sql);

del = true;

} catch (Exception e) {

del = false;

}

return del;

}


public TbSubType getSubType(String typename) {

TbSubType tst = null;

List list = getHibernateTemplate().find(

"from TbSubType where typeName='" + typename + "'");

if (list.size() > 0)

tst = (TbSubType) list.get(0);

return tst;

}


herocx
学分:29 LV2
2016-12-22
19L

public TbSubType getSubType(Integer typeId) {

return (TbSubType) getHibernateTemplate().get(TbSubType.class, typeId);

}


public void insertOrUpdate(TbGoods form) {

getHibernateTemplate().saveOrUpdate(form);

}


public VGoods getVGoods(Long id) {

return (VGoods) getHibernateTemplate().get(VGoods.class, id);

}


public void delObject(Object obj) {

getHibernateTemplate().delete(obj);

}


public List getMembers() {

return getHibernateTemplate().loadAll(TbMember.class);

}


public int updateFreeze(int id) {

String sql = "update TbMember set freeze=1 where ID=" + id;

return getHibernateTemplate().bulkUpdate(sql);

}


public int updateThaw(int id) {

String sql = "update TbMember set freeze=0 where ID=" + id;

return getHibernateTemplate().bulkUpdate(sql);

}


public TbMember getMember(Integer id) {

return (TbMember) getHibernateTemplate().get(TbMember.class, id);

}


public int updateEnforce(int id) {

String sql = "update TbOrder set enforce=1 where orderID=" + id;

return getHibernateTemplate().bulkUpdate(sql);

}


public boolean delPlacard(String id) {

String sql = "delete from TbBbs Where id in(" + id + ")";

boolean del = false;

try {

getHibernateTemplate().bulkUpdate(sql);

del = true;

} catch (Exception e) {

del = false;

}

return del;

}


public TbBbs getBBS(String title) {

List list = getHibernateTemplate().find(

"from TbBbs where title='" + title + "'");

TbBbs tbb = null;

if (list.size() > 0)

tbb = (TbBbs) list.get(0);

return tbb;

}

}


silence雪
学分:378 LV5
2016-12-22
20L

你把项目进行压缩,当附件传给我,帮你测试一下吧。

首页上一页 1234 下一页尾页 32 条记录 2/4页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照