2011-06-09 98 views
1

我在將Web應用程序部署到最新版本的IBM Websphere 7時遇到問題。 異常是在JPA初始化期間引起的。 應用程序使用的servlet 2.5,的EclipseLink 2.1.3,JAVA 6更新25. 的persistence.xml使用版本1.0將我的JPA應用程序部署到Websphere時出現異常7

不確定,如果這個異常由錯誤/配置錯誤引起在Websphere或我的應用程序。也許它也與eclipselink有關。

UPDATE

我們的應用程序不使用JNDI提供的數據源來的EclipseLink。我們的應用程序直接傳遞數據源到的EclipseLink(使用特定的EclipseLink EntityManager的屬性)

的persistence.xml我使用的是(離開了所有的實體定義和調整屬性):

<?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_1_0.xsd" 
    version="1.0"> 
    <persistence-unit name="default" transaction-type="RESOURCE_LOCAL"> 
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> 
    <non-jta-data-source></non-jta-data-source> 
    <class>my.applications.entity.classes.A</class> 
    <!-- other class definitions follow --> 
    <properties> 
     <property name="eclipselink.logging.level" value="FINEST" /> 

     <!-- some other properties, not related to datasources/connections/JNDI 
     follow --> 
    </properties> 
    </persistence-unit> 
</persistence> 

這裏談到的System.err的輸出:

com.ibm.ws.exception.RuntimeWarning: com.ibm.ws.metadata.MetaDataException: CWWJP0018E: Incorrect syntax or error detected in /path/to/my/project/my_application_war.ear/my_application.war/WEB-INF/classes/ for application my_application_war module my_application.war. The following associated error occurred: 
    at com.ibm.ws.jpa.management.JPAApplInfo.processModulePUs(JPAApplInfo.java:185) 
    at com.ibm.ws.jpa.management.JPAComponentImpl.startingDeployedModule(JPAComponentImpl.java:895) 
    at com.ibm.ws.jpa.management.JPAComponentImpl.stateChanged(JPAComponentImpl.java:748) 
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.stateChanged(ApplicationMgrImpl.java:1075) 
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectEvent(DeployedApplicationImpl.java:1302) 
    at com.ibm.ws.runtime.component.DeployedModuleImpl.setState(DeployedModuleImpl.java:221) 
    at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:607) 
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:944) 
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:726) 
    at com.ibm.ws.runtime.component.ApplicationMgrImpl$1.run(ApplicationMgrImpl.java:1268) 
    at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:4588) 
    at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:4766) 
    at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255) 
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplicationDynamically(ApplicationMgrImpl.java:1273) 
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2045) 
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:441) 
    at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123) 
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:384) 
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:655) 
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:617) 
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:1180) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:37) 
    at sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:244) 
    at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1074) 
    at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:955) 
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836) 
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761) 
    at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1332) 
    at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118) 
    at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:1225) 
    at com.ibm.ws.management.commands.AdminServiceCommands$InvokeCmd.execute(AdminServiceCommands.java:251) 
    at com.ibm.ws.console.core.mbean.MBeanHelper.invoke(MBeanHelper.java:239) 
    at com.ibm.ws.console.appdeployment.ApplicationDeploymentCollectionAction.execute(ApplicationDeploymentCollectionAction.java:564) 
    at org.apache.struts.action.RequestProcessor.processActionPerform(Unknown Source) 
    at org.apache.struts.action.RequestProcessor.process(Unknown Source) 
    at org.apache.struts.action.ActionServlet.process(Unknown Source) 
    at org.apache.struts.action.ActionServlet.doPost(Unknown Source) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:738) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1657) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1597) 
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:104) 
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:77) 
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:908) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:934) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:179) 
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:353) 
    at org.apache.struts.action.RequestProcessor.doForward(Unknown Source) 
    at org.apache.struts.tiles.TilesRequestProcessor.doForward(Unknown Source) 
    at org.apache.struts.action.RequestProcessor.processForwardConfig(Unknown Source) 
    at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(Unknown Source) 
    at com.ibm.isclite.container.controller.InformationController.processForwardConfig(InformationController.java:217) 
    at org.apache.struts.action.RequestProcessor.process(Unknown Source) 
    at org.apache.struts.action.ActionServlet.process(Unknown Source) 
    at org.apache.struts.action.ActionServlet.doPost(Unknown Source) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:738) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1657) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1597) 
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:131) 
    at com.ibm.ws.console.core.servlet.WSCUrlFilter.setUpCommandAssistence(WSCUrlFilter.java:933) 
    at com.ibm.ws.console.core.servlet.WSCUrlFilter.continueStoringTaskState(WSCUrlFilter.java:500) 
    at com.ibm.ws.console.core.servlet.WSCUrlFilter.doFilter(WSCUrlFilter.java:321) 
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188) 
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116) 
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:77) 
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:908) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:934) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:179) 
    at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91) 
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:864) 
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583) 
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186) 
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452) 
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511) 
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305) 
    at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83) 
    at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:557) 
    at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:607) 
    at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:984) 
    at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1069) 
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1604) 
Caused by: com.ibm.ws.metadata.MetaDataException: CWWJP0018E: Incorrect syntax or error detected in path/to/my/project/my_application_war.ear/my_application.war/WEB-INF/classes/ for application my_application_war module my_application.war. The following associated error occurred: 
    at com.ibm.ws.jpa.management.JPAPxmlInfo.extractPersistenceUnits(JPAPxmlInfo.java:449) 
    at com.ibm.ws.jpa.management.JPAScopeInfo.processPersistenceUnit(JPAScopeInfo.java:140) 
    at com.ibm.ws.jpa.management.JPAApplInfo.processModulePUs(JPAApplInfo.java:169) 
    ... 90 more 
Caused by: java.lang.ClassCastException: com.ibm.ws.naming.jndicos.CNContextImpl cannot be cast to javax.sql.DataSource 
    at com.ibm.ws.jpa.management.JPAPUnitInfo.getJPADataSource(JPAPUnitInfo.java:493) 
    at com.ibm.ws.jpa.management.JPAPUnitInfo.getNonJtaDataSource(JPAPUnitInfo.java:577) 
    at com.ibm.ws.jpa.management.JPAPUnitInfo.createEntityManagerFactory(JPAPUnitInfo.java:1314) 
    at com.ibm.ws.jpa.management.JPAPxmlInfo.extractPersistenceUnits(JPAPxmlInfo.java:393) 
    ... 92 more 

回答

2

空的非jta數據源導致WebSphere Application Server執行查找(「」),該查找返回根上下文,然後嘗試將其轉換爲DataSource。

容器管理的JPA旨在讓容器獲取數據源並將其傳遞給EM本身。我會建議你要麼在persistence.xml中指定數據源,或者只是禁用容器管理的JPA完全,以避免在應用程序啓動的錯誤:

http://www-01.ibm.com/support/docview.wss?uid=swg1PM26361

+0

這是至少有效的解決方法。謝謝! – MRalwasser 2011-06-09 14:17:50

+0

我不想使用容器管理的JPA。我正在使用RESOURCE_LOCAL。 – MRalwasser 2011-06-09 17:15:45

+0

該設置用於容器管理的JTA(即,JPA提供程序如何與事務服務交互),而不是容器如何與JPA提供程序交互。如果PM26361文檔有助於避免需要容器管理的JPA,那麼在接受答案之前還有什麼需要的嗎? – 2011-06-09 22:22:29

1
Caused by: java.lang.ClassCastException: com.ibm.ws.naming.jndicos.CNContextImpl cannot be cast to javax.sql.DataSource 
    at com.ibm.ws.jpa.management.JPAPUnitInfo.getJPADataSource(JPAPUnitInfo.java:493) 
    at com.ibm.ws.jpa.management.JPAPUnitInfo.getNonJtaDataSource(JPAPUnitInfo.java:577) 
    at com.ibm.ws.jpa.management.JPAPUnitInfo.createEntityManagerFactory(JPAPUnitInfo.java:1314) 
    at com.ibm.ws.jpa.management.JPAPxmlInfo.extractPersistenceUnits(JPAPxmlInfo.java:393) 
    ... 92 more 

在您的EAR配置中,您已經設置了一個JNDI上下文,其中應該有一個JNDI數據源

+0

我們的應用程序不使用JNDI提供數據源來的EclipseLink 。我們的應用程序直接將DataSource傳遞給EclipseLink(使用EclipseLink特定的EntityManager屬性)。我已經更新了這個問題。 – MRalwasser 2011-06-09 12:49:23

2

Websphere似乎正在驗證persistence.xml中的數據源值,它似乎無效。即使稍後重寫,也需要指定有效的值。

請包含您的persistence.xml。您也可以嘗試不設置數據源,或者如果不允許數據源,則使用resource_local。

+0

我已經更新了包含persistence.xml的問題。我不是設置數據源,而是使用resource_local。但是也許空的''會導致這個問題? (但是,順便說一句:其他應用程序服務器沒有任何問題,這個網絡應用程序) – MRalwasser 2011-06-09 13:10:12

相關問題