大鱼

EJB3常见异常及解决

缺少StandAlone的三个Jar包

customer Bill Burker
Exception in thread "main" java.lang.NoClassDefFoundError: Lorg/jboss/invocation/Invoker;
 at java.lang.Class.getDeclaredFields0(Native Method)
 at java.lang.Class.privateGetDeclaredFields(Unknown Source)
 at java.lang.Class.getDeclaredField(Unknown Source)
 at java.io.ObjectStreamClass.getDeclaredSUID(Unknown Source)
 at java.io.ObjectStreamClass.access$700(Unknown Source)
 at java.io.ObjectStreamClass$2.run(Unknown Source)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.io.ObjectStreamClass.<init>(Unknown Source)
 at java.io.ObjectStreamClass.lookup(Unknown Source)
 at java.io.ObjectStreamClass.initNonProxy(Unknown Source)
 at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
 at java.io.ObjectInputStream.readClassDesc(Unknown Source)
 at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
 at java.io.ObjectInputStream.readObject0(Unknown Source)
 at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
 at java.io.ObjectInputStream.readSerialData(Unknown Source)
 at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
 at java.io.ObjectInputStream.readObject0(Unknown Source)
 at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
 at java.io.ObjectInputStream.readSerialData(Unknown Source)
 at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
 at java.io.ObjectInputStream.readObject0(Unknown Source)
 at java.io.ObjectInputStream.readObject(Unknown Source)
 at org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:107)
 at java.io.ObjectInputStream.readExternalData(Unknown Source)
 at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
 at java.io.ObjectInputStream.readObject0(Unknown Source)
 at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
 at java.io.ObjectInputStream.readSerialData(Unknown Source)
 at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
 at java.io.ObjectInputStream.readObject0(Unknown Source)
 at java.io.ObjectInputStream.readObject(Unknown Source)
 at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:128)
 at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:66)
 at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:279)
 at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:143)
 at org.jboss.remoting.Client.invoke(Client.java:525)
 at org.jboss.remoting.Client.invoke(Client.java:488)
 at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:41)
 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
 at org.jboss.aspects.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:34)
 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
 at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:46)
 at $Proxy1.createProxy(Unknown Source)
 at org.jboss.ejb3.JndiProxyFactory.getObjectInstance(JndiProxyFactory.java:52)
 at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
 at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1125)
 at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1142)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:705)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
 at javax.naming.InitialContext.lookup(Unknown Source)
 at com.lyh.ejb3.clients.TravelAgentShell.getAgent(TravelAgentShell.java:46)
 at com.lyh.ejb3.clients.TravelAgentShell.customer(TravelAgentShell.java:156)
 at com.lyh.ejb3.clients.TravelAgentShell.processCommand(TravelAgentShell.java:115)
 at com.lyh.ejb3.clients.TravelAgentShell.shell(TravelAgentShell.java:83)
 at com.lyh.ejb3.clients.TravelAgentShell.main(TravelAgentShell.java:36)

 


Hibernate EntityManager 文档描述如下:
If no persistence.xml with the correct
name are found or if the expected persistence provider is not found, a PersistenceException is raised.

数据库没有启动时会出现如下异常,persistence.xml配置错误也会出现,如帐户,密码错误
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
 at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:217)
 at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
 at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
 at com.titan.clients.StandaloneClient.main(StandaloneClient.java:16)
Caused by: org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
 at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
 at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
 at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:397)
 at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:111)
 at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1928)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
 at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:631)
 at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:760)
 at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:151)
 at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:205)
 ... 3 more
加入JBOSS的jboss-EJB-3.0_Embeddable_ALPHA_8中的jar包即可
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named titan
 at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:41)
 at com.lyh.ejb3.clients.StandaloneClient.main(StandaloneClient.java:21)

 


 在数据库中插入字段,并抛出异常
 public Integer getId() {
  return this.id;
 }
 @Id
 @GeneratedValue(strategy=GenerationType.AUTO)
 public void setId(Integer id) {
  this.id = id;
 }


文章出处:DIY部落(http://www.diybl.com/course/1_web/webjs/20071021/79030_6.html)

posted on 2009-03-16 22:22 大鱼 阅读(534) 评论(0)  编辑  收藏 所属分类: EJB


只有注册用户登录后才能发表评论。


网站导航: