websphere 7和(基于应用程序的)open-jpa 2 [英] websphere 7 and (application based) open-jpa 2

查看:83
本文介绍了websphere 7和(基于应用程序的)open-jpa 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想使用内置的Websphere 7 jpa插件,而是使用应用程序WEB-INF/lib/open-jpa 2和专有的持久性提供程序.我无法为Websphere安装OSGI和JPA 2功能包.

I want to not use the built in Websphere 7 jpa plugin, instead use an application WEB-INF/lib/open-jpa 2 and a proprietary persistence provider. I cannot install the OSGI and JPA 2 feature pack for Websphere.

最初,我在尝试加载persistence.xml时遇到了sax解析错误(不支持version ="2").该错误是由open-jpa 1.2.3中的一个类抛出的.当我运行websphere/appserver/bin/wsjpaversion.bat时,将显示open-jpa 1.2.3 jar.默认情况下,它会覆盖应用程序中的open-jpa 2 jar.我创建了一个包含open-jpa 2 jar的共享库,并选中了以下配置选项:为此共享库使用隔离的类加载器".我将应用程序类加载器设置为最后加载父类,并为其分配了新的共享库资源. 版本2"错误已消失,但是还有另一个问题.当我尝试初始化EntityManager时出现错误:

Originally, I was getting a sax parse error simply trying to load the persistence.xml (version="2" not supported). The error was thrown by a class in open-jpa 1.2.3. When I run websphere/appserver/bin/wsjpaversion.bat, the open-jpa 1.2.3 jar is displayed. By default it overrides the open-jpa 2 jar in the app. I created a shared library containing the open-jpa 2 jar with this config option checked: 'Use an isolated class loader for this shared library'. I set my application classloader to load parent last and assigned it the new shared library resource. The 'version 2' error is gone, but there is another problem. When I try to initialize an EntityManager I get an error:

Caused by: javax.persistence.PersistenceException: Failed to load provider from META-INF/services
    at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(PersistenceProviderResolverHolder.java:121)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:91)
    at java.lang.J9VMInternals.initializeImpl(Native Method)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
    ... 2 more
Caused by: java.lang.ClassCastException: com.ibm.websphere.persistence.PersistenceProviderImpl incompatible with javax.persistence.spi.PersistenceProvider
    at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(PersistenceProviderResolverHolder.java:110)
    ... 11 more

更多细节:在persistence.xml中,provider元素设置为专有的PersistenceProviderImpl,而不是默认的Websphere持久性提供程序.那么,这个Websphere默认值是从哪里来的,我该如何预防呢? (另一个重要说明:当我完全删除persistence.xml时,会出现相同的错误)

One more detail: inside the persistence.xml, the provider element is set to the proprietary PersistenceProviderImpl not the default Websphere persistence provider. So where is this websphere default coming from and how do I prevent it? (another important note: when I remove persistence.xml completely, I get the same error)

谢谢

推荐答案

不安装功能部件包,您正在与失败的战斗搏斗.虽然可以插入您自己的JPA 实现,但无法使用JPA API —因此WAS 7将您与JPA的1.0版本相关联(例如,请参见此处完成了—尽管乍一看似乎很诱人,但没有任何类加载器策略处理可以改变这一点.

Without installing the feature pack, you're fighting a losing battle. While it is possible to plug in your own JPA implementation, it is not possible to do that with JPA API — so WAS 7 ties you to the 1.0 version of JPA (see, for example, here how this is done — no class loader policy juggling will change that, though it seems tempting at first).

这篇关于websphere 7和(基于应用程序的)open-jpa 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆