Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Glassfish 4.1,JPA 2.1 persistence.xml_Java_Xml_Persistence.xml_Jpa 2.1_Glassfish 4.1 - Fatal编程技术网

Java Glassfish 4.1,JPA 2.1 persistence.xml

Java Glassfish 4.1,JPA 2.1 persistence.xml,java,xml,persistence.xml,jpa-2.1,glassfish-4.1,Java,Xml,Persistence.xml,Jpa 2.1,Glassfish 4.1,我面临着这样的错误: Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"http://xmlns.jcp.org/xml/ns/persistence", local:"persistence"). Expected elements are <{http://java.sun.com/xml/ns/persistence}persistence> at com.sun.xml

我面临着这样的错误:

Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"http://xmlns.jcp.org/xml/ns/persistence", local:"persistence"). Expected elements are <{http://java.sun.com/xml/ns/persistence}persistence>
        at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:740)
        at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:262)
我的pom.xml文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>myTestProject</artifactId>
        <groupId>com.myTestProject</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.myTestProject.module.domain</groupId>
    <artifactId>module.domain</artifactId>
    <packaging>bundle</packaging>

    <name>module.domain</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Export-Package>com.myTestProject.module.domain.*</Export-Package>
                        <Import-Package>javax.persistence.*, org.osgi.framework</Import-Package>
                        <Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
                        <Bundle-Activator>com.myTestProject.module.domain.Activator</Bundle-Activator>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>org.eclipse.persistence.jpa</artifactId>
            <version>2.5.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>4.3.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

请大家帮我一个忙。您的问题不清楚您遇到的异常是在表创建过程中还是在执行其他操作时,您能澄清一下吗?实际上,在OSGi捆绑包中部署并尝试使用2.1名称空间执行与上述基本相同的操作时,我也会遇到同样的情况。有什么解决办法吗?这是在进行部署时,甚至在框架在初始解析中将捆绑包识别为JPA捆绑包之前发生的。以防万一其他人也看到了这一点-这是因为GlassFish osgi-JPA.jar中的JPA桥没有更新以处理2.1模式。您可以在glassfish~svn/trunk/fighterfish/module/osgijpa的源代码中看到/更新这一点。
@Entity
public class News {

    @Id
    @GeneratedValue
    private Long ID;
    private String title;
    private String content;
    private Long views;

    // getters and setters.... default non-arg constructor was omitted
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>myTestProject</artifactId>
        <groupId>com.myTestProject</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.myTestProject.module.domain</groupId>
    <artifactId>module.domain</artifactId>
    <packaging>bundle</packaging>

    <name>module.domain</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Export-Package>com.myTestProject.module.domain.*</Export-Package>
                        <Import-Package>javax.persistence.*, org.osgi.framework</Import-Package>
                        <Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
                        <Bundle-Activator>com.myTestProject.module.domain.Activator</Bundle-Activator>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>org.eclipse.persistence.jpa</artifactId>
            <version>2.5.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>4.3.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>