If you are using Jboss 7.1.1, jboss already has
hibernate-jpa-2.0 in its classpath, so during runtime it uses the one in its classpath, not the one you've deployed with your app , to point jboss to the
hibernate-jpa-2.1 do the following:
hibernate-jpa-2.1-api-1.0.0.final.jar to the following directory :
module.xml and change the resource-root as follows :
resource-root path="hibernate-jpa-2.1-api-1.0.0.final.jar" (pointing it to jpa 2.1)
re-compile and re-deploy your app, then you are good to go.
module.xml 檔案內容, 置換成 hibernate-jpa-2.1-api-1.0.0.Final.jar :
<?xml version="1.0" encoding="UTF-8"?>
~ JBoss, Home of Professional Open Source.
~ Copyright 2010, Red Hat, Inc., and individual contributors
~ as indicated by the @author tags. See the copyright.txt file in the
~ distribution for a full listing of individual contributors.
~ This is free software; you can redistribute it and/or modify it
~ under the terms of the GNU Lesser General Public License as
~ published by the Free Software Foundation; either version 2.1 of
~ the License, or (at your option) any later version.
~ This software is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ Lesser General Public License for more details.
~ You should have received a copy of the GNU Lesser General Public
~ License along with this software; if not, write to the Free
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
<module xmlns="urn:jboss:module:1.1" name="javax.persistence.api">
<!-- PersistenceUnitInfo needs javax.sql.DataSource -->
<module name="javax.api" export="true"/>
<!-- Insert resources here -->