An attempt was made to retrieve an initial context for [ClassName] but no JNDI feature is configured - websphere

I am using the IBM WebSphere Application server v8.5 Liberty Profile. I have enabled the feature jndi-1.0 in server.xml by adding
<feature>jndi-1.0</feature>
But still I get the error "An attempt was made to retrieve an initial context for [ClassName] but no JNDI feature is configured."
Any idea what I may be doing wrong?

Related

How to log Websphere connection pool information like active connections in spring boot application

We are using Websphere liberty 20.0.0.12 and spring boot (parent) version 2.0.5.
I can find the connection pool information in the JConsole.
How can I print Websphere connection pool information in application logs?
(Read comments of approved answer if using liberty server instead of traditional websphere application server)
IBM support doc at https://www.ibm.com/support/pages/how-enable-connection-pool-trace-websphere-application-server describes how to enable printing of various connection pool stats in the trace log for traditional WAS, for Liberty, you'll use the same trace specification WAS.j2c=all:RRA=all(you don't need Transaction) and put a logging element in your server config file (typically server.xml). See Liberty doc at https://openliberty.io/docs/latest/log-trace-configuration.html for more info.

javax.naming.NoInitialContextException: Unable to find the InitialContextFactory com.tibco.tibjms.naming.TibjmsInitialContextFactory

I have developed TIBCO EMS standalone client developed which is used in Adobe Livecycle to send requests to tibco queue. Getting the below error.
Going by the error, not able to load InitialContextFactory.
Error snapshot below.
javax.naming.NoInitialContextException: Unable to find the InitialContextFactory com.tibco.tibjms.naming.TibjmsInitialContextFactory.
org.apache.aries.jndi.ContextHelper.getInitialContext(ContextHelper.java:149)
org.apache.aries.jndi.OSGiInitialContextFactoryBuilder.getInitialContext(OSGiInitialContextFactoryBuilder.java:50)
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:696)
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:319)
javax.naming.InitialContext.init(InitialContext.java:254)
javax.naming.InitialContext.<init>(InitialContext.java:228)
com.citigroup.gsu.edelivery.engine.utils.TibcoEMS.ServiceLocator.getInstance(ServiceLocator.java:34)
com.citigroup.gsu.edelivery.engine.utils.TibcoEMS.TibcoEMSClient.SendTibcoEMSMessage(TibcoEMSClient.java:36)
Code snippet details below.
TibcoEMSClient.java:36
serviceLocator = ServiceLocator.getInstance(user,password, providerUrl);
ServiceLocator.java:34
env.put(Context.INITIAL_CONTEXT_FACTORY, providerContextFactory);
env.put(Context.PROVIDER_URL, providerUrl);
ic = new InitialContext(env);
Please help.
Looks like classpath issue. You need to add tibjms.jar to your project classpath or to the applications server classpath. The Jar file you can get from tibco installation folder for example C:\tibco\ems\6.0\lib or download from tibco web site. If you are using ssl you may also need tibcrypt.jar
How to add tibjms.jar to classpath depends on your application server.
For WebSphere this document may help https://docs.tibco.com/pub/enterprise_message_service/6.0.1_january_2011/html/tib_ems_integration_guide/wwhelp/wwhimpl/common/html/wwhelp.htm#href=appint.5.17.htm&single=true
Please see steps:
Add TIBCO Enterprise Message Service as a JMS Provider This section
configures WebSphere to uses TIBCO Enterprise Message Service as a JMS
provider.
Start the WebSphere application server.
Start the WebSphere Administrative Console.
In the WebSphere navigation pane, choose Resources > JMS > JMS providers.
In the content pane, click the New button.
Enter the following values for the required properties: Name TIBCO Description TIBCO Enterprise Message Service Classpath
EMS_HOME\lib\tibjms.jar External Initial Context Factory
com.tibco.tibjms.naming.TibjmsInitialContextFactory External Provider
URL tibjmsnaming://localhost:7222
Click the OK button.
Click the Apply button.

how to get the server display name and process name in Websphere Liberty Profile

In the WebSphere (node) application server, there are the following classes that provide the display name and the process name,
what is the equivalent in WebSphere Liberty Profile
Classes from the WebSphere (traditional) are
com.ibm.websphere.management.AdminServiceFactory
com.ibm.websphere.runtime.ServerName
I am using Liberty Profile v 8.5.5.8
You can retrieve server info from the ServerInfoMBean in Liberty as described in this IBM KnowledgeCenter topic. For more info on how to use management mbeans on Liberty, see this topic.

JSTL SQL setDataSource not working with Webshpere 8.5

<sql:setDataSource var="TCIT" scope="application"
driver="${driver}"
url="${url}"
user="${username}"
password="${password}" />
The above code is used in a legacy application deployed in OC4J that is being migrated to WebSphere 8.5. The properties in {} above are fetched from a property file. Ensured the values are coming correctly form there. However, when the database connection is created the application is encountering the following exception: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver" . I have the ojdbc14.jar in the WEB-INF/lib folder, still facing the issue.
Finally the issue got resolved creating a JDBC connection pool at Application server level. Turns out Websphere does not allow the connection to be created using the above method. Below is the modified tag that is using JNDI lookup for accessing the JDBC connection pool at application level.
<sql:setDataSource var="connPool" scope="application" dataSource="${jndi.devPool}"/>

How to migrate WAS 7.5 to Liberty Profile 8.5?

I am looking to migrate my application to run on Liberty profile 8.5 instead of Websphere Application server 7.5. In this process, I need to do server configuration by setting up LDAP, Database source and JMS. As I am new to Liberty profile, I am looking for help in setting up these. May I get some suggestions from you to complete these settings?
This is a bit broad question, so I'll give you some pointers to documentation to get you started (There is no WAS 7.5, so you probably mean 7.0).
WebSphere Application Server Liberty Profile Guide for Developers - this will give you some basic general information to get you started with Liberty
Data source configuration - basic configuration is quite simple, you define it in server.xml file (you didn't mention which DB you are using, so here is sample with Derby)
<library id="derby">
<fileset dir="${shared.resource.dir}/derby"/>
</library>
<jdbcDriver id="derbyDriver" libraryRef="derby"/>
<dataSource jdbcDriverRef="derbyDriver" jndiName="jdbc/DataSourceJNDI" type="javax.sql.ConnectionPoolDataSource">
<properties.derby.embedded createDatabase="false" databaseName="D:\path\DB"/>
</dataSource>
For more specific information regarding migrating DB2 data sources see
Migrating a DB2 data source to the Liberty profile
LDAP configuration - basic configuration for MS Active Directory
<ldapRegistry id="ldap" realm="SampleLdapADRealm"
host="ldapserver.mycity.mycompany.com" port="389" ignoreCase="true"
baseDN="cn=users,dc=adtest,dc=mycity,dc=mycompany,dc=com"
bindDN="cn=testuser,cn=users,dc=adtest,dc=mycity,dc=mycompany,dc=com"
bindPassword="testuserpwd"
ldapType="Microsoft Active Directory">
<activedFilters
userFilter="(&(sAMAccountName=%v)(objectcategory=user))"&(sAMAccountName=%v)(objectcategory=user))"
groupFilter="(&(cn=%v)(objectcategory=group))"
userIdMap="user:sAMAccountName"
groupIdMap="*:cn"
groupMemberIdMap="memberOf:member">
</activedFilters>
</ldapRegistry>
For more details and other LDAP see Configuring LDAP user registries with the Liberty profile
JMS - as you didn't provide details, if you are acting as JMS server or client and which JMS provider are you using (default or MQ), check this page as starting point for JMS related configuration - Liberty profile: JMS messaging
Application migration - if you want to check, if there are any issues with your application code regarding migration, you can install plugin for Eclipse/RAD -
WebSphere Application Server Migration Toolkit – Liberty Tech Preview which will scan your code for incompatibilities.

Resources