[jboss-user] [Beginners Corner] - No Persistence provider for EntityManager

jhannoy do-not-reply at jboss.com
Mon Dec 24 18:37:47 EST 2007


Hi,

 I am using the following configuration:

 JBoss 4.2.2 GA and EJB3/JPA.

 Here follows a simple session bean and its remote interface that I've been using:


  | public interface Monitor {
  | 	
  | 	abstract EntityManager getEm();
  | 
  | 	abstract void setEm(EntityManager em);
  | 
  | 	public State create(String id, float in, int r,	int b);
  | 
  | 	public void createState(State s);
  | 
  | 	public State findById(String id);
  | 
  | }
  | 
  | 
  | 
  | @Stateless
  | @Remote(Monitor.class)
  | public class MonitorBean implements Monitor {
  | 
  | 	EntityManagerFactory emf;
  | 	@PersistenceUnit(name = "StateMonitor")
  | 	protected EntityManager em;
  | 
  | 	public MonitorBean() {
  | 		em = emf.createEntityManager();
  | 	}
  | 
  | 	public static final String RemoteJNDIName = MonitorBean.class
  | 			.getSimpleName()
  | 			+ "/remote";
  | 	public static final String LocalJNDIName = MonitorBean.class
  | 			.getSimpleName()
  | 			+ "/local";
  | 
  | 	public State create(String id, float in, int r, int b) {
  | 
  | 		final State state = new State(id, in, r, b, Calendar.getInstance().getTime());
  | 
  | 		getEm().persist(state);
  | 		return state;
  | 	}
  | 	
  | 	public void createState(State s) {
  | 		em.persist(s);
  | 	}
  | 	
  | 	public State findById(String id) {
  | 		return em.find(State.class, id);
  | 	}
  | 
  | 	public EntityManager getEm() {
  | 		return em;
  | 	}
  | 
  | 	public void setEm(EntityManager em) {
  | 		this.em = em;
  | 	}
  | }
  | 

As it can be seen the PU named "StateMonitor" is mentioned.

Here follows my persistence.xml file:

  | <?xml version="1.0" encoding="UTF-8"?>
  | <persistence version="1.0"
  | 	xmlns="http://java.sun.com/xml/ns/persistence"
  | 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  | 	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
  | 
  | 
  | 	<persistence-unit name="StateMonitor">
  | 		<provider>org.hibernate.ejb.HibernatePersistence</provider>
  | 		<jta-data-source>java:/OracleDS</jta-data-source>
  | 		<mapping-file>/META-INF/orm.xml</mapping-file>
  | 
  | 		<properties>
  | 			<property name="hibernate.show_sql" value="false" />
  | 			<property name="hibernate.format_sql" value="false" />
  | 			<property name="hibernate.connection.datasource"
  | 				value="java:/OracleDS" />
  | 			<property name="oracle.jdbc.driver.OracleDriver"
  | 				value="org.hsqldb.jdbcDriver" />
  | 			<property name="hibernate.connection.url"
  | 				value="jdbc:oracle:thin:@<ip.ip.ip.ip>:1521:<DB>" />
  | 			<property name="hibernate.connection.username"
  | 				value="aaaaa" />
  | 			<property name="hibernate.connection.password"
  | 				value="aaaaa" />
  | 			<property name="hibernate.dialect"
  | 				value="org.hibernate.dialect.Oracle10gDialect" />
  | 			<property name="hibernate.hbm2ddl.auto" value="create" />
  | 			<property name="hibernate.jdbc.use_streams_for_binary"
  | 				value="false" />
  | 		</properties>
  | 	</persistence-unit>
  | </persistence>
  | 

Here how my build .xml looks like:


  | <?xml version="1.0"?>
  | 
  | <!-- ======================================================================= -->
  | <!-- JBoss build file                                                       -->
  | <!-- ======================================================================= -->
  | 
  | <project name="JBoss" default="ejbjar" basedir=".">
  | 	<property environment="env" />
  | 	<property name="src.dir" location="${basedir}/ejbModule/" />
  | 	<property name="src.resources" value="${basedir}/ejbModule/" />
  | 	<property name="jboss.home" value="${env.JBOSS_HOME}" />
  | 	<property name="build.dir" value="${basedir}/build" />
  | 	<property name="build.classes.dir" value="${build.dir}/classes" />
  | 
  | 
  | 	<!-- Build classpath -->
  | 	<path id="classpath">
  | 		<fileset dir="E:/jboss-4.2.2.GA/server/default/lib">
  | 			<include name="*.jar" />
  | 		</fileset>
  | 		<fileset dir="${jboss.home}/server/default/deploy/ejb3.deployer">
  | 			<include name="*.jar" />
  | 		</fileset>
  | 		<fileset dir="${jboss.home}/server/default/deploy/jboss-aop-jdk50.deployer">
  | 			<include name="*.jar" />
  | 		</fileset>
  | 		<fileset dir="${jboss.home}/server/default/deploy/jboss-bean.deployer">
  | 			<include name="*.jar" />
  | 		</fileset>
  | 		<fileset dir="${jboss.home}/lib">
  | 			<include name="*.jar" />
  | 		</fileset>
  | 		<fileset dir="E:/eclipse/plugins/org.junit4_4.3.1">
  | 			<include name="*.jar" />
  | 		</fileset>
  | 		<fileset dir="E:/jboss-EJB-3.0_Embeddable_ALPHA_8/lib">
  | 			<include name="jboss-ejb3-all.jar" />
  | 		</fileset>
  | 		<fileset dir="E:/eclipse/plugins/org.apache.derby.core_10.3.1">
  | 			<include name="*.jar" />
  | 		</fileset>
  | 		<fileset dir="E:/hibernate-entitymanager-3.3.1.GA">
  | 			<include name="*.jar" />
  | 		</fileset>
  | 		<fileset dir="E:/hibernate-entitymanager-3.3.1.GA/lib">
  | 			<include name="*.jar" />
  | 		</fileset>
  | 		<fileset dir="E:/hibernate-annotations-3.3.0.GA">
  | 			<include name="*.jar" />
  | 		</fileset>
  | 		<fileset dir="E:/hibernate-annotations-3.3.0.GA/lib">
  | 			<include name="*.jar" />
  | 		</fileset>
  | 		<fileset dir="E:/hibernate-3.2/lib">
  | 			<include name="*.jar" />
  | 		</fileset>
  | 		<fileset dir="E:/hibernate-3.2">
  | 			<include name="*.jar" />
  | 		</fileset>
  | 		<fileset dir="{src.dir}/../oraclelibs">
  | 			<include name="*.jar" />
  | 		</fileset>
  | 		<fileset dir="{src.dir}/../oraclelibs">
  | 			<include name="*.zip" />
  | 		</fileset>
  | 
  | 		<pathelement location="${build.classes.dir}" />
  | 		<!-- So that we can get jndi.properties for InitialContext and log4j.xml file -->
  | 		<pathelement location="${basedir}/ejbModule/META-INF" />
  | 	</path>
  | 
  | 	<property name="build.classpath" refid="classpath" />
  | 
  | 	<!-- =================================================================== -->
  | 	<!-- Prepares the build directory                                        -->
  | 	<!-- =================================================================== -->
  | 	<target name="prepare">
  | 		<mkdir dir="${build.dir}" />
  | 		<mkdir dir="${build.classes.dir}" />
  | 		<copy file="Oracle-ds.xml" todir="${jboss.home}/server/default/deploy" />
  | 	</target>
  | 
  | 	<!-- =================================================================== -->
  | 	<!-- Compiles the source code                                            -->
  | 	<!-- =================================================================== -->
  | 	<target name="compile" depends="prepare">
  | 		<javac srcdir="${src.dir}" destdir="${build.classes.dir}" debug="on" deprecation="on" optimize="off" includes="**">
  | 			<classpath refid="classpath" />
  | 		</javac>
  | 	</target>
  | 
  | 	<target name="ejbjar" depends="compile">
  | 		<jar jarfile="build/statemonitor.jar">
  | 			<fileset dir="${build.classes.dir}">
  | 				<include name="entity/*.class" />
  | 				<include name="session/*.class" />
  | 				<include name="exception/*.class" />
  | 				<include name="util/*.class" />
  | 				<include name="testcases/*.class" />
  | 			</fileset>
  | 			<fileset dir="${src.resources}/">
  | 				<include name="META-INF/persistence.xml" />
  | 				<include name="META-INF/orm.xml" />
  | 				<include name="META-INF/jndi.properties" />				
  | 			</fileset>
  | 		</jar>
  | 		<copy file="build/statemonitor.jar" todir="${jboss.home}/server/default/deploy" />
  | 	</target>
  | 
  | 	<target name="run.client" depends="ejbjar">
  | 		<java classname="testcases.TestClient" fork="yes" dir=".">
  | 			<classpath refid="classpath" />
  | 		</java>
  | 	</target>
  | 
  | 	<!-- =================================================================== -->
  | 	<!-- Cleans up generated stuff                                           -->
  | 	<!-- =================================================================== -->
  | 	
  | 	<target name="clean">
  | 		<delete dir="${build.dir}" />
  | 		<delete file="${jboss.home}/server/default/deploy/statemonitor.jar" />
  | 		<delete file="${jboss.home}/server/default/deploy/Oracle-ds.xml" />
  | 	</target>
  | 
  | </project>
  | 
  | 

 As it can be seen I've used all the required jars in the classpath.

 It seems that the server has no issues deploying the application. The following server log confirms this:


  | 
  | ...................
  | ...................
  | ....................
  | 
  | 2007-12-24 19:23:29,296 DEBUG [org.jboss.ejb3.Ejb3AnnotationHandler] found EJB3: ejbName=MonitorBean, class=session.MonitorBean, type=STATELESS
  | 2007-12-24 19:23:29,390 DEBUG [org.hibernate.util.DTDEntityResolver] trying to resolve system-id [http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd]
  | 2007-12-24 19:23:29,390 DEBUG [org.hibernate.cfg.EJB3DTDEntityResolver] recognized EJB3 ORM namespace; attempting to resolve on classpath under org/hibernate/ejb
  | 2007-12-24 19:23:29,390 DEBUG [org.hibernate.cfg.EJB3DTDEntityResolver] located [http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd] in classpath
  | 2007-12-24 19:23:29,421 DEBUG [org.jboss.ejb3.Ejb3Deployment] EJB3 deployment time took: 203
  | 2007-12-24 19:23:29,421 DEBUG [org.jboss.ejb3.Ejb3Module] Created jboss.j2ee:service=EJB3,module=statemonitor.jar
  | 2007-12-24 19:23:29,421 DEBUG [org.jboss.system.ServiceController] Creating dependent components for: jboss.j2ee:service=EJB3,module=statemonitor.jar dependents are: []
  | 2007-12-24 19:23:29,421 DEBUG [org.jboss.deployment.MainDeployer] Done with create step of deploying statemonitor.jar
  | 2007-12-24 19:23:29,421 DEBUG [org.jboss.deployment.MainDeployer] Begin deployment start file:/E:/jboss-4.2.2.GA/server/default/deploy/statemonitor.jar
  | 2007-12-24 19:23:29,421 DEBUG [org.jboss.ejb3.EJB3Deployer] start application, deploymentInfo: org.jboss.deployment.DeploymentInfo at 206491c1 { url=file:/E:/jboss-4.2.2.GA/server/default/deploy/statemonitor.jar }
  |   deployer: MBeanProxyExt[jboss.ejb3:service=EJB3Deployer]
  |   status: Starting
  |   state: START_DEPLOYER
  |   watch: file:/E:/jboss-4.2.2.GA/server/default/deploy/statemonitor.jar
  |   altDD: null
  |   lastDeployed: 1198504409203
  |   lastModified: 1198504409203
  |   mbeans:
  | , short name: statemonitor.jar, parent short name: null
  | 2007-12-24 19:23:29,421 DEBUG [org.jboss.system.ServiceController] starting service jboss.j2ee:service=EJB3,module=statemonitor.jar
  | 2007-12-24 19:23:29,421 DEBUG [org.jboss.ejb3.Ejb3Module] Starting jboss.j2ee:service=EJB3,module=statemonitor.jar
  | 2007-12-24 19:23:29,421 INFO  [org.jboss.ejb3.JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.entity.PersistenceUnitDeployment
  | 2007-12-24 19:23:29,437 INFO  [org.jboss.ejb3.JmxKernelAbstraction] installing MBean: persistence.units:jar=statemonitor.jar,unitName=StateMonitor with dependencies:
  | 2007-12-24 19:23:29,437 INFO  [org.jboss.ejb3.JmxKernelAbstraction] 	jboss.jca:name=OracleDS,service=DataSourceBinding
  | 2007-12-24 19:23:29,437 DEBUG [org.jboss.system.ServiceController] Creating service persistence.units:jar=statemonitor.jar,unitName=StateMonitor
  | 
  | ...................
  | ...................
  | ....................
  | 
  | 2007-12-24 19:23:29,437 DEBUG [org.jboss.ejb3.ServiceDelegateWrapper] Starting persistence.units:jar=statemonitor.jar,unitName=StateMonitor
  | 2007-12-24 19:23:29,437 INFO  [org.jboss.ejb3.entity.PersistenceUnitDeployment] Starting persistence unit persistence.units:jar=statemonitor.jar,unitName=StateMonitor
  | 2007-12-24 19:23:29,437 DEBUG [org.jboss.ejb3.entity.PersistenceUnitDeployment] Found persistence.xml file in EJB3 jar
  | 2007-12-24 19:23:29,453 INFO  [org.hibernate.ejb.Version] Hibernate EntityManager 3.2.1.GA
  | 2007-12-24 19:23:29,484 INFO  [org.hibernate.cfg.annotations.Version] Hibernate Annotations 3.2.1.GA
  | 2007-12-24 19:23:29,484 INFO  [org.hibernate.cfg.Environment] Hibernate 3.2.4.sp1
  | 2007-12-24 19:23:29,500 INFO  [org.hibernate.cfg.Environment] hibernate.properties not found
  | 2007-12-24 19:23:29,500 INFO  [org.hibernate.cfg.Environment] Bytecode provider name : javassist
  | 2007-12-24 19:23:29,500 INFO  [org.hibernate.cfg.Environment] using JDK 1.4 java.sql.Timestamp handling
  | 2007-12-24 19:23:29,625 DEBUG [org.hibernate.ejb.Ejb3Configuration] Processing PersistenceUnitInfo [
  | 	name: StateMonitor
  | 	persistence provider classname: org.hibernate.ejb.HibernatePersistence
  | 	classloader: org.jboss.mx.loading.UnifiedClassLoader3 at 1ca5b68{ url=file:/E:/jboss-4.2.2.GA/server/default/tmp/deploy/tmp22123statemonitor.jar ,addedOrder=46}
  | 	Temporary classloader: org.jboss.mx.loading.UnifiedClassLoader3 at 19a19fd{ url=file:/E:/jboss-4.2.2.GA/server/default/tmp/deploy/tmp22123statemonitor.jar ,addedOrder=0}
  | 	excludeUnlistedClasses: false
  | 	JTA datasource: org.jboss.resource.adapter.jdbc.WrapperDataSource at 1963273
  | 	Non JTA datasource: null
  | 	Transaction type: JTA
  | 	PU root URL: file:/E:/jboss-4.2.2.GA/server/default/deploy/statemonitor.jar
  | 	Jar files URLs []
  | 	Managed classes names []
  | 	Mapping files names [
  | 		/META-INF/orm.xml]
  | 	Properties [
  | 		hibernate.jacc.ctx.id: statemonitor.jar
  | 		hibernate.connection.password: orvetl
  | 		hibernate.cache.region_prefix: statemonitor_jar,StateMonitor
  | 		hibernate.show_sql: false
  | 		hibernate.bytecode.use_reflection_optimizer: false
  | 		hibernate.connection.datasource: java:/OracleDS
  | 		hibernate.transaction.manager_lookup_class: org.hibernate.transaction.JBossTransactionManagerLookup
  | 		hibernate.hbm2ddl.auto: create
  | 		hibernate.jdbc.use_streams_for_binary: false
  | 		hibernate.format_sql: false
  | 		hibernate.session_factory_name: persistence.units:jar=statemonitor.jar,unitName=StateMonitor
  | 		hibernate.connection.username: orvetl
  | 		hibernate.jndi.java.naming.factory.url.pkgs: org.jboss.naming:org.jnp.interfaces
  | 		hibernate.jndi.java.naming.factory.initial: org.jnp.interfaces.NamingContextFactory
  | 		oracle.jdbc.driver.OracleDriver: org.hsqldb.jdbcDriver
  | 		hibernate.cache.provider_class: org.hibernate.cache.HashtableCacheProvider
  | 		hibernate.dialect: org.hibernate.dialect.Oracle10gDialect
  | 		hibernate.connection.url: jdbc:oracle:thin:@10.5.2.101:1521:DBADP1
  | 		hibernate.bytecode.provider: javassist]
  | 2007-12-24 19:23:29,625 DEBUG [org.hibernate.ejb.Ejb3Configuration] Detect class: true; detect hbm: true
  | 2007-12-24 19:23:29,625 DEBUG [org.hibernate.ejb.Ejb3Configuration] Detect class: true; detect hbm: true
  | 
  | ........................
  | ...........................
  | ........................
  | 
  | 2007-12-24 19:23:29,750 INFO  [org.hibernate.ejb.Ejb3Configuration] [PersistenceUnit: StateMonitor] META-INF/orm.xml found
  | 2007-12-24 19:23:29,765 DEBUG [org.hibernate.cfg.AnnotationConfiguration] Execute first pass mapping processing
  | 2007-12-24 19:23:29,843 DEBUG [org.hibernate.cfg.AnnotationConfiguration] Process hbm files
  | 2007-12-24 19:23:29,843 DEBUG [org.hibernate.cfg.AnnotationConfiguration] Process annotated classes
  | 2007-12-24 19:23:29,843 INFO  [org.hibernate.cfg.AnnotationBinder] Binding entity from annotated class: entity.State
  | 
  | ........................
  | ...........................
  | ........................
  | 
  | 2007-12-24 19:23:30,921 INFO  [org.hibernate.impl.SessionFactoryObjectFactory] Factory name: persistence.units:jar=statemonitor.jar,unitName=StateMonitor
  | 2007-12-24 19:23:30,937 INFO  [org.hibernate.util.NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.impl.SessionFactoryImpl] Returning a Reference to the SessionFactory
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.util.NamingHelper] Bound name: persistence.units:jar=statemonitor.jar,unitName=StateMonitor
  | 2007-12-24 19:23:30,937 INFO  [org.hibernate.impl.SessionFactoryObjectFactory] Bound factory to JNDI name: persistence.units:jar=statemonitor.jar,unitName=StateMonitor
  | 2007-12-24 19:23:30,937 WARN  [org.hibernate.impl.SessionFactoryObjectFactory] InitialContext did not implement EventContext
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.impl.SessionFactoryImpl] instantiated session factory
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.cfg.AnnotationConfiguration] Execute first pass mapping processing
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.cfg.AnnotationConfiguration] Process hbm files
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.cfg.AnnotationConfiguration] Process annotated classes
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.cfg.AnnotationConfiguration] processing manytoone fk mappings
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.cfg.Configuration] processing extends queue
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.cfg.Configuration] processing collection mappings
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.cfg.Configuration] processing native query and ResultSetMapping mappings
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.cfg.Configuration] processing association property references
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.cfg.Configuration] processing foreign key constraints
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.validator.ClassValidator] ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.cfg.AnnotationConfiguration] Execute first pass mapping processing
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.cfg.AnnotationConfiguration] Process hbm files
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.cfg.AnnotationConfiguration] Process annotated classes
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.cfg.AnnotationConfiguration] processing manytoone fk mappings
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.cfg.Configuration] processing extends queue
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.cfg.Configuration] processing collection mappings
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.cfg.Configuration] processing native query and ResultSetMapping mappings
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.cfg.Configuration] processing association property references
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.cfg.Configuration] processing foreign key constraints
  | 2007-12-24 19:23:30,937 DEBUG [org.hibernate.validator.ClassValidator] ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages
  | 2007-12-24 19:23:30,937 INFO  [org.hibernate.tool.hbm2ddl.SchemaExport] Running hbm2ddl schema export
  | 
  | ........................
  | ...........................
  | ........................
  | 
  | 2007-12-24 19:23:31,375 DEBUG [org.jboss.ejb3.Ejb3Deployment] Bound ejb3 container jboss.j2ee:jar=statemonitor.jar,name=OSMonitorBean,service=EJB3
  | 2007-12-24 19:23:31,375 DEBUG [org.jboss.ejb3.Ejb3Module] Started jboss.j2ee:service=EJB3,module=statemonitor.jar
  | 2007-12-24 19:23:31,375 DEBUG [org.jboss.system.ServiceController] Starting dependent components for: jboss.j2ee:service=EJB3,module=statemonitor.jar dependent components: []
  | 2007-12-24 19:23:31,375 INFO  [org.jboss.ejb3.EJB3Deployer] Deployed: file:/E:/jboss-4.2.2.GA/server/default/deploy/statemonitor.jar
  | 2007-12-24 19:23:31,375 DEBUG [org.jboss.deployment.MainDeployer] End deployment start on package: statemonitor.jar
  | 2007-12-24 19:23:31,375 DEBUG [org.jboss.deployment.MainDeployer] Deployed package: file:/E:/jboss-4.2.2.GA/server/default/deploy/statemonitor.jar
  | 2007-12-24 19:23:31,375 DEBUG [org.jboss.deployment.scanner.URLDeploymentScanner] Watch URL for: file:/E:/jboss-4.2.2.GA/server/default/deploy/statemonitor.jar -> file:/E:/jboss-4.2.2.GA/server/default/deploy/statemonitor.jar
  | 
  | ..................
  | ..................
  | ....................
  | 
  | 
  | 
  | Finally here follows a typical test client:
  | 
  | 
  |   | 
  |   | public class TestClient {
  |   | 
  |   | 	private EntityManagerFactory emf;
  |   | 	private EntityManager em;
  |   | 
  |   | 	Monitor bean = null;
  |   | 
  |   | 	public void runTest() throws Exception {
  |   | 		
  |   | 		try {
  |   | 			InitialContext ctx = new InitialContext();
  |   | 			Agent agent = new Agent();
  |   | 
  |   | 			bean = (Monitor) ctx.lookup(MonitorBean.RemoteJNDIName);
  |   | 			initEmfAndEm();
  |   | 			bean.getEm().getTransaction().begin();
  |   | 
  |   | 			System.out.println("Monitor Sateless...");
  |   | 			bean.create(agent.getId(), agent.getIn(), agent.getR(), agent.getB());
  |   | 			bean.toString();
  |   | 
  |   | 			bean.getEm().getTransaction().rollback();
  |   | 
  |   | 		} catch (NamingException e) {
  |   | 			e.printStackTrace();
  |   | 		}
  |   | 	}
  |   | 
  |   | 	public void initEmfAndEm() {
  |   | 		emf = Persistence.createEntityManagerFactory("StateMonitor");		em = emf.createEntityManager();
  |   | 		bean.setEm(em);
  |   | 	}
  |   | 
  |   | 	public void closeEmAndEmf() {
  |   | 		bean.getEm().close();
  |   | 		emf.close();
  |   | 	}
  |   | 
  |   | 	public static void main(String[] args) {
  |   | 		try {
  |   | 			TestClient cli = new TestClient();
  |   | 			System.out.println("Created Class...");
  |   | 			cli.runTest();
  |   | 
  |   | 		} catch (Exception e) {
  |   | 			e.printStackTrace();
  |   | 		}
  |   | 	}
  |   | 
  |   | }
  |   | 
  | 
  | While running this using ant (build.xml) I am getting the following error:
  | 
  | 
  |   | 
  |   | Buildfile: E:\E_WSPACE_EURO\StateMonitor\build.xml
  |   | prepare:
  |   | compile:
  |   | ejbjar:
  |   | run.client:
  |   |      [java] Created Class...
  |   |      [java] log4j:WARN No appenders could be found for logger (org.hibernate.ejb.Version).
  |   |      [java] log4j:WARN Please initialize the log4j system properly.
  |   |      [java] javax.persistence.PersistenceException: No Persistence provider for EntityManager named StateMonitor
  |   |      [java] 	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
  |   |      [java] 	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
  |   |      [java] 	at testcases.TestClient.initEmfAndEm(TestClient.java:68)
  |   |      [java] 	at testcases.TestClient.runTest(TestClient.java:39)
  |   |      [java] 	at testcases.TestClient.main(TestClient.java:82)
  |   | BUILD SUCCESSFUL
  |   | Total time: 1 second
  |   | 
  | 
  | Requesting all to help please. Do I need any more config/xmls?
  | 
  | -Thanks,
  | J.
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4115389#4115389

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4115389



More information about the jboss-user mailing list