Topic
  • 2 replies
  • Latest Post - ‏2012-10-07T06:04:41Z by SystemAdmin
alicinar
alicinar
2 Posts

Pinned topic DataSource problem with Websphere Liberty Profile Please Help

‏2012-08-10T12:43:15Z |
Liberty Profile start is exception:
err javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter,
or in an application resource file: java.naming.factory.initial
err at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:673)
err at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:318)
err at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:355)
err at javax.naming.InitialContext.lookup(InitialContext.java:422)
err at com.avrupayazilim.bmd.base.BMDTransaction.initDBConnectionPool(*BMDTransaction.java:46*)
err at com.avrupayazilim.bmd.base.BMDTransaction.<clinit>(BMDTransaction.java:34)
BMDTransaction:
javax.naming.Context ctx = new javax.naming.InitialContext();
ds = (DataSource) ctx.lookup("jdbc/ORACLE_WRLD");//Nameing

Liberty Server.xml:

<dataSource jndiName="jdbc/ORACLE_WRLD" type="javax.sql.DataSource" jdbcDriverRef="OracleRef">
<properties user="ali" password="{xor}KjAvNjEr" portNumber="1521" URL="jdbc:oracle:thin:@192.168.1.5:1521:ORCL" databaseName="ORCL" serverName="192.168.1.5" ref="ORACLE_WRLD" />
</dataSource>

<jdbcDriver id="OracleRef" libraryRef="OracleLib"
javax.sql.DataSource="oracle.jdbc.pool.OracleDataSource" />

<library id="OracleLib" name="OracleLib">
<fileset dir="c:\OracleLib" includes="ojdbc6.jar" />
</library>
Updated on 2012-10-07T06:04:41Z at 2012-10-07T06:04:41Z by SystemAdmin
  • alicinar
    alicinar
    2 Posts

    Re: DataSource problem with Websphere Liberty Profile Please Help

    ‏2012-08-10T13:02:41Z  
    This problem solved.
    I defined a jdbc-4.0 with a featureManager.

    <featureManager>
    <feature>jdbc-4.0</feature> ///problem solved
    </featureManager>
  • SystemAdmin
    SystemAdmin
    37422 Posts

    Re: DataSource problem with Websphere Liberty Profile Please Help

    ‏2012-10-07T06:04:41Z  
    • alicinar
    • ‏2012-08-10T13:02:41Z
    This problem solved.
    I defined a jdbc-4.0 with a featureManager.

    <featureManager>
    <feature>jdbc-4.0</feature> ///problem solved
    </featureManager>
    I had a similar issue, even whit the jdbc-4.0 feature, what i need to do is inject the data source through a Resource annotation, like this:

    /**
    * Application Lifecycle Listener implementation class ContextLoaderListener
    *
    */
    @WebListener
    @Resource(type=DataSource.class, name="jdbc/MyDB")
    public class ContextLoaderListener implements ServletContextListener {
    .....
    }

    And you need to have a resource reference in your web.xml to that data source.