Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Oracle11g rejects my credentials w JPA/EclipseLink but works w JDBC

277354Jan 17 2013 — edited Jan 14 2015
I am converting a Java app using JPA/EclipseLink/Hibernate from H2 to Oracle 11g. But my credentials get rejected when I try to connect. It works fine using plain old JDBC (see below).

I have tried changing persistence.xml in numerous ways, as listed at the end of this post, but in any configuration with any variation it works fine with JDBC but fails with EclipseLink/Hibernate. Since everything works fine with H2 I wanted to see it there might be an Oracle difference that is causing this first - before I post it on an EclipseLink forum. I have verified that Tomcat and Eclipse are using the same Java version (1.6.0_29) and am using the correct ojdbc6 as linked from the Oracle page where I downloaded Oracle 11g. I've made sure there are no other versions of these anywhere in the classpath. (BTW - Don't worry that I've listed my password, this is an internal system for dev only.) Thank you so very much in advance.

1. THE ERROR:

[EL Info]: 2013-01-17 09:37:48.746--ServerSession(7475052)--EclipseLink, version: Eclipse Persistence Services - 2.4.1.v20121003-ad44345
[EL Severe]: ejb: 2013-01-17 09:37:48.84--ServerSession(7475052)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: ORA-01017: invalid username/password; logon denied
Error Code: 1017

2. JDBC WORKS JUST FINE:

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection(
"jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)" +
"(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl.catmktg.com)))", "JIMC", "Abc12345");
CallableStatement stmt = conn.prepareCall("select * from SHOPPER");
stmt.clearParameters();
java.sql.ResultSet rs = stmt.executeQuery();
String s = rs.getString("SHOPPERNUMBER");

3. ECLIPSE/HIBERNATE FAILS:

<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl.catmktg.com)))"/>
<property name="javax.persistence.jdbc.username" value="JIMC"/>
<property name="javax.persistence.jdbc.password" value="Abc12345"/>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>
<property name="hibernate.connection.url" value="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl.catmktg.com)))"/>
<property name="hibernate.connection.username" value="JIMC"/>
<property name="hibernate.connection.password" value="Abc12345"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
<property name="eclipselink.ddl-generation.output-mode" value="database" />

4. WHAT I HAVE TRIED:

- Only JDBC driver/URL/username/password versus only Hibernate
- Putting the credentials in the URL instead of properties: ;UID=JIMC;PWD=Abc12345 -OR- ;User ID=JIMC;Password=Abc12345 -OR- other such variations
- Using the SID (orcl) instead of the service name
- Replacing the DESCRIPTION list with a conventional DB connection string
- Using the oci8 or krpb drivers
- Switching back to H2 again, instead of Oracle, to keep verifying that JPA/EclipseLink/Hibernate works fine with another DBMS
- Using the Oracle10gDialect
etc.

5. FOR THOSE THAT MIGHT WANT DETAILS, I TURNED ON ALL LOGGING FOR ECLIPSELINK/SQL:

[EL Finer]: 2013-01-17 10:23:03.701--Thread(Thread[http-8080-2,5,main])--fixUNC: before fixing: url = file:/C:/Users/JimC/workspace/OfferDistributionAccess/bin/, authority = , file = /C:/Users/JimC/workspace/OfferDistributionAccess/bin/ (There is no English translation for this message.)
[EL Finer]: 2013-01-17 10:23:03.811--Thread(Thread[http-8080-2,5,main])--fixUNC: after fixing: url = file:/C:/Users/JimC/workspace/OfferDistributionAccess/bin/, authority = null, file = /C:/Users/JimC/workspace/OfferDistributionAccess/bin/ (There is no English translation for this message.)
[EL Finer]: 2013-01-17 10:23:03.837--Thread(Thread[http-8080-2,5,main])--fixUNC: before fixing: url = file:/C:/Users/JimC/workspace/ShopperHistoryAccess/bin/, authority = , file = /C:/Users/JimC/workspace/ShopperHistoryAccess/bin/ (There is no English translation for this message.)
[EL Finer]: 2013-01-17 10:23:03.838--Thread(Thread[http-8080-2,5,main])--fixUNC: after fixing: url = file:/C:/Users/JimC/workspace/ShopperHistoryAccess/bin/, authority = null, file = /C:/Users/JimC/workspace/ShopperHistoryAccess/bin/ (There is no English translation for this message.)
[EL Finer]: jpa: 2013-01-17 10:23:04.008--Thread(Thread[http-8080-2,5,main])--JavaSECMPInitializer - predeploying persistence-distribution.
[EL Finest]: properties: 2013-01-17 10:23:04.134--ServerSession(12974590)--Thread(Thread[http-8080-2,5,main])--property=eclipselink.logging.logger; value=JavaLogger; translated value=org.eclipse.persistence.logging.JavaLog
Jan 17, 2013 10:23:17 AM org.eclipse.persistence.session.file:/C:/Users/JimC/workspace/OfferDistributionAccess/bin/_persistence-distribution
INFO: EclipseLink, version: Eclipse Persistence Services - 2.4.1.v20121003-ad44345
Jan 17, 2013 10:23:17 AM org.eclipse.persistence.session.file:/C:/Users/JimC/workspace/OfferDistributionAccess/bin/_persistence-distribution.ejb
SEVERE:
Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: ORA-01017: invalid username/password; logon denied
Error Code: 1017
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:319)
at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:138)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:685)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:215)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:542)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:186)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:278)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:304)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:282)
at com.catalinamarketing.offerdistribution.BaseDistributionDao.createSingleUseEntityManager(BaseDistributionDao.java:549)
at com.catalinamarketing.offerdistribution.BaseDistributionDao.ensureDatabaseIsOpen(BaseDistributionDao.java:525)
at com.catalinamarketing.offerdistribution.JPADistributionDao.logShopperVisit(JPADistributionDao.java:354)
at com.catalinamarketing.offerdistribution.OfferDistributionEngine.logShopperVisit(OfferDistributionEngine.java:319)
at com.catalinamarketing.www.offerdistribution.OfferDistributionServiceCoupler.logShopperVisit(OfferDistributionServiceCoupler.java:185)
at com.catalinamarketing.www.offerdistribution.OfferDistributionSOAPImpl.logShopperVisit(OfferDistributionSOAPImpl.java:17)
at com.catalinamarketing.www.offerdistribution.OfferDistributionSOAPSkeleton.logShopperVisit(OfferDistributionSOAPSkeleton.java:137)
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 org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
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.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:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.sql.SQLException: ORA-01017: invalid username/password; logon denied
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:389)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:382)
at oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:600)
at oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:445)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:380)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:760)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:401)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:236)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:98)
... 43 more

-Jim

BTW - I have not run the Oracle diagnostic logging because of the dreadful time-consuming hack that it is. I fought with it for a day and a half before I came across this URL about it:
http://www.robert-stupp.de/blog/2008/01/oracle_malicious_11g_data_source_implementation.html

Edited by: james_clack on Jan 17, 2013 8:59 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 15 2013
Added on Jan 17 2013
1 comment
943 views