PROBLEM: using Jackson's "ObjectMapper()" within the "process()" method causes an exception...
public void process(org.apache.camel.Exchange exchange) throws IOException {
//...this statement causes the exception...
com.fasterxml.jackson.databind.ObjectMapper om = new com.fasterxml.jackson.databind.ObjectMapper();
...
}
The exception is shown in the Jboss Fuse console...looks like this...
...
2017-09-12 16:45:56,262 | INFO | edhat-187/deploy | fileinstall | 9 - org.apache.felix.fileinstall - 3.5.0 | Installing bundle aaa.bbb.ccc.camelRest / 1.0.0
2017-09-12 16:45:56,323 | WARN | edhat-187/deploy | fileinstall | 9 - org.apache.felix.fileinstall - 3.5.0 | Error while starting bundle: file:/C:/tools/jboss-fuse-6.3.0.redhat-187/deploy/camelRest-1.jar
org.osgi.framework.BundleException: Unresolved constraint in bundle aaa.bbb.ccc.camelRest [759]: Unable to resolve 759.0: missing requirement [759.0] osgi.wiring.package; (&(osgi.wiring.package=com.fasterxml.jackson.databind)(version>=2.7.0)(!(version>=3.0.0)))
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4002)[org.apache.felix.framework-4.4.1.jar:]
at org.apache.felix.framework.Felix.startBundle(Felix.java:2045)[org.apache.felix.framework-4.4.1.jar:]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:976)[org.apache.felix.framework-4.4.1.jar:]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1245)[9:org.apache.felix.fileinstall:3.5.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1217)[9:org.apache.felix.fileinstall:3.5.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:509)[9:org.apache.felix.fileinstall:3.5.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:358)[9:org.apache.felix.fileinstall:3.5.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:310)[9:org.apache.felix.fileinstall:3.5.0]
...
QUESTION:
How can I successfully use the Jackson "ObjectMapper()" inside a "process()" method, i.e., to convert a map into json?
To provide context, below is the info on this simple application/bundle
aaa.bbb.ccc.CamelRestRoutes.java
package aaa.bbb.ccc;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.cdi.ContextName;
#ContextName("rest-dsl")
public class CamelRestRoutes extends RouteBuilder {
public CamelRestRoutes() {
}
private final org.apache.camel.Processor proc1 = new Processor1();
int notificationTime = 60;
int overlapTime = 5;
String codeListString = "AA,BB";
#Override
public void configure() throws Exception {
String fromURL = "http://localhost:7001/jaxrsRestService/service/getAll";
from("timer://foo?fixedRate=true&period=" + 5000) //5 seconds... do we need to make this a system property (like notification service)???....
.setBody(constant(codeListString))
.to("direct:thingB");
from("direct:thingB")
.split().tokenize(",")
.to("direct:thingC");
from("direct:thingC")
.setHeader(Exchange.HTTP_METHOD, constant(org.apache.camel.component.http4.HttpMethods.GET))
.to("netty4-http:http://localhost:7001/jaxrsRestService/service/getAll/")
.to("direct:thingD");
from("direct:thingD")
.split()
.jsonpath("$.container[*]")
.streaming()
.parallelProcessing()
.process(proc1)
.to("wmq:queue:mylocalqueue?jmsMessageType=Text&exchangePattern=InOnly");
}
}
aaa.bbb.ccc.Processor1.java
package aaa.bbb.ccc;
import java.io.IOException;
import java.util.Map;
public class Processor1 implements org.apache.camel.Processor {
#Override
public void process(org.apache.camel.Exchange exchange) throws IOException {
//***this causes the exception***
com.fasterxml.jackson.databind.ObjectMapper.ObjectMapper om = new com.fasterxml.jackson.databind.ObjectMapper.ObjectMapper(); <== causes
Map<String, String> map = (Map<String, String>) exchange.getIn().getBody();
exchange.getIn().setBody(map.toString());
}
};
camel-route.xml
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs"
xmlns:camel="http://camel.apache.org/schema/blueprint"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://cxf.apache.org/blueprint/jaxrs http://cxf.apache.org/schemas/blueprint/jaxrs.xsd
http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd
">
<camel:camelContext id="aaa.bbb.ccc.routing.poc" xmlns="http://camel.apache.org/schema/blueprint">
<packageScan>
<package>aaa.bbb.ccc</package>
</packageScan>
</camel:camelContext>
<bean id="wmqcf" class="com.ibm.mq.jms.MQConnectionFactory">
<property name="hostName" value="localhost"/>
<property name="port" value="1414"/>
<property name="queueManager" value="QM1"/>
<property name="channel" value="DEV.ADMIN.SVRCONN"/>
<property name="transportType" value="1"/>
</bean>
<bean id="wmqcfw" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
<property name="targetConnectionFactory" ref="wmqcf" />
<property name="username" value="admin" />
<property name="password" value="passw0rd" />
</bean>
<bean id="wmqcfg" class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="wmqcfw"/>
<property name="concurrentConsumers" value="10"/>
</bean>
<bean id="wmq" class="org.apache.camel.component.jms.JmsComponent">
<property name="configuration" ref="wmqcfg"/>
</bean>
</blueprint>
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>aaa.bbb.ccc</groupId>
<artifactId>camelRest</artifactId>
<version>1</version>
<packaging>bundle</packaging>
<name>camelRest</name>
<description>camelRest</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<skipTests>true</skipTests>
<mq.version>8.0.0.7</mq.version>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.17.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cdi</artifactId>
<version>2.17.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-netty4-http</artifactId>
<version>2.17.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jackson</artifactId>
<version>2.17.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http4</artifactId>
<version>2.17.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf</artifactId>
<version>2.17.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>allclient</artifactId>
<version>${mq.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>jms</artifactId>
<version>${mq.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jsonpath</artifactId>
<version>2.17.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<source>src/main/resources/xsd/jaxrsRestService.xsd</source>
</sources>
<packageName>aaa.bbb.ccc.generated</packageName>
<verbose default-value="false">${xjc.verbose}</verbose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.3.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Export-Package>aaa.bbb.ccc*</Export-Package>
<Export-Package>aaa.bbb.ccc.generated*</Export-Package>
<Import-Package>*</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
camel features installed
JBossFuse:karaf#root> features:list | grep "camel-" | grep "\[installed"
[installed ] [2.7.0 ] xml-specs-api camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-core camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-blueprint camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-spring camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-bindy camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-cdi camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-csv camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-cxf camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-exec camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-ftp camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-http4 camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-jackson camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-jacksonxml camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-jasypt camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-jaxb camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-jdbc camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-jms camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-jmx camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-jsonpath camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-mail camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-netty4 camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-netty4-http camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-ognl camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-paxlogging camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-restlet camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-rmi camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-routebox camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-saxon camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-script camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-snmp camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-spring-javaconfig camel-2.17.0.redhat-630187
[installed ] [2.17.0.redhat-630187 ] camel-xstream camel-2.17.0.redhat-630187
[installed ] [1.2.0.redhat-630187 ] camel-amq fabric-1.2.0.redhat-630187
JBossFuse:karaf#root>
deploy directory containing IBM MQ osgi jars
Directory of C:\tools\jboss-fuse-6.3.0.redhat-187\deploy
09/13/2017 10:19 AM <DIR> .
09/13/2017 10:19 AM <DIR> ..
09/12/2017 05:10 PM 14,495 camelRest-1.jar
06/29/2017 01:00 AM 159,649 com.ibm.mq.osgi.allclientprereqs_8.0.0.7.jar
06/29/2017 01:00 AM 8,011,749 com.ibm.mq.osgi.allclient_8.0.0.7.jar
06/29/2017 01:00 AM 4,088,715 com.ibm.mq.osgi.java_8.0.0.7.jar
06/29/2017 01:00 AM 171,064 com.ibm.msg.client.osgi.commonservices.j2se_8.0.0.7.jar
06/29/2017 01:00 AM 48,715 com.ibm.msg.client.osgi.jms.prereq_8.0.0.7.jar.DISABLE
06/29/2017 01:00 AM 639,807 com.ibm.msg.client.osgi.jms_8.0.0.7.jar
06/29/2017 01:00 AM 216,218 com.ibm.msg.client.osgi.nls_8.0.0.7.jar
06/29/2017 01:00 AM 279,861 com.ibm.msg.client.osgi.wmq.nls_8.0.0.7.jar
06/29/2017 01:00 AM 92,406 com.ibm.msg.client.osgi.wmq.prereq_8.0.0.7.jar
06/29/2017 01:00 AM 7,963,226 com.ibm.msg.client.osgi.wmq_8.0.0.7.jar
09/15/2016 04:19 AM 873 README
12 File(s) 21,686,778 bytes
2 Dir(s) 142,681,493,504 bytes free
other environment info
jdk1.8.0_131
jboss-fuse-6.3.0.redhat-187
WebLogic 12.2.1 (running the rest service)
Thank you for your help!
The deploy error you are encountering is because you don't have the correct version of the com.fasterxml.jackson.databind jar on the classpath (as defined below). Are you using a features file for deployment? If so, please include it in your question.
org.osgi.framework.BundleException: Unresolved constraint in bundle
aaa.bbb.ccc.camelRest [585]: Unable to resolve 585.0: missing
requirement [585.0] osgi.wiring.package;
(&(osgi.wiring.package=com.fasterxml.jackson.databind)(version>=2.7.0)(!(version>=3.0.0)))
The way you are using Processor to deserialize to JSON is correct, however I would suggest creating the ObjectMapper() outside of the Process() method since you don't need a new one each time and creating one is expensive.
Related
I am trying to automate an application on Windows11. We have .exe to run and need to create shortcut file on desktop to run. I have to click on that .lnk file to process further execution. So I am using winium driver to start .lnk application on port 9999. Now I have to
continue automation on open application edge browser. i.e. When I click on .lnk file present on desktop, will open in Edge browser (IE Mode On). Then I will have to same session to login application.
Application is opening through winium driver but not able to login to application since driver session not working
ChromeTest.Java
import java.io.File;
import java.io.IOException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriverService;
import org.openqa.selenium.edge.EdgeOptions;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.winium.DesktopOptions;
import org.openqa.selenium.winium.WiniumDriver;
import org.openqa.selenium.winium.WiniumDriverService;
public class ChromeTest {
public static void main(String[] args) throws IOException, InterruptedException {
// TODO Auto-generated method stub
WebDriver browser = null;
DesktopOptions option;
WiniumDriver windriver = null;
WiniumDriverService service = null;
String applicationPath = "C:\\Users\\My\\Desktop\\172.20.1.4.lnk";
// user profile path = C:\Users\My\AppData\Local\Microsoft\Edge\User Data\Default
try {
option = new DesktopOptions();
option.setApplicationPath(applicationPath);
option.setDebugConnectToRunningApp(false);
File driverPath = new File(System.getProperty("user.dir") + File.separator + "drivers" + File.separator
+ "Winium.Desktop.Driver.exe");
service = new WiniumDriverService.Builder().usingDriverExecutable(driverPath).usingPort(9999)
.withVerbose(true).withSilent(false).buildDesktopService();
try {
service.start();
} catch (IOException e) {
System.out.println("Exception while starting WINIUM service");
e.printStackTrace();
}
windriver = new WiniumDriver(service, option);
Thread.sleep(10000);
// creating instance of edge using port
System.out.println("1");
EdgeDriverService edgeservice = new EdgeDriverService.Builder()
.usingDriverExecutable(new File("D:\\My_Workspace\\ChromeTest\\drivers\\msedgedriver.exe")).usingPort(9999).build();
System.out.println("2");
edgeservice.start();
System.out.println("3");
System.out.println("URL :: "+edgeservice.getUrl());
browser = new RemoteWebDriver(edgeservice.getUrl(), new EdgeOptions());
System.out.println("4");
System.out.println("TITLE :: "+browser.getTitle());
Thread.sleep(20000);
} catch (Exception e) {
System.out.println(e);
}
Thread.sleep(20000);
Thread.sleep(20000);
// browser.quit();
// edgeDriverservice.stop();
service.stop();
// windriver.quit();
}
}
POM.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ChromeTest.com</groupId>
<artifactId>ChromeTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.github.2gis.winium</groupId>
<artifactId>winium-webdriver</artifactId>
<version>0.1.0-1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
<scope>test</scope>
</dependency>
<!-- <dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>7.3.0</version>
</dependency> -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<!-- <dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0</version>
</dependency> -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>23.0</version>
</dependency>
<!-- <dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.9.1</version>
</dependency> -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>5.0.8</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.5</version>
</dependency>
<dependency>
<groupId>tech.grasshopper</groupId>
<artifactId>extentreports-cucumber6-adapter</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.14.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.14.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-examples -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-examples</artifactId>
<version>4.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-excelant -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-excelant</artifactId>
<version>4.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>9.4.1.jre8</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.2</version>
</dependency>
<dependency>
<groupId>com.sikulix</groupId>
<artifactId>sikulixapi</artifactId>
<version>2.0.4</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>if-suite-exists</id>
<activation>
<property>
<name>!env.SUITES</name>
</property>
</activation>
<properties>
<suites>GlobalSuite</suites>
</properties>
</profile>
<!-- browsers -->
<profile>
<id>firefox</id>
<properties>
<capabilities>/firefox.capabilities</capabilities>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>chrome</id>
<properties>
<capabilities>/chrome.capabilities</capabilities>
</properties>
</profile>
<profile>
<id>ie</id>
<properties>
<capabilities>/ie.capabilities</capabilities>
</properties>
</profile>
</profiles>
<properties>
<suites>${env.SUITES}</suites>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<resources>
<resource>
<directory>src/main/java/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/java/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<!--<inherited>true</inherited> -->
<configuration>
<!--<testFailureIgnore>false</testFailureIgnore> -->
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/suites/${suites}.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
Exception Log :
Starting Windows Desktop Driver on port 9999
15:44:32 [DEBUG] Waiting for a connection...
15:44:32 [WARN] ACCEPTED EMPTY REQUEST
15:44:32 [DEBUG] Client closed
15:44:32 [DEBUG] Waiting for a connection...
15:44:32 [DEBUG] ACCEPTED REQUEST GET /status HTTP/1.1
15:44:32 [INFO] COMMAND status
{}
15:44:32 [DEBUG] RESPONSE:
OK: {
"sessionId": "AwesomeSession",
"status": 0,
"value": {
"build": {
"version": "1.2.0.0"
},
"os": {
"arch": "x64",
"name": "windows",
"version": "Microsoft Windows NT 6.2.9200.0"
}
}
}
15:44:32 [DEBUG] Client closed
15:44:32 [DEBUG] Waiting for a connection...
15:44:32 [DEBUG] ACCEPTED REQUEST POST /session HTTP/1.1
15:44:32 [INFO] COMMAND newSession
{
"desiredCapabilities": {
"app": "C:\\Users\\My\\Desktop\\172.20.1.4.lnk",
"debugConnectToRunningApp": false
},
"capabilities": {
"firstMatch": [
{}
]
}
}
15:44:32 [DEBUG] Current keyboard simulator: BasedOnInputSimulatorLib
15:44:32 [DEBUG] RESPONSE:
OK: {
"sessionId": "AwesomeSession",
"status": 0,
"value": {
"app": "C:\\Users\\My\\Desktop\\172.20.1.4.lnk",
"args": "",
"debugConnectToRunningApp": false,
"innerPort": 9998,
"keyboardSimulator": 1,
"launchDelay": 0
}
}
15:44:32 [DEBUG] Client closed
15:44:32 [DEBUG] Waiting for a connection...
Sep 28, 2022 3:44:32 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
1
15:44:43 [DEBUG] ACCEPTED REQUEST GET /status HTTP/1.1
15:44:43 [INFO] COMMAND status
{}
2
3
URL :: http://localhost:9999
15:44:43 [DEBUG] RESPONSE:
OK: {
"sessionId": "AwesomeSession",
"status": 0,
"value": {
"build": {
"version": "1.2.0.0"
},
"os": {
"arch": "x64",
"name": "windows",
"version": "Microsoft Windows NT 6.2.9200.0"
}
}
}
15:44:43 [DEBUG] Client closed
15:44:43 [DEBUG] Waiting for a connection...
15:44:43 [DEBUG] ACCEPTED REQUEST POST /session HTTP/1.1
15:44:43 [INFO] COMMAND newSession
{
"desiredCapabilities": {
"browserName": "MicrosoftEdge"
},
"capabilities": {
"firstMatch": [
{
"browserName": "MicrosoftEdge"
}
]
}
}
15:44:43 [DEBUG] RESPONSE:
OK: {
"sessionId": "AwesomeSession",
"status": 13,
"value": {
"error": "unknown error",
"stacktrace": " at Winium.Cruciatus.Application.Start(String arguments)\r\n at Winium.Desktop.Driver.CommandExecutors.NewSessionExecutor.InitializeApplication(Boolean debugDoNotDeploy)\r\n at Winium.Desktop.Driver.CommandExecutors.NewSessionExecutor.DoImpl()\r\n at Winium.Desktop.Driver.CommandExecutors.CommandExecutorBase.Do()",
"message": "Path \"D:\\My_Workspace\\ChromeTest\" doesn't exists"
}
}
15:44:43 [DEBUG] Client closed
15:44:43 [DEBUG] Waiting for a connection...
org.openqa.selenium.WebDriverException: Path "D:\My_Workspace\ChromeTest" doesn't exists (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 6 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'QAMACHINE20', ip: '172.20.1.4', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '15.0.2'
Driver info: driver.version: RemoteWebDriver
Starting Microsoft Edge WebDriver 105.0.1343.25 (d3a25e9da89eba5d55f1ab48fced0ccd321e4ba8) on port 9999
To submit feedback, report a bug, or suggest new features, please visit https://github.com/MicrosoftEdge/EdgeWebDriver
Only local connections are allowed.
Please see https://aka.ms/WebDriverSecurity for suggestions on keeping Microsoft Edge WebDriver safe.
Microsoft Edge WebDriver was started successfully.
15:45:23 [DEBUG] ACCEPTED REQUEST GET /shutdown HTTP/1.1
15:45:23 [WARN] Unknown command recived: http://localhost:9999/shutdown
15:45:23 [DEBUG] Client closed
15:45:23 [DEBUG] Waiting for a connection...
So I have a react js and I am using firebase to host the site. And I have created a project named "parentproject" having multiple sites "site1" "site2".
And I am using GitHub actions to detect push on either of my 2 branches "prod and dev". So, when I push into prod branch I want to deploy on "site1" and when I push to dev branch I want to deply on "site2".
I am also using github workflow. My firebase configs are :
.firebaserc
{
"projects": {
"default": "site1"
},
"targets": {
"parentProject": {
"hosting": {
"prod": ["site1"],
"dev": ["site2"],
}
}
}
}
firebase.json
{
"hosting": {
"target": "prod",
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
My yml file for push branch looks like:
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
name: Deploy to Firebase Hosting on merge
'on':
push:
branches:
- prod
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v1
with:
node-version: '14'
- run: npm ci
- run: CI=false npm run build
- uses: FirebaseExtended/action-hosting-deploy#v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_SECRETKEY }}'
channelId: live
projectId: parentProject
env:
FIREBASE_CLI_PREVIEWS: hostingchannels
Every time I push to prod, my site gets deployed on default firebase hosting page, not "site1". Any suggestion are helpful.
There is a field called "target" where you can setup the specific site to deploy, more about it on the documentation of the firebase github action: https://github.com/FirebaseExtended/action-hosting-deploy#target-string
(...)
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_SECRETKEY }}'
channelId: live
projectId: parentProject
==> target: "<site id here>"
env:
FIREBASE_CLI_PREVIEWS: hostingchannels
You have to add also the field "site" on the firebase.json, like:
{
"hosting": {
"target": "prod",
==> "site": "<id of the site in the firebase projet>",
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
Geeting error: Unexpected token export while running tests in Jest with components having amcharts4
export { System, system } from "./.internal/core/System";
^^^^^^
SyntaxError: Unexpected token export
> 1 | import * as am4core from "#amcharts/amcharts4/core";
| ^
2 | import * as am4charts from "#amcharts/amcharts4/charts";
3 | import * as am4maps from "#amcharts/amcharts4/maps";
4 | import am4geodata_worldLow from "#amcharts/amcharts4-geodata/worldLow";
"jest": "24.9.0"
"#amcharts/amcharts4": "^4.10.19"
"typescript": "^3.9.5"
Following is jest config in the package.json file :(Using create-react-app for the project & ejected it)
"jest": {
"roots": [
"<rootDir>/src"
],
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"setupFiles": [
"react-app-polyfill/jsdom",
"<rootDir>\\src\\__mocks__\\dom.js",
"<rootDir>\\src\\__mocks__\\reactrouter.js"
],
"setupFilesAfterEnv": [
"#testing-library/jest-dom/extend-expect"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
],
"testEnvironment": "jest-environment-jsdom-fourteen",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"node_modules/(?!#amcharts/amcharts4/)",
"^.+\\.module\\.(css|sass|scss)$"
],
"modulePaths": [
"<rootDir>/src/",
"<rootDir>/node_modules/"
],
"moduleNameMapper": {
"\\.(css|scss)$": "<rootDir>/src/__mocks__/styleMock.js"
},
"moduleFileExtensions": [
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
"node"
],
"watchPlugins": [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname"
]
}
Cause: babel-jest uses babel configuration that is loaded based on the location of the file that is going to be transformed. After ejecting create-react-app your package.json probably contains:
"babel": {
"presets": [
"react-app"
]
}
which makes import/export statements work for your files, but #amcharts/amcharts4 does not have that setting in its package.json nor does it have .babelrc and so no import/export transformation takes place.
Solution: You can update your Jest config to transform #amcharts in a more specific way:
Add relevant babel plugin: npm install -D #babel/plugin-transform-modules-commonjs
Update jest config in your package.json - redirect #amcharts transformation to custom transformer. (I also changed transformIgnorePatterns so that they work for Windows.)
"transform": {
"#amcharts[/\\\\].+\\.(js|jsx|ts|tsx)$": "<rootDir>/config/jest/babelTransformImportExport.js",
"^.+\\.(js|jsx|ts|tsx)$": "babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"node_modules[/\\\\](?!#amcharts[/\\\\]amcharts4[/\\\\])",
"^.+\\.module\\.(css|sass|scss)$"
],
Create config/jest/babelTransformImportExport.js:
const babelJest = require("babel-jest");
module.exports = babelJest.createTransformer({
plugins: [require.resolve("#babel/plugin-transform-modules-commonjs")],
babelrc: false,
configFile: false,
});
Tests should be running now.
Edit: As Subrato Patnaik mentioned (using amcharts with jest), amcharts use APIs such as SVGPathElement which aren't yet available in Jest test environment (JSDOM - issue #2128). In other words, your tests won't probably work, if you're using standard mounting. But they might work if you are using e.g. enzyme and its shallow rendering.
If you don't use enzyme or it doesn't work, then as the last resort, you can try to simply define missing APIs in a minimalistic way and see whether it is sufficient:
Change setupFiles in jest config to:
"setupFiles": [
"react-app-polyfill/jsdom",
"<rootDir>/config/jest/setup.js"
],
Create config/jest/setup.js:
class SVGGraphicsElement extends SVGElement {}
class SVGGeometryElement extends SVGGraphicsElement {}
class SVGPathElement extends SVGGeometryElement {}
Object.assign(global, {
SVGGraphicsElement,
SVGGeometryElement,
SVGPathElement,
});
PS: If you are using pnpm instead of npm/yarn, then you will need to update transformIgnorePatterns to:
"node_modules[/\\\\](?!(|\\.pnpm[/\\\\]#amcharts.*node_modules[/\\\\])#amcharts[/\\\\]amcharts4[/\\\\])",
otherwise the old regexp would match (and therefore ignore) paths such as node_modules/.pnpm/#amcharts+amcharts4#4.10.21/node_modules/#amcharts/amcharts4/core.js
I added code below to build.xml(root directory of sencha project), trying to exclude Ext.ux.ajax.* classes when build app.js
<target name="-before-init">
<if>
<equals arg1="${build.environment}" arg2="production"/>
<then>
<property name="build.operations">
exclude
-namespace=Ext.ux.ajax
</property>
</then>
</if>
</target>
But it seems not working, the output app.js still includes all Ext.ux.ajax.* classes.
I also tried -after-init-defaults, exclude -file=xxx, and it didn't make any difference.
What am I doing wrong?
I figured it out
"output": {
// ...
"js": {
"path": "app.js",
"filter": "all" // because of this config
}
},
i trying to build camel sql application, but i've stack.
I found informations about camel-sql in http://camel.apache.org/sql-component.html page.
I've created xml configurations, as shown in example, and in my FUSE ESB i found exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'camel-21': Invocation of init method failed; nested exception is
org.springframework.beans.factory.CannotLoadBeanClassException:
Cannot find class [org.springframework.jdbc.datasource.DriverManagerDataSource]
for bean with name 'esb' defined in URL [bundle://249.2:0/META-INF/spring/camel-context.xml]; nested exception is java.lang.ClassNotFoundException:
org.springframework.jdbc.datasource.DriverManagerDataSource not found from bundle [camel]
but in my fuse console i have spring jdbc:
karaf#root> osgi:list | grep Spring
ID State Blueprint Spring Level Name
[ 73] [Active ] [ ] [ ] [ 60] Spring Beans (3.0.5.RELEASE)
[ 74] [Active ] [ ] [ ] [ 60] Spring Context Support (3.0.5.RELEASE)
[ 75] [Active ] [ ] [ ] [ 60] Spring Context (3.0.5.RELEASE)
[ 76] [Active ] [ ] [ ] [ 60] Spring Expression Language (3.0.5.RELEASE)
[ 77] [Active ] [ ] [ ] [ 60] Spring ASM (3.0.5.RELEASE)
[ 78] [Active ] [ ] [ ] [ 60] Spring Core (3.0.5.RELEASE)
[ 79] [Active ] [ ] [ ] [ 60] Spring AOP (3.0.5.RELEASE)
[ 87] [Active ] [ ] [ ] [ 60] Apache XBean :: Spring (3.8)
[ 92] [Active ] [ ] [ ] [ 50] Spring Transaction (3.0.5.RELEASE)
[ 94] [Active ] [ ] [ ] [ 50] Spring JMS (3.0.5.RELEASE)
[ 169] [Active ] [ ] [ ] [ 50] Apache XBean :: Spring (3.7)
[ 223] [Active ] [ ] [ ] [ 60] Spring Web (3.0.5.RELEASE)
[ 224] [Active ] [ ] [ ] [ 60] Spring Web Servlet (3.0.5.RELEASE)
[ 252] [Active ] [ ] [ ] [ 50] Spring JDBC (3.0.5.RELEASE)
what do i have to do ?
UPDATE:
My POM is :
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>camelWs</groupId>
<artifactId>camel</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>A Camel Route</name>
<url>http://www.myorganization.org</url>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>2.9.0</version>
</dependency>
<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-sql</artifactId>
<version>2.8.0</version>
<!-- use the same version as your Camel core version -->
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.1.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Import-Package>
org.springframework.jdbc.datasource
</Import-Package>
</instructions>
</configuration>
</plugin>
<!-- allows the route to be ran via 'mvn camel:run' -->
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-maven-plugin</artifactId>
<version>2.9.0</version>
<configuration>
<instructions>
<Import-Package>
*,
org.springframework.jdbc,
org.springframework.jdbc.datasource
</Import-Package>
<DynamicImport-Package>camel.*</DynamicImport-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
but when i'm using osgi:headers i don't see imported classes, what is wrong im my pom.xml ?
osgi:headers:
camel (271)
-----------
Manifest-Version = 1.0
Bnd-LastModified = 1332154265299
Archiver-Version = Plexus Archiver
Tool = Bnd-0.0.357
Originally-Created-By = Apache Maven
Generated-By-Ops4j-Pax-From = wrap:file:/.../$Bundle-SymbolicName=camel&Bundle-Version=1.0.0.SNAPSHOT
Build-Jdk = 1.6.0_29
Created-By = 1.6.0_29 (Apple Inc.)
Bundle-Name = camel
Bundle-SymbolicName = camel
Bundle-Version = 1.0.0.SNAPSHOT
Bundle-ManifestVersion = 2
Private-Package =
.
Import-Package =
camel;resolution:=optional,
org.apache.camel.builder;resolution:=optional,
org.apache.camel.model;resolution:=optional,
org.apache.camel.spring;resolution:=optional
Export-Package =
camel;uses:="org.apache.camel.builder,org.apache.camel.model,org.apache.camel.spring"
OSGi can be a bit troublesome for installing and using JDBC drivers easily. A proven solution is to install the JDBC driver as a fragment bundle to your bundle.
Its been discussed at the FuseSource forums where there is instructions how to resolve this. A starting point is this link: http://fusesource.com/forums/thread.jspa?messageID=13043㋳, and then follow the references for other discussions for more details and how to resolve it.
You should make sure your route has an import-package on org.springframework.jdbc.datasource. You can verify it using the header command in karaf.
OK, i found solution.
It was quite easy - i just have to install mysql connector.
Thanks all.