Results 1 to 8 of 8
  1. #1
    javaBee is offline Member
    Join Date
    Jan 2012
    Posts
    12
    Rep Power
    0

    Default Could not find any META-INF/persistence.xml file in the classpath

    Hai friends,

    I am new to this JPA technology.And i am trying to create tables dynamically by using JPA in dynamic web project.But during program execution i am constantly getting this error

    Java Code:
    08:37:30,527 INFO  [org.hibernate.cfg.Environment] (http-localhost-127.0.0.1-8080-1) HHH000206: 
    hibernate.properties not found
    08:37:30,528 INFO  [org.hibernate.cfg.Environment] (http-localhost-127.0.0.1-8080-1) HHH000021: 
    Bytecode provider name : javassist
    08:37:30,581 INFO  [org.hibernate.ejb.Ejb3Configuration] (http-localhost-127.0.0.1-8080-1) HHH000318: Could not find any 
    META-INF/persistence.xml file in the classpath
    08:37:30,582 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) In catch exception block !!
    08:37:30,583 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) e : javax.persistence.PersistenceException:
     No Persistence provider for EntityManager named sample

    And My persistence.xml file is :

    Java Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence 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_2_0.xsd"
                 version="2.0">
       <persistence-unit name="sample" transaction-type="RESOURCE_LOCAL">
             <provider>org.hibernate.ejb.HibernatePersistence</provider> 
            
            <class>com.sarath.sample.dto.checkDTO</class>
             <properties>
                <property name="hibernate.hbm2ddl.auto" value="update"/>
                <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
                <property name="hibernate.show_sql" value="true"/>
                <property name="hibernate.connection,driver-class" value="org.postgresql.
    Driver"/>
                <property name="hibernate.connection.username" value="postgres"/>
                <property name="hibernate.connection.password" value="postgres" />
                <property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432
    /sample_sarath"/>
                <property name="hibernate.max-fetch-depth" value="3"/>
            </properties>
        </persistence-unit> 
     
        
    </persistence>
    During debugging i found that in this code ,

    Java Code:
    try {
    
    	   EntityManagerFactory emf = Persistence.
    createEntityManagerFactory("sample");
    	    EntityManager em = emf.createEntityManager();
    	    em.getTransaction().begin();
    
    	    checkDTO cdto = new checkDTO();
    	    cdto.setName(name);
    	    cdto.setPassWord(passWord);
    	    em.persist(cdto);
    	    em.getTransaction().commit();
    	    em.close();
    
    	    System.out.println("hai");
    
    	} 
    	catch (Exception e) 
    	{
    	    System.out.println("In catch exception block !!\ne : " + e);
    	}
    when pointer reaches
    Java Code:
      EntityManager em = emf.createEntityManager();
    it throws error and pointer moves to the catch block.


    Can any one please help.Any help regarding this issue is so much appreciated

    Thank you guys in advance.
    Last edited by javaBee; 07-12-2013 at 06:29 AM.

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,365
    Rep Power
    6

    Default Re: Could not find any META-INF/persistence.xml file in the classpath

    But is it in a META-INF subfolder?

    If you're using Eclipse you may also want to check your project build settings to be sure that resources are not being excluded.

  3. #3
    javaBee is offline Member
    Join Date
    Jan 2012
    Posts
    12
    Rep Power
    0

    Default Re: Could not find any META-INF/persistence.xml file in the classpath

    Quote Originally Posted by gimbal2 View Post
    But is it in a META-INF subfolder?

    If you're using Eclipse you may also want to check your project build settings to be sure that resources are not being excluded.
    persistent.xml file is located in META-INF folder.
    The META-INF folder is actually present in two places.
    One in src and other in Web content folder.

    I am not sure where i have to put that file.So i put the persistent.xml file in both folders.

  4. #4
    javaBee is offline Member
    Join Date
    Jan 2012
    Posts
    12
    Rep Power
    0

    Default Re: Could not find any META-INF/persistence.xml file in the classpath

    Did you mean "jboss-deployement-structure.xml" file as project build settings ?

    I am putting the contents of that file below ::



    Java Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
    	<deployment>
    		<!-- Project exclusions/dependencies -->
    		<dependencies>
    			<module name="org.apache.commons.logging" export="true" />
    			<module name="org.apache.commons.collections" export="true" />
    <module name="org.postgresql" slot="main">
    				<imports>
    					<include path="META-INF**" />
    					<include path="org**" />
    				</imports>
    			</module>
    			
    		</dependencies>
    	</deployment>
    
    </jboss-deployment-structure>

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,365
    Rep Power
    6

    Default Re: Could not find any META-INF/persistence.xml file in the classpath

    No, I never said anything about jboss-deployment-structure.xml; you never even mentioned that you were using JBoss 7 so how would I know that the file exists?

    And the persistence.xml file needs to be on the classpath, so the web resources is not going to help you. Guessing NEVER helps you, it only hurts. In any case Java or the framework is not lying to you, the file is not on the classpath so your application deployment must be going wrong somewhere. Good luck figuring out where, I don't have access to your machine so I can't debug it for you.

  6. #6
    javaBee is offline Member
    Join Date
    Jan 2012
    Posts
    12
    Rep Power
    0

    Default Re: Could not find any META-INF/persistence.xml file in the classpath

    hey..
    Chill dude..
    I don't have any understanding about this JPA thing..
    Thats y i posted this qn in the forum..
    And no one asked you to debug it for me.

    If you have any intention to help , it is so much appreciated.
    If you like to play James Goesling , do it somewhere else !

    Thank you for ur help !!

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Could not find any META-INF/persistence.xml file in the classpath

    Quote Originally Posted by javaBee View Post
    Thats y i posted this qn
    This is a technical forum, not SMS chat. Please take the trouble to spell words in full.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  8. #8
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,365
    Rep Power
    6

    Default Re: Could not find any META-INF/persistence.xml file in the classpath

    Quote Originally Posted by javaBee View Post
    hey..
    Chill dude..
    I am chill, you just interpret what I say badly. Thanks a lot for assuming the worst, "friend".

Similar Threads

  1. Can't find classpath
    By Tizmiz in forum New To Java
    Replies: 1
    Last Post: 01-02-2013, 06:22 AM
  2. add the driver jar file in the classpath.
    By vahidbakhtiary in forum New To Java
    Replies: 9
    Last Post: 07-03-2012, 05:31 AM
  3. Replies: 0
    Last Post: 03-31-2012, 08:27 AM
  4. Load A Property File From Classpath?
    By miko5054 in forum New To Java
    Replies: 2
    Last Post: 06-29-2010, 01:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •