java - DataSource initialization error within liberty profile server -
i trying set datasource in liberty profile server, i'm getting nullpointerexception
(on ds variable below) when code tries use it.
the relevant code, , server.xml
entries below. interestingly, if change jndiname java:comp/env/jdbc/oracle
illegalargumentexception
on server startup, config below doesn't seem try activate datasource...
public abstract class daobase { //@resource(name = "jdbc/oracle", type = javax.sql.datasource.class, shareable = true, authenticationtype = authenticationtype.container) @resource(lookup = "jdbc/oracle") private datasource ds; protected connection getconnection() throws sqlexception { connection conn = ds.getconnection(); return conn; }
my server.xml
config:
<featuremanager> <feature>jsp-2.2</feature> <feature>jaxrs-1.1</feature> <feature>localconnector-1.0</feature> <feature>appsecurity-2.0</feature> <feature>jpa-2.0</feature> <feature>jdbc-4.0</feature> <feature>jndi-1.0</feature> </featuremanager> <library id="oraclejdbc_id"> <fileset dir="c:\src\main\lib" includes="ojdbc6.jar"/> </library> <jdbcdriver id="oracledriver" libraryref="oraclejdbc_id"/> <datasource jdbcdriverref="oracledriver" jndiname="jdbc/oracle"> <properties.oracle url="jdbc:oracle:thin:@ldap://oid:***/opl***,cn=oraclecontext,dc=****,dc=com" password="****" user="*****"/> </datasource>
error in log:
[error ] cwwke0701e: [com.ibm.ws.jdbc.datasource(200)] modified method has thrown exception bundle:com.ibm.ws.jdbc(id=82) java.lang.illegalargumentexception: j2ca8011e: value java:comp/env/jdbc/oracle not supported jndiname on datasource @ com.ibm.ws.jdbc.datasourceservice.activate(datasourceservice.java:209) @ [internal classes]
edit: code in base class our data access layer. we're calling in restful web service via plain initialization:
auditdao auditdao = new auditdao();
the @resource
not work in pojo unless activate cdi. try following:
- add beans.xml file
web-inf
folder, , add cdi feature
<feature>cdi-1.0</feature>
- inject auditdao web service using
@inject auditdao auditdao
- use following reference in dao
@resource(name="jdbc/oracle", lookup = "jdbc/oracle") private datasource ds;
Comments
Post a Comment