从weblogic 12c连接到sql server

时间:2012-11-28 00:09:25

标签: sql-server jdbc weblogic datasource weblogic12c

我开发了一个公开Web服务的应用程序,该应用程序部署在weblogic 12c中,我从java Web客户端调用Web服务,当我运行java客户端时抛出此异常:

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: EJB Exception: ; nested exception is: 
    javax.persistence.PersistenceException: Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [sqlServer].
Internal Exception: javax.naming.NameNotFoundException: Unable to resolve 'sqlServer'. Resolved ''; remaining name 'sqlServer'
    at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
    at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:111)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
    at $Proxy34.loginService(Unknown Source)
    at main.Main.loginService(Main.java:32)
    at main.Main.main(Main.java:22)

我在Weblogic 12c的管理控制台中配置了一个jdbc资源,而JNDI被命名为sqlServer ...在应用程序中也有一个持久性单元xml文件,即:

<persistence-unit name="BancaSimulacionIBancariaPU" transaction-type="JTA">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>sqlServer</jta-data-source>
    <class>entities.Account</class>
    <class>entities.Bank</class>
    <class>entities.BeneficiaryBankItself</class>
    <class>entities.BeneficiaryThird</class>
    <class>entities.CreditCard</class>
    <class>entities.Movement</class>
    <class>entities.RuleType</class>
    <class>entities.ServiceBank</class>
    <class>entities.TransactionRule</class>
    <class>entities.UserApplication</class>
    <class>entities.Money</class>
    <properties>
      <property name="javax.persistence.jdbc.url" value="jdbc:sqlserver://servertb:1433;databaseName=BancaSimulacion"/>
      <property name="javax.persistence.jdbc.password" value="(*******)"/>
      <property name="javax.persistence.jdbc.driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
      <property name="javax.persistence.jdbc.user" value="sa"/>
    </properties>

我将驱动程序sqljdbc4.jar放在wl_server/lib文件夹中并配置commEnv.cmd ...我替换了同一文件夹中64sqljdbc.dll的{​​{1}} { {1}} ...

但是我不知道哪个是与我的数据库连接的合适设置...我测试我的数据库并且是正确的...有什么问题?

1 个答案:

答案 0 :(得分:0)

确保您的数据源具有目标集 - 否则WebLogic将不会知道它并且它将引发令人讨厌的JNDI(NameNotFoundException)错误。

基本上,您的数据源连接必须100%正确且功能正常,以便WebLogic接受和使用它 - 并且包括确保它具有有效的目标集。