Thanks for your answer... 

I certainly missed something... The tutorial is really well done, but all they 
tell about using the entity manager is only that it should be preceded by the 
@PersistenceContext annotation.

This is what my code looks like... 


  | public class Mediastore implements Serializable {
  |     @PersistenceContext(unitName="mediastore")
  |     private EntityManager entityManager ;
  |     private String hello = "Hello World";
  |     
  |     private static final long serialVersionUID = -2416336874715455139L;
  | 
  |     @SuppressWarnings("unchecked")
  |     public Mediastore(){
  | 
  |             if(entityManager != null){
  |                     System.out.println("Entity manager created 
successfully");
  |             }
  |             else {
  |                     System.out.println("Entity Manager is null !");
  |             }
  | 

This is the code which helped me to say that the EntityManaged was not injected 
correctly, after having had a lot of null pointer exceptions...

Here's my persistence.xml file : 

  | <persistence>
  |    <persistence-unit name="mediastore">
  |       <jta-data-source>java:/mediastoreDS</jta-data-source>
  |       <properties>
  |          <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
  |          <property name="hibernate.cache.use_query_cache" value="true"/>
  |          <property name="hibernate.show_sql" value="true"/>
  |       </properties>
  |    </persistence-unit>
  | </persistence>
  | 

My "mediastore-ds.xml" file : 


  | <?xml version="1.0" encoding="UTF-8"?>
  | 
  | <datasources>
  |     <local-tx-datasource>
  |         <jndi-name>mediastoreDS</jndi-name>
  |         
<connection-url>jdbc:postgresql://localhost/mediastore</connection-url>
  |         <driver-class>org.postgresql.Driver</driver-class>
  |         <user-name>postgres</user-name>
  |         <password>postgres</password>
  |         <min-pool-size>5</min-pool-size>
  |         <max-pool-size>20</max-pool-size>
  |         <idle-timeout-minutes>10</idle-timeout-minutes>
  |         <track-statements>true</track-statements>
  |       </local-tx-datasource>
  | </datasources>
  | 

My ear file is packaged like this :


  | 
  | mediastore.ear 
  |       /META-INF
  |             application.xml
  |      mediastore.jar
  |              /META-INF
  |                    persistence.xml
  |              /packages/classfiles
  | 
  |      mediastore.war
  |              /WEB-INF
  |                      web.xml
  |                      faces-config.xml
  |                      /lib
  |                           jarfiles
  |                      /classes
  |                            packages/classes
  |              index.jsp
  |              home.jsp
  | 
  | 
  | 

I hope this could help someone to see what I did wrong. 

Thanks in advance,

rmic.

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

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


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to