Can't find valid JDBC Driver (implementation class) for Hana in Websphere Liberty - websphere-liberty

I'm trying to connect a Websphere Liberty v16.0.0.4 to a HANA datasource, but I'm unable to find the right driver.
Currently in my server.xml I have the following:
<xml version="1.0" encoding="UTF-8">
<server description="o01-cls-pega-static-prpc02-appsrv03">
<!-- Enable features -->
<featureManager>
<feature>webProfile-7.0</feature>
<feature>localConnector-1.0</feature>
<feature>jdbc-4.1</feature>
<feature>ssl-1.0</feature>
<feature>servlet-3.1</feature>
<feature>ejb-3.2</feature>
<feature>ejbLite-3.2</feature>
<feature>ejbRemote-3.2</feature>
<feature>jndi-1.0</feature>
<feature>jms-2.0</feature>
<feature>jaxws-2.2</feature>
<feature>jaxb-2.2</feature>
<feature>restConnector-2.0</feature>
<feature>wmqJmsClient-2.0</feature>
<feature>jmsMdb-3.2</feature>
</featureManager>
<httpEndpoint id="defaultHttpEndpoint"
host="localhost"
httpPort="28740"
httpsPort="28741" />
<!-- JDBC Hana Driver -->
<jdbcDriver id="myHanaDriver" javax.sql.DataSource="com.ibm.ws.jdbc.jdbcDriver">
<library>
<fileset dir="${wlp.user.dir}/shared/resources/hana" includes="*.jar" id="HANALib"/>
</library>
</jdbcDriver>
<!-- HANA JDBC Databases -->
<dataSource
type="javax.sql.DataSource"
containerAuthDataRef="PegaDBUserSAPHANA"
id="hanaDataSource"
jdbcDriverRef="myHanaDriver"
jndiName="jdbc/hanaDataSource">
<properties serverName="localhost" port="35315"/>
</dataSource>
<applicationManager autoExpand="true"/>
</server>
This is the error I get:
[5/6/19 14:24:24:735 CEST] 00000038 LogService-156-com.ibm.ws.jdbc
E CWWKE0701E: FrameworkEvent ERROR Bundle:com.ibm.ws.jdbc(id=156) org.osgi.framework.ServiceException:
Exception in com.ibm.ws.resource.internal.ResourceFactoryTrackerData$1.getService()
Caused by: java.lang.RuntimeException: java.sql.SQLNonTransientException:
DSRA4000E: A valid JDBC driver implementation class was not found for the jdbcDriver jdbcDriver[myHanaDriver] using the library com.ibm.ws.classloading.sharedlibrary_587. [/opt/wlp/usr/shared/resources/hana/ngdbc.jar]
Caused by: java.sql.SQLNonTransientException:
DSRA4000E: A valid JDBC driver implementation class was not found for the jdbcDriver jdbcDriver[myHanaDriver] using the library com.ibm.ws.classloading.sharedlibrary_587. [/opt/wlp/usr/shared/resources/hana/ngdbc.jar]
Caused by: java.lang.ClassNotFoundException: com.ibm.ws.jdbc.jdbcDriver
Any one that can help me, get the right implementation class that I need?

You are correct that javax.sql.DataSource="com.ibm.ws.jdbc.jdbcDriver" is misconfigured. This should either point to the JDBC driver's implementation of javax.sql.DataSource, for example, javax.sql.DataSource="com.sap.dbtech.jdbcext.DataSourceSapDB"
or, for many JDBC drivers, newer versions of Liberty (but not the older 16.0.0.4 level that this question asks about) are often able to infer the correct implementation class if you omit this configuration attribute altogether.

I have it working now, I changed this:
javax.sql.DataSource="com.ibm.ws.jdbc.jdbcDriver"
into
javax.sql.ConnectionPoolDataSource="com.sap.db.jdbcext.ConnectionPoolDataSourceSAP"
And type="javax.sql.DataSource" into this type="javax.sql.ConnectionPoolDataSource".

Related

Spring-based web application fails at startup on WAS Liberty

I'm writing a simple Spring-based web application and deploy it to Websphere Liberty 8.5.5.9. The deployment fails because the application start fails. The message in console.log is
[ERROR ] CWWKZ0002E: An exception occurred while starting the application userSetting.
The exception message was: com.ibm.ws.container.service.metadata.MetaDataException:
com.ibm.wsspi.adaptable.module.UnableToAdaptException:
com.ibm.ws.javaee.ddmodel.DDParser$ParseException: CWWKC2262E: The server is
unable to process the 3.1 version and the http://xmlns.jcp.org/xml/ns/javaee namespace
in the /META-INF/web-fragment.xml deployment descriptor on line 23.
The last part of the message makes now sense since I don't hav /META-INF or /WEB-INF in the Eclipse project for the application, since I'm deploying with Gradle: gradle clean build deploy.
I've tried all kinds of modifications to the project and, in desperation, I've cut it down to only have the following source code:
#SpringBootApplication
public class UserSettingApplication {
private static final LoggerUtils logger = new LoggerUtils( UserSettingApplication.class );
public static void main(String[] args) {
logger.debug( "Entering UserSettingApplication.main()" );
SpringApplication.run(UserSettingApplication.class, args);
}
}
Can you please advise me how to fix this service start-up problem?
server.xml:
<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">
<!-- Enable features -->
<featureManager>
<feature>jsp-2.2</feature>
</featureManager>
<featureManager>
<feature>adminCenter-1.0</feature>
</featureManager>
<!-- Define the host name for use by the collective.
If the host name needs to be changed, the server should be
removed from the collective and re-joined. -->
<variable name="defaultHostName" value="localhost" />
<!-- Define an Administrator and non-Administrator -->
<basicRegistry id="basic">
<user name="admin" password="********" />
<user name="nonadmin" password="***********" />
</basicRegistry>
<!-- Assign 'admin' to Administrator -->
<administrator-role>
<user>admin</user>
</administrator-role>
<keyStore id="defaultKeyStore" password="*******" />
<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint id="defaultHttpEndpoint"
host="*"
httpPort="9080"
httpsPort="9443" />
<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="false"/>
</server>
This error appears to be caused by some of your build tooling generating a web-fragment.xml with a Servlet 3.1 schema.
Currently, you have the jsp-2.2 feature enabled, which by default enables servlet-3.0.
To fix the problem, I would recommend upgrading from jsp-2.2 to jsp-2.3 (which will pull in servlet-3.1), or adding <feature>webProfile-7.0</feature> to just enable all of the Java EE 7 web profile features (servlet, JPA, bean validation, cdi, jsf, etc).
So your new server.xml could look like this:
<server description="new server">
<!-- Enable features -->
<featureManager>
<feature>jsp-2.3</feature>
<feature>adminCenter-1.0</feature>
</featureManager>
<!-- rest of file unchanged.... -->

Websphere Liberty AdminCenter login does not work when custom JAAS context is defined

I am new to WebSphere Liberty profile. I am working on 17.0.0.4 version. What I am trying to achieve is to have custom JAAS login setup for the application. The application works fine on WebSphere 8.5.
I have reviewed so many link from IBM Knowledge Center for the same, but got result with either or with JAAS custom login, but not both of them together. With WebSphere 8.5 we are having level of hierarchy to decide which authentication mechanism goes where, but with Liberty if I setup Custom JAAS authentication mechanism then I can't login to WebSphere Liberty AdminCenter, and if I configure server.xml for , then it does not authenticate my application's user (because it is designed to get authenticate users via JAAS).
Here is my server.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">
<!-- Enable features -->
<featureManager>
<feature>adminCenter-1.0</feature>
<feature>ssl-1.0</feature>
<feature>webProfile-7.0</feature>
<feature>appSecurity-2.0</feature>
</featureManager>
<keyStore id="defaultKeyStore" password="WASLiberty" />
<!-- Admin Center username/password -->
<!--<quickStartSecurity userName="admin" userPassword="admin123" />-->
<!-- Define an Administrator and non-Administrator -->
<basicRegistry id="basic">
<user name="admin" password="{xor}PjsyNjFubWw=" /> <!-- Encoded version of "admin123" -->
<user name="nonadmin" password="nonadmin123" />
</basicRegistry>
<!-- Assign 'admin' to Administrator -->
<administrator-role>
<user>admin</user>
</administrator-role>
<!-- JNDI Connection configuration -->
<dataSource id="MY_CUSTOM_DS" jndiName="jdbc/MY_CUSTOM_DS">
<jdbcDriver libraryRef="sqlserverjdbc"/>
<properties.microsoft.sqlserver databaseName="mydb"
serverName="localhost" portNumber="1433"
user="sa" password="root" />
</dataSource>
<!-- JDBC Driver file location -->
<library id="sqlserverjdbc">
<file name="${wlp.install.dir}/lib/sqljdbc4.jar"/>
</library>
<library id="MyLoginModuleLib">
<fileset dir="${wlp.install.dir}/lib" includes="custom_auth.jar"/>
</library>
<!-- JAAS Login Module for web application -->
<jaasLoginModule id="myCustom"
className="com.kana.auth.websphere.MyLoginModule"
controlFlag="REQUIRED" libraryRef="MyLoginModuleLib">
<options myOption1="value1" myOption2="value2"/>
</jaasLoginModule>
<!-- JAAS Login Context -->
<jaasLoginContextEntry id="system.WEB_INBOUND" name="system.WEB_INBOUND"
loginModuleRef="myCustom, hashtable, userNameAndPassword, certificate, token" />
<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint id="defaultHttpEndpoint"
host="*"
httpPort="9080"
httpsPort="9443" />
<webApplication contextRoot="mywebapp" location="mywebapp.war" />
<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true"/>
<!-- Enable remote file access -->
<remoteFileAccess>
<writeDir>${server.config.dir}</writeDir>
</remoteFileAccess>
</server>
Can anyone please point out where I am making mistake?
If you are using custom JAAS login module, then your custom JAAS login module need to ignore the admin center authentication and let the default login modules handle it.
The better option is to use custom TAI to handle application authentication and let the default login modules handle the admin center authentication.
Regards,
Ut Le
Many many thanks Ut Le for providing solution.
From the log file, found that the root cause was ClassNotFound exception. It does not have class which I was pointing to from <jaasLoginModule>. Later on found that I was pointing to jar file which is not at that location. So that was a silly mistake I made for configuration.

Application is not working in WebSphere

I deployed WAR file on Websphere console and mapped it to datasource. I am able to test the datasource which I configured with PostgreSQL server details. But my application is not connecting to the server. I am new to WebSphere and could anyone please help me to configure the datasource based on the below context.xml file. My application works well in tomcat but not in Websphere.
I think am doing something wrong in the datasource configuration.
<Resource
name="jdbc/domains/ABC" url="jdbc:postgresql://localhost:5432/postgres"
initConnectionSqls="SET search_path TO my_schme;"
username="abccc"
password="******"
auth="Container"
type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver"
validationQuery="select 1"
initialSize="5"
maxActive="20"
maxIdle="10"
maxWait="-1"
/>
Here is an example based on the most common way to configure data sources in WebSphere Application Server Liberty -- in server.xml (it is also possible to define within the application via the standard #DataSourceDefinition annotation or deployment descriptor, which would be a separate example)
In server.xml,
<featureManager>
<feature>jdbc-4.2</feature>
<feature>jndi-1.0</feature>
... other features
</featureManager>
<dataSource id="ABC" jndiName="jdbc/domains/ABC" type="javax.sql.ConnectionPoolDataSource" validationTimeout="30s">
<jdbcDriver libraryRef="PostGreLib" javax.sql.ConnectionPoolDataSource="org.postgresql.ds.PGConnectionPoolDataSource"/>
<properties url="jdbc:postgresql://localhost:5432/postgres"/>
<containerAuthData user="abccc" password="******"/>
<connectionManager maxPoolSize="20" connectionTimeout="-1"/>
<!-- no equivalents for initialSize and maxIdle -->
<onConnect>SET search_path TO my_schme;</onConnect>
</dataSource>
<library id="PostGreLib">
<file name="C:/PostGreSQL/postgresql-42.1.4.jar"/>
</library>
Here are some helpful knowledge center articles on data source configuration in WebSphere Application Server Liberty,
https://www.ibm.com/support/knowledgecenter/en/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/twlp_dep_configuring_ds.html
https://www.ibm.com/support/knowledgecenter/en/SSEQTP_liberty/com.ibm.websphere.liberty.autogen.base.doc/ae/rwlp_feature_jdbc-4.2.html

Unable to use JCA CICS resource with IBM WebSphere Application Server Liberty Profile

I'm trying to setup WLP for an existing EAR application.
This setup works fine with WAS 9 traditional.
The problem is the JCA CICS Resource Adapter call.
The server.xml :
<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">
<!-- Enable features -->
<featureManager>
<feature>javaee-7.0</feature>
</featureManager>
<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint id="defaultHttpEndpoint"
host="*"
httpPort="9080"
httpsPort="9443" />
<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true"/>
<library id="sharedLibs">
<fileset dir="/work/sharedlibs" includes="*.jar"/>
<folder dir="/work" />
</library>
<resourceAdapter
autoStart="true"
id="eciResourceAdapter"
location="/work/cicseci.rar">
</resourceAdapter>
<connectionFactory id="CTGDV06" jndiName="jca/CTGDV06" >
<properties.eciResourceAdapter.javax.resource.cci.ConnectionFactory
connectionUrl="tcp://*******"
serverName="*******"
userName="*******"
portNumber="2006"
/>
</connectionFactory>
<application type="ear" id="app" location="app.ear" name="app">
<classloader
commonLibraryRef="sharedLibs"
classProviderRef="eciResourceAdapter" />
</application>
</server>
in ibm-web-bnd.xml :
<resource-ref name="cicsjca" binding-name="jca/CTGDV06"></resource-ref>
in web.xml :
<resource-ref id="ResourceRef_Cics_Jca">
<description>Acces CICS</description>
<res-ref-name>cicsjca</res-ref-name>
<res-type>javax.resource.cci.ConnectionFactory</res-type>
<res-auth>Application</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
Startup is Ok, but access to JCA fail with :
java.lang.Exception: Lookup for java:comp/env/cicsjca failed. Exception: javax.naming.NamingException: CWNEN1001E: The object referenced by the java:comp/env/cicsjca JNDI name could not be instantiated. If the reference name maps to a JNDI name in the deployment descriptor bindings for the application performing the JNDI lookup, make sure that the JNDI name mapping in the deployment descriptor binding is correct. If the JNDI name mapping is correct, make sure the target resource can be resolved with the specified name relative to the default initial context.
[Root exception is com.ibm.wsspi.injectionengine.InjectionException: CWNEN0030E: The server was unable to obtain an object instance for the java:comp/env/cicsjca reference. The exception message was: CWNEN1003E: The server was unable to find the jca/CTGDV06 binding with the javax.resource.cci.ConnectionFactory type for the java:comp/env/cicsjca reference.]
I don't understand what's wrong with this setup, any help would be apreciated !
The correct configuration depends on how many connection factory implementations are provided by the resource adapter.
If the resource adapter provides only a single connection factory (which is commonly the case for many resource adapters), then configuration would be:
<connectionFactory id="CTGDV06" jndiName="jca/CTGDV06" >
<properties.eciResourceAdapter
connectionUrl="tcp://*******"
serverName="*******"
userName="*******"
portNumber="2006"
/>
</connectionFactory>
Full detail on how to specify configuration for JCA resource adapters in Liberty can be found here in the knowledge center.

Configuring Oracle dataSource settings on WAS Liberty (WL ) - failure

I am receiving below exception. on Liberty console & in browser.
javax.servlet.ServletException: Worklight Console initialization failed.Logged Exception: com.worklight.server.database.api.WorklightDataSourceException: FWLSE0194E: MobileFirst Server cannot be started because of failure while getting a connection from data-source bound to resource reference: jdbc/WorklightDS. Make sure the database is up, the credentials are correct and the driver is available for the server. [project worklight]
at com.worklight.core.auth.impl.AuthenticationFilter.verifyServletInitialized(AuthenticationFilter.java:451)
at com.worklight.core.auth.impl.AuthenticationFilter.doFilter(AuthenticationFilter.java:138)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:194)
at [internal classes]
When running/viewing an app (war) on a UAT machine having below configuration.
Environment:
WL 6.3 EE
WAS Liberty Core V8.5.5.4
Oracle 11g
Windows Server 2012 R2
worklight.properties
publicWorkLightHostname=localhost
publicWorkLightProtocol=http
publicWorkLightPort=9080
wl.db.url=jdbc:oracle:thin:#10.100.11.1:1529:gmaxem
wl.db.username=WRKLIGHT
wl.db.password=wrklight
wl.reports.db.url=jdbc:oracle:thin:#10.100.11.1:1529:gmaxem
wl.reports.db.username=WLRREPOR
wl.reports.db.password=wlrrepor
Web.xml
<resource-ref>
<description>Worklight Server Database</description>
<res-ref-name>jdbc/WorklightDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>Reports Database</description>
<res-ref-name>jdbc/WorklightReportsDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Liberty - server.xml
<application id="worklight" name="worklight" location="myapp.war" type="war" context-root="/worklight" >
<classloader delegation="parentLast">
<privateLibrary id="worklightlib_worklight">
<fileset dir="${shared.resource.dir}/lib" includes="worklight-jee-library.jar"/>
</privateLibrary>
</classloader>
</application>
<jndiEntry value="9080" jndiName="publicWorkLightPort"/>
<jndiEntry value="localhost" jndiName="publicWorkLightHostname"/>
<jndiEntry value="http" jndiName="publicWorkLightProtocol"/>
<jndiEntry value="10" jndiName="serverSessionTimeout"/>
<library id="OracleLib">
<fileset dir="${shared.resource.dir}/oracle" includes="*.jar"/>
</library>
<dataSource jndiName="jdbc/AppCenterDS" transactional="false">
<jdbcDriver libraryRef="OracleLib"/>
<properties.oracle driverType="thin" URL="jdbc:oracle:thin:#10.100.11.1:1529:gmaxem" user="WLAPPCENTER" password="wlappcenter"/>
</dataSource>
<dataSource jndiName="worklight/jdbc/WorklightDS" transactional="false">
<jdbcDriver libraryRef="OracleLib" />
<properties.oracle driverType="thin" url="jdbc:oracle:thin:#10.100.11.1:1529:gmaxem" user="WRKLIGHT" password="wrklight" />
</dataSource>
<dataSource jndiName="worklight/jdbc/WorklightReportsDS" transactional="false">
<jdbcDriver libraryRef="OracleLib" />
<properties.oracle driverType="thin" url="jdbc:oracle:thin:#10.100.11.1:1529:gmaxem" user="WLRREPOR" password="wlrrepor" />
</dataSource>
I have also copied:
jdbc jar (ojdbc6.jar) at Liberty\usr\shared\resources\oracle
worklight-jee-library.jar at Liberty\usr\shared\resources\lib
myapp.war at Liberty\usr\servers\WorklightServer\apps
The apps folder on Liberty contains only these 3 war files.
myapp.war
appcenterconsole.war
applicationcenter.war
The error message mentions jdbc/WorklightDS, therefore the configuration mistake must be in the <dataSource jndiName="worklight/jdbc/WorklightDS" ...> element.
You are using the syntax url="jdbc:oracle:thin:#//10.100.11.1:1529/WRKLIGHT" which is the syntax for a JDBC URL with a service name, but WRKLIGHT is probably not the service name but the SID of your database. (Service names usally include some dots.)
You have two options:
Use the syntax which references the SID: url="jdbc:oracle:thin:#10.100.11.1:1529:WRKLIGHT"
Look up the service name in the file ORACLE_HOME\network\admin\tnsnames.ora, and use this service name in the URL, instead of WRKLIGHT.
Error in update 2: javax.servlet.ServletException: Worklight Console initialization failed.Logged Exception: java.lang.RuntimeException: FWLSE0206E: The project /worklight failed to initialize, because the project database schema for data source jdbc:oracle:thin:#10.100.11.1:1529:gmaxem is from version N/A, which is not supported by the server from version 6.3.0.00.20141127-1357. Use the MobileFirst ant tasks to upgrade the project database schema. [project worklight
This means that the connection to the database worked but that the tables that are expected to be in the table were not found.
If you install manually, you need to create the schema of the tables.
https://www-01.ibm.com/support/knowledgecenter/SSHS8R_6.3.0/com.ibm.worklight.installconfig.doc/admin/t_config_oracle_DB_manually_for_wladmin.html
Solved
This issue has been resolved.
Unfortunately my client had not created WLADMIN database at all and I was told that it does exists. Plus app center database was having wrong tables created as I mentioned in another post.
I was not given privileges to install any db tool to interact/see the databases structure.
Note: - The above mentioned configuration is correct and is working fine.
might be useful to someone, it should be '/' separator for port name and service name
<dataSource beginTranForResultSetScrollingAPIs="true" beginTranForVendorAPIs="false" commitOrRollbackOnCleanup="rollback" connectionManagerRef="default-conn-mgr" isolationLevel="TRANSACTION_READ_COMMITTED" jndiName="jdbc/test" transactional="true" type="javax.sql.ConnectionPoolDataSource">
<jdbcDriver libraryRef="oracleJDBCJars"/>
<properties.oracle URL="jdbc:oracle:thin:#my-host.name.xxx.com:portnumber/service.name.com" password="xxx" user="test_usr"/>

Resources