Forum Stats

  • 3,838,667 Users
  • 2,262,392 Discussions
  • 7,900,730 Comments

Discussions

Not able to use OEP defined datasources

Olivier Dubois - Oscars
Olivier Dubois - Oscars Member Posts: 12 Blue Ribbon
edited Sep 3, 2014 8:26AM in Complex Event Processing

Hi OEP Team,

I migrated my project 11g in 12c SOA and JDev with success, but I can't connect database using my datasource

   <data-source>

        <name>DATASOURCE_GIPCORE</name>

        <data-source-params>

            <jndi-names>

                <element>DsGipCore</element>

            </jndi-names>

            <global-transactions-protocol>OnePhaseCommit</global-transactions-protocol>

        </data-source-params>

        <connection-pool-params>

            <credential-mapping-enabled></credential-mapping-enabled>

            <test-table-name>SQL SELECT 1 FROM DUAL</test-table-name>

            <initial-capacity>5</initial-capacity>

            <max-capacity>60</max-capacity>

            <capacity-increment>1</capacity-increment>

        </connection-pool-params>

        <driver-params>

            <use-xa-data-source-interface>true</use-xa-data-source-interface>

            <driver-name>oracle.jdbc.OracleDriver</driver-name>

            <url>jdbc:oracle:thin:@localhost:1521:CHITA</url>

            <properties>

                <element>

                    <value>gipcore</value>

                    <name>user</name>

                </element>

                <element>

                    <value>{AES}xklE7q1n6KMBzrOkVJtQTQ==</value>

                    <name>password</name>

                </element>

            </properties>

        </driver-params>

    </data-source>

When using

    Context initialContext = new InitialContext ();       

          

            Object obj  = initialContext.lookup ("DsGIPCore");                         

    //gets the data source from context

    DataSource ds = (javax.sql.DataSource)obj;

I get this "javax.naming.NameNotFoundException; remaining name DsGIPCore"

I also tried with @Resource like described in docs but nothing works. My datasource is valid and working rightly. It appears without any errors in my WLEVS/OEP dashboard.

This code was working with OEP 11G, did you change anything to access OEP datasource? I need it.

It seems that datasource is right when using standard bean/table cache.

Regards,

Olivier

Answers

  • Hi Oliver,

    You have registered test table.

    Do you have any errors when OEP server starts?

    Do you have data source issue only when you are trying to use it from Java class but all works fine with table epn stage?

    Regards,

    Vitaly.

  • Olivier Dubois - Oscars
    Olivier Dubois - Oscars Member Posts: 12 Blue Ribbon

    Hi Vitaly,

    No error with datasource when starting . It works because I tried to make it wrong and I had an error message.

    It works within OEP but not via java classes, that's right.

    It seems that I am not using the right name/namespace for datasource with initialContext but I can't find any solution.

    Regards,

    Olivier

  • Hi Oliver,

    Can you try the next approach:

        @Resource(name="DATASOURCE_GIPCORE")

        public void setDataSource(DataSource ds)

        {

            m_ds = ds;

        }

    The problem can be that your jndi/name is not recognized.

    Regards,

    Vitaly.

  • Olivier Dubois - Oscars
    Olivier Dubois - Oscars Member Posts: 12 Blue Ribbon

    Hi,

    I tried but nothing change. The code was working in release 11g, but not working since I try in 12c.

    Did you try datasources in 12C? Perhaps, namespace are different?

    Regards,

    Olivier

  • Hi Oliver,

    the described above approach works exactly in 12c.(just checked it again)

    It's important that you have to use datasource name but not datasource jndi name here.

    What jdk version are you using?

    What OS are you using?

    Are there any errors/warnings during OEP server startup?

    Can you check with a new simple scenario not migrated code but completely new one?

    Regards,

    Vitaly.

  • Olivier Dubois - Oscars
    Olivier Dubois - Oscars Member Posts: 12 Blue Ribbon

    Hi,

    I just started from scratch to test different use case.

    In fact, the @resource work when the class is the one from the bean itself. My case was that I used another subclass to make the connection. This is the reason why the @resource was not ok with me.

    The jndi mode using initialcontext does not work at all for me. You need to adapt the documentation if we could not use this anymore.

    I will send you my project via email using a simple use case.

    Summary:

    1. Using an event bean, initial context is not working (in constructor), but @resource works and I can use my connection in a thread (after the initialisation of the bean).

    2. Using an bean used to load a specific context and cache, initial context is not working (in constructor), but @resource works, but I need to have the connection when my bean start (in the constructor). I does not work due to initialisation mode of the bean. I also tried init-method in bean definition but nothing works. A good option would be to use initial context, but not working.

    What do you think about point 2? How do I have access to datasource in a constructor of a standard bean?

    PS: The code I had was working in 11g, it seems that 12c changes some rules. But this is always the case when migrating...

    Regards,

    Olivier

  • Olivier Dubois - Oscars
    Olivier Dubois - Oscars Member Posts: 12 Blue Ribbon

    Hi Vitaly,

    Did you test anything on my usecase?

    Can you provide me feedback on this topic?

    Regards,

    Olivier

This discussion has been closed.