I am trying to connect to WebsphereMQ using JMS.
The following configuration is defined:
properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
properties.put(Context.URL_PKG_PREFIXES, "com.ibm.ws.naming");
properties.put(Context.PROVIDER_URL, "iiop://localhost:2809");
properties.put(Context.SECURITY_PRINCIPAL, "user")
properties.put(Context.SECURITY_CREDENTIALS, "password")
The following dependencies are included in the Maven POM file:
<dependency>
<groupId>com.ibm</groupId>
<artifactId>com.ibm.mqjms</artifactId>
<version>7.0.1.4</version>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>com.ibm.mq.jmqi</artifactId>
<version>7.0.1.4</version>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>com.ibm.dhbcore</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq.jar</artifactId>
<version>7.0.1.4</version>
<scope>runtime</scope>
</dependency>
When trying to instantiate the context (new InitialContext(properties)), the following exception is thrown:
javax.naming.NoInitialContextException: Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory [Root exception is java.lang.ClassNotFoundException: com.ibm.websphere.naming.WsnInitialContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.init(InitialContext.java:242)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
Is there a maven dependency missing?
Thanks
Not sure what the maven coordinates are, since I don't think these libraries are in any public repos, so coordinates will be repo specific, but according to this post, the jar files required are:
wssec.jar
naming.jar
namingclient.jar
lmproxy.jar
sas.jar
ecutils.jar
Nicholas' answer is correct. (Moving this from comment to allow for formatting)
IBM does not distribute their jars into Maven repositories. Someone in your organization deployed them manually (which is a common practice).
You either:
Are not pointing your maven settings.xml or project pom.xml to your organization's internal Maven Repository
Need to deploy the MQ jars to the repository manually.
mvn deploy:deploy-file -DgroupId=com.ibm.mq -DartifactId=mqjms -Dversion=7.5.0.2 -Dfile=mqjms.jar
See: https://maven.apache.org/guides/mini/guide-3rd-party-jars-remote.html
Related
I want to get an example of liquibase, Spring and MongoDB all together. In order to do so, I created a Spring project using Spring Initializr with Spring Data MongoDB as dependency. The project already connects to the database and now I would like to use liquibase. I followed the instructions from liquibase using the maven approach but if I run the maven command mvn liquibase:status I will get the following error:
Unexpected error running Liquibase: Cannot find database driver: com.mongodb.client.MongoClients.<init>()
It looks like this problem has been already reported to liquibase but if there is a solution it hasn't been posted in the issue.
I tried as well to use the CLI option by adding the jars to the lib folder of the liquibase installation. I got the same error if I run liquibase status
I have created a repo in GitHub to show the problem. Here there is some relevant configuration of the code:
pom.xml
<project>
...
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.3</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
...
<properties>
<liquibase-mongo-ext.version>4.14.0</liquibase-mongo-ext.version>
<liquibase-maven-plugin.version>4.2.0</liquibase-maven-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-mongodb</artifactId>
<version>${liquibase-mongo-ext.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase-maven-plugin.version}</version>
<configuration>
<propertyFile>liquibase.properties</propertyFile>
</configuration>
<dependencies>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-mongodb</artifactId>
<version>${liquibase-mongo-ext.version}</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.6.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
liquibase.properties
changeLogFile=./mongo/changelog/changelog.sql
url=jdbc:mongodb://127.0.0.1:27017/local
driver=com.mongodb.client.MongoClients
How can I get liquibase running with maven? Any suggestions?
EDIT 1:
As Andrey suggested:
Driver was updated to: driver=liquibase.ext.mongodb.database.MongoClientDriver
Url was updated to:
url=mongodb://127.0.0.1:27017/local
plugin from liquibase was updated with new dependency
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>4.9.1</version>
</dependency>
mvn liquibase:update now trhows the following error. Since the other error seems to be unrelated to this one. I'll solve this answer and create a new thread.
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:4.2.0:update (default-cli) on project mongo: Execution default-cli of goal org.liquibase:liquibase-maven-plugin:4.2.0:update failed: A required class was missing while executing org.liquibase:liquibase-maven-plugin:4.2.0:update: liquibase/configuration/HubConfiguration
EDIT 2:
As mentioned in the answer, there was a mismatch between the version from Spring and the version of the plugin, which failed to find the class because HubConfiguration class is now under liquibase.hub.HubConfiguration This set up could have led to a CastException as well. So I updated the version liquibase-maven-plugin to 4.9.1
Also the use of the local database is not compatible with validators. The URI was updated to url=mongodb://127.0.0.1:27017/test in the liquibase.properties file.
Now it works like a charm! :D
I have found following mistakes in your configuration:
1.
changeLogFile=./mongo/changelog/changelog.sql
url=jdbc:mongodb://127.0.0.1:27017/local
driver=com.mongodb.client.MongoClients
while liquibase-mongodb expects something like (no jdbc prefix, another driver class):
changeLogFile=./mongo/changelog/changelog.sql
url=mongodb://127.0.0.1:27017/local
driver=liquibase.ext.mongodb.database.MongoClientDriver
liquibase version:
<liquibase-maven-plugin.version>4.2.0</liquibase-maven-plugin.version>
4.2.0 liquibase version seems to be incompatible with NoSQL DB extensions
spring boot 2.7.3 uses liquibase 4.9.1 - you need somehow choose the correct liquibase version
Finally I get the following on liquibase:update:
[ERROR] Failed to execute goal
org.liquibase:liquibase-maven-plugin:4.14.0:update (default-cli) on
project mongo: [ERROR] Error setting up or running Liquibase: [ERROR]
liquibase.exception.DatabaseException: Could not execute: Command
failed with error 72 (InvalidOptions): 'Document validators are not
allowed on collection local.DATABASECHANGELOGLOCK with UUID
31bd40b8-3e1c-45c8-9d03-77b91c67a1a9 in the local internal database'
on server 127.0.0.1:27017. The full response is {"ok": 0.0, "errmsg":
"Document validators are not allowed on collection
local.DATABASECHANGELOGLOCK with UUID
31bd40b8-3e1c-45c8-9d03-77b91c67a1a9 in the local internal database",
"code": 72, "codeName": "InvalidOptions"}
no idea what does it mean - something related to mongodb and extension I believe
UPD.
The root cause of last error is described in documentation:
Restrictions
You cannot specify a validator for collections in the admin, local, and config databases.
You cannot specify a validator for system.* collections.
So, url (jdbc:mongodb://127.0.0.1:27017/local) should point to another db.
Compilation of project was successful but in a runtime this error appeared:
java.lang.NoClassDefFoundError: com/microsoft/graph/httpcore/ICoreAuthenticationProvider
Implementation of ClientCredentialProvider
Class ClientCredentialProvider needed ICoreAuthenticationProvider interface which is in artifact microsoft-graph-core.
Just add this dependency to maven:
<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph-core</artifactId>
<version>2.0.0</version>
</dependency>
I'm building a web app using Vaadin and it needs to communicate with several REST APIs. I've set it up in IntelliJ with Maven. I was thinking for the REST client I would use GSON to parse the JSON objects I'd be receiving from the open APIs, however, the application crashes due to a servlet exception error.
Caused by:
java.lang.ClassNotFoundException: com.google.gwt.json.client.JSONObject
I've added the GSON dependency to the pom.xml:
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
And have tried changing the module settings from Provided to Compiled to Runtime but with no change.
I'm just stumped as to why the GSON jar appears in the project dependencies within IntelliJ using Maven but fails on run time. I've seen references to Eclipse and including the jar in the classpath but, again, I'm using IntelliJ/Maven to build my Vaadin project and satisfy dependencies.
Any help is greatly appreciated!
Add below dependency in your classpath:
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.3.0</version>
</dependency>
I have a Java EE project which is meant to run on Glassfish 4.1. I want to use Selenium to collect information from some web pages, i.e. I need to include Selenium in the deployment (not just for tests).
I am using Eclipse IDE and have previously utilized the incremental deployment function in Eclipse to automatically deploy all saved changes to the project. But when I included (with Maven) the dependencies for Selenium incremental deployment stopped working. The project can still be deployed to Glassfish but I have to restart Glassfish between every change. I get the following error in Eclipse:
Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: java.util.concurrent.ExecutionException: com.sun.faces.config.ConfigurationException: Unable to parse document 'bundle://136.0:1/com/sun/faces/jsf-ri-runtime.xml': DTD factory class org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl does not extend from DTDDVFactory.. Please see server.log for more details.
org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl is included with Selenium as a transitive dependency (xerces:xercesImpl:2.11.0).
Here are my Maven dependencies:
<dependency>
<groupId>org.jboss.arquillian.selenium</groupId>
<artifactId>selenium-bom</artifactId>
<version>2.44.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
</dependency>
I hope there is a solution to this but after reading Jens Schauder's response in Dealing with "Xerces hell" in Java/Maven? I'm afraid there might not be. Anyone?
I currently can't reproduce the issue with a simple project, did you make sure that you don't have any other dependencies which are importing another version of xercesImpl?
You can try to place the xercesImpl-2.11.0.jar and the transitive dependency xml-apis-1.4.01.jar in the lib folder of your Glassfish domain and exclude it from your dependencies like this:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.44.0</version>
<exclusions>
<exclusion>
<artifactId>xercesImpl</artifactId>
<groupId>xerces</groupId>
</exclusion>
</exclusions>
</dependency>
See also:
org.apache.xerces.impl.dv.DVFactoryException: DTD factory class org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl does not extend from DTDDVFactory
Xerces error: org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl
I'm trying to run integration tests in an OSGi container, namely the Equinox container embedded in Eclipse, using Arquillian in remote mode.
I followed the instructions given on the JBoss OSGI site. So I began by provisionning my target platform by adding these artefacts (which I found by browsing the jboss repository) :
<dependency>
<groupId>org.jboss.arquillian.osgi</groupId>
<artifactId>arquillian-osgi-bundle</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<!-- required by arquillian-osgi-bundle -->
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.1.0.GA</version>
</dependency>
<dependency>
<groupId>org.jboss.osgi.jmx</groupId>
<artifactId>jboss-osgi-jmx</artifactId>
<version>1.0.10</version>
</dependency>
When I try to validate the bundles, I get unsatisfied imports from jboss-osgi-jmx :
missing package org.jboss.osgi.spi.capability
missing package org.jboss.osgi.testing
Apparently, the missing packages belong to these artifacts (once again, found by browsing):
<!-- osgi.spi : this one ?-->
<dependency>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-spi</artifactId>
<version>1.0.10</version>
</dependency>
<!-- or that one ?-->
<dependency>
<groupId>org.jboss.osgi.spi</groupId>
<artifactId>jbosgi-spi</artifactId>
<version>1.0.26</version>
</dependency>
<!-- osgi.testing -->
<dependency>
<groupId>org.jboss.osgi.testing</groupId>
<artifactId>jbosgi-testing</artifactId>
<version>1.0.4</version>
</dependency>
But neither of these artifacts is an OSGI bundle, so I'm stuck with unresolved constraints.
So, my questions are :
did I screw up my platform configuration ?
does anybody already succeeded at using Arquillian inside a non-JBoss
osgi container in remote mode (plain felix would be OK) ?
Try Pax Exam for OSGi testing. You can choose between embedded and remote usage (Native Test Container vs. Forked Test Container).
Pax Exam supports all OSGI 4.2 compliant frameworks. It it regression tested on Equinox, Felix and Knopflerfish.