1
votes

I'm using Oracle Express (XE) and connecting to it through JDBC. The code has a Universal Connection Pool implemented (UCP).

For some reason, when I try to get a new connection I get:

java.sql.SQLException: Unable to start the Universal Connection Pool: oracle.ucp.UniversalConnectionPoolException: Cannot get Connection from Datasource

I'm running my tomcat server using maven

mvn tomcat7:run

Do I need to add any extra configuration to my pom.xml or to the Oracle itself to make UCP work?

Here is the stacktrace:

java.sql.SQLException: Unable to start the Universal Connection Pool: oracle.ucp.UniversalConnectionPoolException: Cannot get Connection from Datasource
    at oracle.ucp.util.UCPErrorHandler.newSQLException(UCPErrorHandler.java:541)
    at oracle.ucp.jdbc.PoolDataSourceImpl.throwSQLException(PoolDataSourceImpl.java:588)
    at oracle.ucp.jdbc.PoolDataSourceImpl.startPool(PoolDataSourceImpl.java:277)
    at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:647)
    at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:614)
    at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:608)
    at com.websitepros.sql.UCPConnectionPoolImpl.borrowConnection(UCPConnectionPoolImpl.java:268)
    at com.websitepros.sql.ConnectionFactoryImpl.borrowConnection(ConnectionFactoryImpl.java:60)
    at com.websitepros.sql.ConnectionFactoryImpl.getConnection(ConnectionFactoryImpl.java:49)
    at com.websitepros.sql.Table.getConnection(Table.java:196)
    at com.websitepros.matrix.dataobjects.tables.PartnersTable.selectAll(PartnersTable.java:513)
    at com.websitepros.util.PartnerTreeUtil.buildMap(PartnerTreeUtil.java:92)
    at com.websitepros.util.PartnerTreeUtil.<init>(PartnerTreeUtil.java:38)
    at com.websitepros.util.dbproperties.DBPartnerProperties.load(DBPartnerProperties.java:44)
    at com.websitepros.util.PropertiesUtil.getProperties(PropertiesUtil.java:47)
    at com.websitepros.util.PropertiesUtil.getProperties(PropertiesUtil.java:35)
    at com.rocktide.integration.mip.PartnerAttributes.<init>(PartnerAttributes.java:76)
    at com.rocktide.integration.mip.BuilderEnvironment.createPartnerAttributes(BuilderEnvironment.java:68)
    at com.rocktide.integration.mip.BuilderEnvironment.createPartnerAttributes(BuilderEnvironment.java:53)
    at com.websitepros.matrix.partners.hermes.Authenticate.serviceRequest(Authenticate.java:74)
    at com.websitepros.servlet.WebComGenericServlet.doPost(WebComGenericServlet.java:31)
    at com.websitepros.servlet.WebComGenericServlet.doGet(WebComGenericServlet.java:24)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:745)
Caused by: oracle.ucp.UniversalConnectionPoolException: Cannot get Connection from Datasource
    at oracle.ucp.util.UCPErrorHandler.newUniversalConnectionPoolException(UCPErrorHandler.java:421)
    at oracle.ucp.util.UCPErrorHandler.newUniversalConnectionPoolException(UCPErrorHandler.java:389)
    at oracle.ucp.jdbc.DriverConnectionFactoryAdapter.createConnection(DriverConnectionFactoryAdapter.java:134)
    at oracle.ucp.common.UniversalConnectionPoolImpl$UniversalConnectionPoolInternal.createOnePooledConnectionInternal(UniversalConnectionPoolImpl.java:1613)
    at oracle.ucp.common.UniversalConnectionPoolImpl$UniversalConnectionPoolInternal.access$600(UniversalConnectionPoolImpl.java:1421)
    at oracle.ucp.common.UniversalConnectionPoolImpl.createOnePooledConnection(UniversalConnectionPoolImpl.java:488)
    at oracle.ucp.common.UniversalConnectionPoolImpl.addNewConnections(UniversalConnectionPoolImpl.java:988)
    at oracle.ucp.common.UniversalConnectionPoolBase.getInitialConnections(UniversalConnectionPoolBase.java:541)
    at oracle.ucp.common.UniversalConnectionPoolBase.start(UniversalConnectionPoolBase.java:655)
    at oracle.ucp.jdbc.PoolDataSourceImpl.startPool(PoolDataSourceImpl.java:271)
    ... 37 more
Caused by: java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:412)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:531)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:221)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503)
    at oracle.ucp.jdbc.DriverConnectionFactoryAdapter.createConnection(DriverConnectionFactoryAdapter.java:130)
    ... 44 more
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

    at oracle.net.ns.NSProtocol.connect(NSProtocol.java:385)
    at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1042)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:301)
    ... 49 more
1
Please post the entire stacktrace, and not just the message.Mark Rotteveel

1 Answers

0
votes

I fixed this issue by doing the following:

1) In my tnsnames.ora i added:

 (SID = XE)

to

XE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Lenovo-PC)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = XE)
      (SID = XE)
    )
  )

2) In listener.ora i added:

 (SID_DESC =
      (SID_NAME = XE)
      (ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
    )

to:

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (SID_NAME = XE)
      (ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
    )
  )

3) Restarted OracleServiceXE and OracleXETNSListener and it worked

Also after checking the stacktrace i saw this question was asked several times but it has many different answers so this would be my grain of sand :)