Discussion:
TomEE Plume 7.0.4/JDBC resource config/unused property
maciejka
2018-07-19 13:41:42 UTC
Permalink
Hello and welcome

I am using 'apache-tomee-plume-7.0.4' with java version '1.8.0_152' on
'Linux debian 3.16.0-4-amd64'

I have basic problem with datasource configuration. My datasource is
configured like (tried various configurations - Password=xxx, Password xxx,
password=xxx, passWord xxx....):

<Resource id="jdbc/xxx" type="DataSource">
jdbcDriver=oracle.jdbc.xa.client.OracleXADataSource
jdbcUrl=jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:xxx
UserName=xxx
Password=xxx
</Resource>

I put ojdbc.jar to tomee lib folder. During deployment of my app I have
warning like:

18-Jul-2018 16:35:13.799 INFO [main]
org.apache.openejb.assembler.classic.Assembler.createRecipe Creating
Resource(id=jdbc/xxx)
18-Jul-2018 16:35:13.900 WARNING [main]
org.apache.openejb.assembler.classic.Assembler.unusedProperty unused
property 'JdbcUrl' for resource 'jdbc/xxx'
18-Jul-2018 16:35:13.900 WARNING [main]
org.apache.openejb.assembler.classic.Assembler.unusedProperty unused
property 'UserName' for resource 'jdbc/xxx'
18-Jul-2018 16:35:13.900 WARNING [main]
org.apache.openejb.assembler.classic.Assembler.unusedProperty unused
property 'Password' for resource 'jdbc/xxx'
18-Jul-2018 16:35:13.900 WARNING [main]
org.apache.openejb.assembler.classic.Assembler.unusedProperty unused
property 'PasswordCipher' for resource 'jdbc/xxx'
18-Jul-2018 16:35:13.900 WARNING [main]
org.apache.openejb.assembler.classic.Assembler.unusedProperty unused
property 'asdf' for resource 'jdbc/xxx'

When I use my Resource like:

@Resource(name = "jdbc/xxx")
private DataSource ds;

java.sql.Connection connection = ds.getConnection();
Statement createStatement = connection.createStatement();
executeQuery = createStatement.executeQuery("...");


I get: java.sql.SQLException: ORA-01017: invalid username/password; logon
denied

but if I write:

java.sql.Connection connection = ds.getConnection("xxx", "xxx");
Statement createStatement = connection.createStatement();
executeQuery = createStatement.executeQuery("...");

it works.
Somehow 'jdbcUrl' was set on resource - despite the WARINING - and
'username' and 'password' were not.

Questions:
Why properties (username, password) set in tomee.xml for the datasource are
not taken into account and 'jdbcUrl' is?
How to trace this issue? I don't know where to search.



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Romain Manni-Bucau
2018-07-19 14:42:50 UTC
Permalink
Hi

Basically the tests " Password=xxx, Password xxx, password=xxx, passWord
xxx...." are all the same since we are not case sensitive.

However you didnt set oracle driver as jdbcdriver so our pool configuration
is bypassed by default and we use the oracle datasource as main
configuration for the real connection so you must configure the datasource
too, i.e User and Pass for oracle IIRC.

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>
Post by maciejka
Hello and welcome
I am using 'apache-tomee-plume-7.0.4' with java version '1.8.0_152' on
'Linux debian 3.16.0-4-amd64'
I have basic problem with datasource configuration. My datasource is
configured like (tried various configurations - Password=xxx, Password xxx,
<Resource id="jdbc/xxx" type="DataSource">
jdbcDriver=oracle.jdbc.xa.client.OracleXADataSource
UserName=xxx
Password=xxx
</Resource>
I put ojdbc.jar to tomee lib folder. During deployment of my app I have
18-Jul-2018 16:35:13.799 INFO [main]
org.apache.openejb.assembler.classic.Assembler.createRecipe Creating
Resource(id=jdbc/xxx)
18-Jul-2018 16:35:13.900 WARNING [main]
org.apache.openejb.assembler.classic.Assembler.unusedProperty unused
property 'JdbcUrl' for resource 'jdbc/xxx'
18-Jul-2018 16:35:13.900 WARNING [main]
org.apache.openejb.assembler.classic.Assembler.unusedProperty unused
property 'UserName' for resource 'jdbc/xxx'
18-Jul-2018 16:35:13.900 WARNING [main]
org.apache.openejb.assembler.classic.Assembler.unusedProperty unused
property 'Password' for resource 'jdbc/xxx'
18-Jul-2018 16:35:13.900 WARNING [main]
org.apache.openejb.assembler.classic.Assembler.unusedProperty unused
property 'PasswordCipher' for resource 'jdbc/xxx'
18-Jul-2018 16:35:13.900 WARNING [main]
org.apache.openejb.assembler.classic.Assembler.unusedProperty unused
property 'asdf' for resource 'jdbc/xxx'
@Resource(name = "jdbc/xxx")
private DataSource ds;
java.sql.Connection connection = ds.getConnection();
Statement createStatement = connection.createStatement();
executeQuery = createStatement.executeQuery("...");
I get: java.sql.SQLException: ORA-01017: invalid username/password; logon
denied
java.sql.Connection connection = ds.getConnection("xxx", "xxx");
Statement createStatement = connection.createStatement();
executeQuery = createStatement.executeQuery("...");
it works.
Somehow 'jdbcUrl' was set on resource - despite the WARINING - and
'username' and 'password' were not.
Why properties (username, password) set in tomee.xml for the datasource are
not taken into account and 'jdbcUrl' is?
How to trace this issue? I don't know where to search.
--
http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
maciejka
2018-07-19 15:26:52 UTC
Permalink
I am quite new to TomEE and maybe thats why I dont understand Your point.

You wrote 'you didnt set oracle driver as jdbcdriver'

Isn't below configuration setting oracle driver as jdbcdriver? :

<Resource id="jdbc/xxx" type="DataSource">
*jdbcDriver=oracle.jdbc.xa.client.OracleXADataSource *
...

You wrote 'you must configure the datasource too' - haven't I just done that
by defining Resource?

I used instruction from:
http://tomee.apache.org/datasource-config.html

Could You give a template of sample config?
Should I configure something more than:
<Resource id="jdbc/xxx" type="DataSource">...?






--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Romain Manni-Bucau
2018-07-19 15:32:49 UTC
Permalink
Actually JDBCDriver expects a Driver implementation, OracleXADataSource is
a datasource implementation. We tolerate it but in this case you must also
configure the underlying datasource instance.

More on http://tomee.apache.org/admin/configuration/resources.html and
http://tomee.apache.org/datasource-config.html (the very end for this one)
Post by maciejka
I am quite new to TomEE and maybe thats why I dont understand Your point.
You wrote 'you didnt set oracle driver as jdbcdriver'
<Resource id="jdbc/xxx" type="DataSource">
*jdbcDriver=oracle.jdbc.xa.client.OracleXADataSource *
...
You wrote 'you must configure the datasource too' - haven't I just done that
by defining Resource?
http://tomee.apache.org/datasource-config.html
Could You give a template of sample config?
<Resource id="jdbc/xxx" type="DataSource">...?
--
http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
maciejka
2018-07-20 10:41:10 UTC
Permalink
I am still a bit suprised but it works!
Final configuration looks like:


<Resource id="jdbc/xxx" type="DataSource">
jdbcDriver=oracle.jdbc.xa.client.OracleXADataSource
jdbcUrl=jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:xxx
UserName=xxx
Password=xxx
*user*=xxx -> as You said
*pass*=xxx -> as You said
</Resource>

Thx for help.



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Loading...