Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

on glassfish resource mapping via glassfish-ejb-jar.xml

TiminJul 8 2020

Hi all.

Can not understand what is wrong with glassfish resource mapping.

I've created a simple java ee application (NetBeans + Glassfish 5-0).

In my session bean i've included a ref to a global DataSource (which is working well)

[code]

@Resource (name = "jdbc/HRData")

    DataSource ds;[/code]

Then i've added glassfish-ejb-jar.xml descriptor and put this inside

[code]resource-ref>

        <res-ref-name>jdbc/HRData</res-ref-name>

        <jndi-name>jdbc/HRDataSource</jndi-name>

</resource-ref>[/code]

where jdbc/HRDataSource is my DataSource jndi name (which is working!)

When i try to deploy and test my client jsf i get

java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Ошибка соединения с сервером localhost на порту 1 527 с сообщением Connection refused: connect.

But if do  the resource mapping via mappedName in Resource annotation

[code]

@Resource (name = "jdbc/HRData", mappedName = "jdbc/HRDataSource")

    DataSource ds;[/code]

it works!!!

what is wrong with glassfish-ejb-jar.xml descriptor. The configuration folder where it is located seems to be included into the deployment profile...

Thanks in advance. Alex.

Comments
Post Details
Added on Jul 8 2020
0 comments
222 views