问题描述
我使用eclipse学习实体bean的开发,按照书上一步一步的来的,没有错误,可是就是不能实现部署,想请教一下什么原因?1.persistence.xml[code=XM]<?xmlversion="1.0"encoding="UTF-8"?><persistence><persistence-unitname="myentity"><jta-data-source>java:/MySqlDS</jta-data-source><properties><propertyname="hibernate.hbm2ddl.auto"value="update"/></properties></persistence-unit></persistence>[/code]2.mysql-ds.xml[code=XM]<?xmlversion="1.0"encoding="UTF-8"standalone="no"?><datasources><local-tx-datasource><jndi-name>MySqlDS</jndi-name><connection-url>jdbc:mysql://localhost:3306/seamdemo</connection-url><driver-class>com.mysql.jdbc.Driver</driver-class><user-name>root</user-name><password>root</password><exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name><metadata><type-mapping>mySQL</type-mapping></metadata></local-tx-datasource></datasources>[/code]3.POJO(Student.class)[code=Jav]packageedu.ujs.entity;//Generated2011-2-2011:59:47byHibernateTools3.4.0.CR1importjava.io.Serializable;importjavax.persistence.Column;importjavax.persistence.Entity;importjavax.persistence.GeneratedValue;importstaticjavax.persistence.GenerationType.IDENTITY;importjavax.persistence.Id;importjavax.persistence.Table;/***Studentgeneratedbyhbm2java*/@Entity@Table(name="student",catalog="seamdemo")publicclassStudentimplementsSerializable{privateIntegerstudentId;privateStringstudentName;privateShortstudentAge;publicStudent(){}publicStudent(StringstudentName){this.studentName=studentName;}publicStudent(StringstudentName,ShortstudentAge){this.studentName=studentName;this.studentAge=studentAge;}@Id@GeneratedValue(strategy=IDENTITY)@Column(name="studentId",unique=true,nullable=false)publicIntegergetStudentId(){returnthis.studentId;}publicvoidsetStudentId(IntegerstudentId){this.studentId=studentId;}@Column(name="studentName",nullable=false,length=25)publicStringgetStudentName(){returnthis.studentName;}publicvoidsetStudentName(StringstudentName){this.studentName=studentName;}@Column(name="studentAge")publicShortgetStudentAge(){returnthis.studentAge;}publicvoidsetStudentAge(ShortstudentAge){this.studentAge=studentAge;}}[/code]4.实体bean的interface[code=Jav]packageedu.ujs.entity;publicinterfaceIStudentHome{publicabstractvoidpersist(StudenttransientInstance);publicabstractvoidremove(StudentpersistentInstance);publicabstractStudentmerge(StudentdetachedInstance);publicabstractStudentfindById(Integerid);}[/code]5.实体bean的class[code=Jav]packageedu.ujs.entity;//Generated2011-2-2011:59:48byHibernateTools3.4.0.CR1importjavax.ejb.Remote;importjavax.ejb.Stateless;importjavax.persistence.EntityManager;importjavax.persistence.PersistenceContext;importorg.apache.commons.logging.Log;importorg.apache.commons.logging.LogFactory;/***HomeobjectfordomainmodelclassStudent.*@seeedu.ujs.entity.Student*@authorHibernateTools*/@Stateless@Remote({IStudentHome.class})publicclassStudentHomeimplementsIStudentHome{privatestaticfinalLoglog=LogFactory.getLog(StudentHome.class);@PersistenceContextprivateEntityManagerentityManager;/*(non-Javadoc)*@seeedu.ujs.entity.IStudentHome#persist(edu.ujs.entity.Student)*/publicvoidpersist(StudenttransientInstance){log.debug("persistingStudentinstance");try{entityManager.persist(transientInstance);log.debug("persistsuccessful");}catch(RuntimeExceptionre){log.error("persistfailed",re);throwre;}}/*(non-Javadoc)*@seeedu.ujs.entity.IStudentHome#remove(edu.ujs.entity.Student)*/publicvoidremove(StudentpersistentInstance){log.debug("removingStudentinstance");try{entityManager.remove(persistentInstance);log.debug("removesuccessful");}catch(RuntimeExceptionre){log.error("removefailed",re);throwre;}}/*(non-Javadoc)*@seeedu.ujs.entity.IStudentHome#merge(edu.ujs.entity.Student)*/publicStudentmerge(StudentdetachedInstance){log.debug("mergingStudentinstance");try{Studentresult=entityManager.merge(detachedInstance);log.debug("mergesuccessful");returnresult;}catch(RuntimeExceptionre){log.error("mergefailed",re);throwre;}}/*(non-Javadoc)*@seeedu.ujs.entity.IStudentHome#findById(java.lang.Integer)*/publicStudentfindById(Integerid){log.debug("gettingStudentinstancewithid:"+id);try{Studentinstance=entityManager.find(Student.class,id);log.debug("getsuccessful");returninstance;}catch(RuntimeExceptionre){log.error("getfailed",re);throwre;}}}[/code]1,2应该是没有什么问题的,3,4,5我检查了好几遍,不知道问题出在哪里?
解决方案
解决方案二:
解决办法:原来我测试的时候,eclipse是可以自动部署的,不知道现在为什么不可以了,所以解决的办法就是手工部署,