I want to use jdbc directly in a project for service mix.
I have tried to install ojdbc7.jar with
bundle:install wrap:file:F:/tmp/ojdbc7.jar
after starting I get
264 | Active | 80 | 0 | wrap_file_F__tmp_ojd
bc7.jar
My code is:
try (final Connection con = DriverManager.getConnection("jdbc:oracle:thin:#localhost:1521/orcl2", "bla", "bla")) {
String sql = "Insert INTO message values('" + fall.getMessageid() + "','" + fall.getXml() + "')";
final Statement statement = con.createStatement();
statement.executeUpdate(sql);
} catch (Exception e) {
String msg = "Error while trying to persist Fall with msgid " + fall.getMessageid();
log.error(msg, e);
throw new AdvisException(msg, e);
}
I get
java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:#localhost:1521/orcl2
Do I have to add some extra configuration or something?
edit:
I think I must import the installed bundle somehow in the MANIFEST.MF
Problem 1:
I have declared the dependency
<dependency>
<groupId>com.oracle</groupId>
<artifactId>oracle-jdbc</artifactId>
<version>6.0.0</version>
</dependency>
and use
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.3</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Import-Package>*</Import-Package>
<Private-Package>de.iteos</Private-Package>
</instructions>
</configuration>
but the ojdbc6 does not show up the imports:
Import-Package: javax.jws,javax.xml.bind,javax.xml.bind.annotation,javax
.xml.bind.annotation.adapters,javax.xml.datatype,javax.xml.namespace,ja
vax.xml.parsers,javax.xml.transform,javax.xml.transform.stream,javax.xm
l.ws,javax.xml.xpath,org.apache.activemq,org.apache.activemq.camel.comp
onent,org.apache.camel;version="[2.16,3)",org.slf4j;version="[1.7,2)",o
rg.w3c.dom,org.xml.sax
Why?
Problem 2:
the name of the bundle after the install is probably not compatible
How can I change this?
I have solved the problem by copying the ojdbc driver to
apache-servicemix-7.0.1\lib\ext
Related
I want to use Maven Exec Plugin in order to write a command output to a file,
I was only able to do it by running a shell command that the plugin is invoking.
This is the shell script:
git rev-parse --abbrev-ref HEAD > branch.txt
This is my pom.xml:
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<inherited>false</inherited>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-instrument</artifactId>
<version>5.3.21</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>gitbranch.sh</executable>
<workingDirectory>${basedir}</workingDirectory>
</configuration>
</plugin>
When trying to run it as a command and not using a script , I can't get to be written into a file:
<configuration>
<executable>git</executable>
<outputFile>branching.txt</outputFile>
<arguments>
<argument>rev-parse</argument>
<argument>--abbrev-ref</argument>
<argument>HEAD</argument>
</arguments>
<workingDirectory>${basedir}</workingDirectory>
</configuration>
I also tried to run echo "something" > file.txt using this plugin, but nothing is writing anything in to a file.
This may not directly answer your question but I use maven git commit id plugin to do the same thing you want to do. I have:
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<useNativeGit>true</useNativeGit>
<dateFormat>yyyy-MM-dd'T'HH:mm:ssXXX</dateFormat>
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
</configuration>
</plugin>
in my build/plugins section of my pom.xml. When I run this I get the file named git.properties generated in my target/classes directory that contains:
#Generated by Git-Commit-Id-Plugin
#Wed Jul 06 11:51:45 MDT 2022
git.branch=feature/test-branch
git.build.host=bluerock
git.build.time=2022-07-06T11\:51\:45-06\:00
git.build.user.email=
git.build.user.name=
git.build.version=1.0
git.closest.tag.commit.count=
git.closest.tag.name=
git.commit.id=c991301b1a88e6cd138d347c46e3479d34b6f24d
git.commit.id.abbrev=c991301
git.commit.id.describe=c991301
git.commit.id.describe-short=c991301
git.commit.message.full=cleaned up a bit
git.commit.message.short=cleaned up a bit
git.commit.time=2020-09-29T11\:48\:58-06\:00
git.commit.user.email=myemail#example.tld
git.commit.user.name=First Last
git.dirty=false
git.remote.origin.url=<the git url>
git.tags=
git.total.commit.count=4
Then, in my code base I have:
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class VersionInfo {
public String getVersionString() {
try {
Properties properties = getGitProperties();
boolean isDirty = false;
String gitDirty = properties.getProperty( "git.dirty" );
if( gitDirty != null )
isDirty = Boolean.parseBoolean(gitDirty);
return "built \"" + properties.getProperty("git.build.time") +
"\" in branch \"" + properties.getProperty("git.branch") +
"\" with short commit id \"" + properties.getProperty("git.commit.id.describe-short") + "\"" +
", isDirty is " + isDirty +
" remote url is \"" + properties.getProperty("git.remote.origin.url") + "\"";
}
catch( IOException ioe ) {
return( "can't locate git.properties on the class path");
}
}
private Properties getGitProperties() throws IOException {
Properties properties = new Properties();
try (InputStream inputStream = this.getClass().getResourceAsStream("/git.properties")) {
if (inputStream == null)
throw new IOException("Can't locate properties file to generate version info");
properties.load(inputStream);
return properties;
}
}
}
This allows me to print out information about the git environment as part of a startup string or do what you want with it. Again
i have a problem with maven in jenkins. When I building application using maven in jenkis, I got error:
[ERROR] Failures:
[ERROR] MessageResourceIT.Should add Message to Room:49 Condition not satisfied:
response.getStatusCode() == HttpStatus.CREATED
| | | |
| 403 FORBIDDEN false 201 CREATED
It looks like a normal failed test, but when I building application in my computer, test is correct.
My test:
def "Should add Message to Room"() {
given:
Room room = roomHelper.room()
participantHelper.participant(room.id, user.id)
AddMessageRequest request = messageHelper.addMessageRequest()
String url = UriComponentsBuilder.fromPath('/room/{roomId}/message')
.buildAndExpand(room.id)
HttpEntity payload = new HttpEntity<>(request, userHeaders)
when:
ResponseEntity<MessageResponse> response = restTemplate.exchange(url, HttpMethod.POST, payload, MessageResponse.class)
then:
response.getStatusCode() == HttpStatus.CREATED
response.body
MessageResponse messageResponse = response.body
messageResponse.content == request.content
}
my setup:
def setup() {
String userLogin = 'test'
String userPassword = 'test'
user = userHelper.user(userPassword, userLogin)
userHeaders = securityHelper.securityHeader(userLogin, userPassword)
}
It's look as jenkins running tests asynchronously and another test removed users when this test is running.
I using maven-failsafe-plugin:
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<skipITs>false</skipITs>
<includes>
<include>%regex[.*IT.*]</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
Anyone have an idea what can happen and how to fix it?
I have maven based interface, I need to connect MSBI database and fetch the data into mule.
I have added the required jar sqljdbc42.jar to build path.
PFB is the MSBI connection configuration:
<poll doc:name="Poll">
<schedulers:cron-scheduler expression="${msbi.poll.schedule.cdo}"/>
<db:select config-ref="MSBI_Database_Configuration" streaming="true" fetchSize="1000" doc:name="MSBI Select Contact CDO data">
<db:parameterized-query><![CDATA[SELECT [Cstmr_Acct_Id] AS SAP_Account_ID1
,[Accnt_Nm] AS CRM_Account_Name1
,[Accnt_Type] AS APL_Account_Attributes___Account_Type1
,[Cstmr_Sgmnt] AS CRM_Customer_Segment1
,[Trnprttn_role] AS CRM_Transportation_Role1
,CASE WHEN [Accnt_Stts]='A' THEN 'Active' WHEN [Accnt_Stts]='I' THEN 'Inactive' ELSE NULL END AS CRM_Account_Status1
,[Rgn] AS Region1
,[Rgn_desc] AS Region_Text1
,[Clster] AS Cluster1
,[Clster_desc] AS Cluster_Text1
,[Dstrct] AS District1
,[Dstrct_desc] AS District_Text1
,[Cntry] AS Country1
,[Cntry_desc] AS Country_Text1
,[Brnch] AS Branch1
,[Brnch_desc] AS Branch_Text1
,[Trrtry] AS Territory1
,[Trrtry_desc] AS Territory_Desc1
,[New_BT_Cd] AS BT_Code1
,[Lgcy_BT_Cd] AS Legacy_BTCode1
,[Last_Update_Dt] AS LAST_UPDATE_Date1
FROM [dbo].[vw_elqa_CRM_Accnt_Sales_Hierarchy]
WHERE
(
CAST(Last_Update_Dt AS date) >= CAST(GETDATE() AS date) OR
CAST(Last_Update_Dt AS date) >= CAST(#[server.systemProperties['mule.env']=='dev'?server.systemProperties['msbi.debug.csr.query.filterDate']:'2100-01-01'] AS date)
) AND Cstmr_Acct_Id IS NOT NULL]]></db:parameterized-query>
</db:select>
</poll>
When i run the interface it is deployed successfully but while triggering the MSBI throwing below error
ERROR 2017-10-30 20:58:26,792 [nol-integration-v1.3-polling://MSBItoEloquaContactCDODataUpdate/541182371_Worker-1] org.mule.exception.DefaultSystemExceptionStrategy:
********************************************************************************
Message : org.mule.module.db.internal.domain.connection.ConnectionCreationException: Error trying to load driver: com.microsoft.sqlserver.jdbc.SQLServerDriver : Cannot load class 'com.microsoft.sqlserver.jdbc.SQLServerDriver' (java.sql.SQLException)
Element : /MSBI_Database_Configuration # app:bulk-integration.xml:26 (Generic Database Configuration)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.sql.SQLException: Error trying to load driver: com.microsoft.sqlserver.jdbc.SQLServerDriver : Cannot load class 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
at org.enhydra.jdbc.standard.StandardDataSource.getConnection(StandardDataSource.java:184)
at org.enhydra.jdbc.standard.StandardDataSource.getConnection(StandardDataSource.java:144)
at org.mule.module.db.internal.domain.connection.SimpleConnectionFactory.doCreateConnection(SimpleConnectionFactory.java:30)
at org.mule.module.db.internal.domain.connection.AbstractConnectionFactory.create(AbstractConnectionFactory.java:23)
at org.mule.module.db.internal.domain.connection.TransactionalDbConnectionFactory.createDataSourceConnection(TransactionalDbConnectionFactory.java:84)
at org.mule.module.db.internal.domain.connection.TransactionalDbConnectionFactory.createConnection(TransactionalDbConnectionFactory.java:53)
at org.mule.module.db.internal.processor.AbstractDbMessageProcessor.process(AbstractDbMessageProcessor.java:72)
at org.mule.transport.polling.MessageProcessorPollingMessageReceiver$1.process(MessageProcessorPollingMessageReceiver.java:165)
at org.mule.transport.polling.MessageProcessorPollingMessageReceiver$1.process(MessageProcessorPollingMessageReceiver.java:149)
at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:16)
at org.mule.execution.CommitTransactionInterceptor.execute(CommitTransactionInterceptor.java:35)
at org.mule.execution.CommitTransactionInterceptor.execute(CommitTransactionInterceptor.java:22)
at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:30)
at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:14)
at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:67)
at org.mule.execution.ResolvePreviousTransactionInterceptor.execute(ResolvePreviousTransactionInterceptor.java:44)
at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:50)
at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:40)
at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:41)
at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:48)
at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:28)
at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:13)
at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:110)
at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:30)
at org.mule.transport.polling.MessageProcessorPollingMessageReceiver.pollWith(MessageProcessorPollingMessageReceiver.java:148)
at org.mule.transport.polling.MessageProcessorPollingMessageReceiver.poll(MessageProcessorPollingMessageReceiver.java:139)
at org.mule.transport.AbstractPollingMessageReceiver.performPoll(AbstractPollingMessageReceiver.java:216)
at org.mule.transport.PollingReceiverWorker.poll(PollingReceiverWorker.java:84)
at org.mule.transport.PollingReceiverWorker.run(PollingReceiverWorker.java:48)
at org.mule.modules.schedulers.cron.CronJob.execute(CronJob.java:33)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Getting the below error after adding dependency
ERROR
********************************************************************************
Message : Response code 500 mapped as failure.
Payload : org.glassfish.grizzly.utils.BufferInputStream#cb5d5af
Payload Type : org.mule.module.db.internal.result.resultset.ResultSetIterator
Element : /MSBItoEloquaContactCDODataUpdate/input/0/0/EloquaLookupContactsCDOBulk/subprocessors/1/EloquaLookupFields/subprocessors/0/0/1/2 # nol-integration-v1:bulk-integration.xml:92 (Eloqua Get CDO fields)
Element XML : <http:request config-ref="Eloqua_Bulk_API" path="/customObjects/{customObjectId}/fields" method="GET" doc:name="Eloqua Get CDO fields">
<http:request-builder>
<http:uri-param paramName="customObjectId" value="#[flowVars.cdo.id]"></http:uri-param>
</http:request-builder>
</http:request>
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.module.http.internal.request.ResponseValidatorException: Response code 500 mapped as failure.
at org.mule.module.http.internal.request.SuccessStatusCodeValidator.validate(SuccessStatusCodeValidator.java:37)
at org.mule.module.http.internal.request.DefaultHttpRequester.validateResponse(DefaultHttpRequester.java:413)
at org.mule.module.http.internal.request.DefaultHttpRequester.innerProcess(DefaultHttpRequester.java:401)
at org.mule.module.http.internal.request.DefaultHttpRequester.processBlocking(DefaultHttpRequester.java:221)
at org.mule.processor.AbstractNonBlockingMessageProcessor.process(AbstractNonBlockingMessageProcessor.java:43)
It seems sqljdbc4.jar is not found at runtime.
If you are using Maven build(pom.xml)
Add the dependency to the pom.xml
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
Note :Just for information-
If any jar is not in Maven repo you are referring in your pom.xml , you need to add it yourself to your local repository/company repository.
To add to your local repository,
1.Please check if you are having correct version of driver jar.
2.Execute below to add it to local Maven repository
mvn install:install-file -Dfile=<jar_name>.jar -DgroupId=<group_id_of_jar> -DartifactId=<artifact_id_of_jar> -Dversion=<version_of_jar> -Dpackaging=jar
I'm using Mulesoft, and using the answer above and #Mahesh_Loya's comment, I was able to get this working.
Add dependency to pom.xml, just before closing </dependencies> tag:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
Add the Clojars repo to pom.xml, just before closing </repositories> tag
<repository>
<id>Clojars</id>
<name>Clojars</name>
<url>http://clojars.org/repo/</url>
<layout>default</layout>
</repository>
Save pom.xml and rerun Maven, and all should be working. Happy times.
I downloaded gatling as a maven dependency and now I'm looking for how to override the gatling.conf file to configure the connection between gatling and graphite.
So I created a gatling.conf file like that :
data {
writers = [console, file, graphite] # The list of DataWriters to which Gatling write simulation data (currently supported : console, file, graphite, jdbc)
reader = file # The DataReader used by the charting engine for reading simulation results
console {
light = false # When set to true, displays a light version without detailed request stats
}
file {
bufferSize = 8192 # FileDataWriter's internal data buffer size, in bytes
}
leak {
noActivityTimeout = 30 # Period, in seconds, for which Gatling may have no activity before considering a leak may be happening
}
graphite {
light = false # only send the all* stats
host = "mygraphite.host.com" # The host where the Carbon server is located
port = 1010 # The port to which the Carbon server listens to (2003 is default for plaintext, 2004 is default for pickle)
protocol = "tcp" # The protocol used to send data to Carbon (currently supported : "tcp", "udp")
rootPathPrefix = "gatling" # The common prefix of all metrics sent to Graphite
bufferSize = 8192 # GraphiteDataWriter's internal data buffer size, in bytes
writeInterval = 1 # GraphiteDataWriter's write interval, in seconds
}
}
Inside my src/main/resources/conf/gatling.conf
Here's my pom.xml :
<build>
<plugins>
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>${gatling-plugin.version}</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<configFolder>src/main/resources/conf/</configFolder>
<!-- Default values -->
<!--<configFolder>src/test/resources</configFolder-->
<dataFolder>src/main/resources/data</dataFolder>
<resultsFolder>target/gatling/results</resultsFolder>
<!--<!–<requestBodiesFolder>src/test/resources/request-bodies</requestBodiesFolder>-->
<simulationsFolder>src/main/scala</simulationsFolder>
<simulationClass>my.awesomeCompany.scenarios.Scenarios</simulationClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
What I'm doing wrong, there's an other way to do that with a config file ? Or I'll have to override all the options with jvm args ?
Cheers.
You're missing the configuration root, gatling. Therefore, your values overrides nothing. Wrap your data { … } block in a gatling { … } block and it'll work.
I want to run a simple example of word count with map reduce. but I have this problem and have no idea how to solve it.
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
org/apache/hadoop/mapred/JobTrackerInstrumentation.create(Lorg/apache/hadoop/mapred/JobTracker;Lorg/apache/hadoop/mapred/JobConf;)Lorg/apache/hadoop/mapred/JobTrackerInstrumentation; #5: invokestatic
Reason:
Type 'org/apache/hadoop/metrics2/lib/DefaultMetricsSystem' (current frame, stack[2]) is not assignable to 'org/apache/hadoop/metrics2/MetricsSystem'
Current Frame:
bci: #5
flags: { }
locals: { 'org/apache/hadoop/mapred/JobTracker', 'org/apache/hadoop/mapred/JobConf' }
stack: { 'org/apache/hadoop/mapred/JobTracker', 'org/apache/hadoop/mapred/JobConf', 'org/apache/hadoop/metrics2/lib/DefaultMetricsSystem' }
Bytecode:
0000000: 2a2b b200 03b8 0004 b0
I had the same problem and it got solved by removing some unneeded references in Maven (hadoop-common and hadoop-hdfs).
I'm using hadoop 2.2.0 from Windows, connecting to Linux hadoop single-node cluster.
the below order for dependencies solved the problem for me.
hadoop-core 1.2.1
hadoop-common 2.6.0
The below dependencies worked for me
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>2.6.0</version>
</dependency>
</dependencies>