I always use data.sql file in my resource folder if I want to initialise my H2 database with spring boot.
Now I need to use a H2 database but also to externalise data.sql in order to update this file when there are any changes.
I don't want to install MySql or other Databases because it's a very small service with a few database items and this service may be restarted sometimes.
So I have my folder in which there are the following two files: the uber jar file of my spring boot application (with Tomcat embedded) and data.sql file.
How can I externalise data.sql like the way I can externalise the configurations for application.properties?
How about putting it in the classpath when you run the jar?
java -jar uber.jar -classpath "PATH_TO_YOUR_SQL_FILE"
Related
For automatic scripts running at the start I use following property:
spring.datasource.data=classpath:base.scripts/*
It runs all the scripts in src/main/resources/base.scripts
But imagine my scripts files are located not in resources. (In another project directory, for example src/test/resources/base/scripts). How can I specify that path?
This is how I fixed it:
spring.datasource.data=file:src/main/resources/base.scripts/*
We are running a Flink(1.9.1) application on AWS-EMR(5.29) using yarn. We are using a common logging adaptor throughout all the components(including the Flink application) in our project and it uses Log4j2.
From the documentation, I see that there are 3 configuration files.
log4j.properties
log4j-yarn-session.properties
log4j-cli.properties
I understand that I will have to modify log4j.properties for the job manager and task manager logs and log4j-cli.properties for the code not included in the cluster code.
Now given this situation,
How do I pass my log4j2.properties?
Do we replace the logging jars in the lib folder with log4j2 jars?
Not a solid solution but this is a workaround. If the log4j.properties file in the /conf folder is deleted, the log4j2 file within the jar that is within the classpath is referred. But be careful when you have multiple jars in the classpath with the log4j2 properties file.
I have a docker image as located here
https://github.com/Landoop/fast-data-dev which has all the good stuff that I am using for development. I've tried to add a JDBC connector to push into a Kafka topic however am getting this error. I've made a consumer in Java which is working fine however I would like to use KafkaConnect
Invalid value java.sql.SQLException: No suitable driver found for jdbc:sqlserver://servername for configuration Couldn't open connection to jdbc:sqlserver://servername
name=JdbcSourceConnector
connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
connection.user=user
connection.password=password
tasks.max=1
connection.url=jdbc:sqlserver://servername
topic.prefix=test
table.whitelist=dbo.IB_WEBLOG_DUMMY_small
query=SELECT * FROM IB_WEBLOG_DUMMY_small
value.converter=org.apache.kafka.connect.json.JsonConverter
key.converter=org.apache.kafka.connect.json.JsonConverter
poll.interval.ms=5000
table.poll.interval.ms=120000
mode=bulk
What should I be looking into to fix this problem?
Your JDBC driver’s JAR file is not in Kafka Connect’s classpath. Put it there and you will be good to go:
One option is to install the JDBC driver jar alongside the connector. The packaged connector is installed in the share/java/kafka-connect-jdbc directory, relative to the installation directory. If you have installed from Debian or RPM packages, the connector will be installed in /usr/share/java/kafka-connect-jdbc. If you installed from zip or tar files, the connector will be installed in the path given above under the directory where you unzipped the Confluent Platform archive.
Alternatively, you can set the CLASSPATH variable before running connect-standalone or connect-distributed. For example:
$ CLASSPATH=/usr/local/firebird/* ./bin/connect-distributed ./config/connect-distributed.properties
Alternatively, put all the SQL Server JDBC JAR files in the libs dir under the root folder of Apache Kafka. But that would pollute the classpath and is better to be avoided in production.
Mmm. I put the postgre jar on the lib folder of hsql database manager but then I tried to use the database manager an error occurs "java.lang.ClassNotFoundException:org.postgresql.Driver".
It is not enough to put the jar in the lib folder. You need to include the jar in the command line that you use to execute DatabaseManager. An example for Windows below:
java -cp /path/to/hsqldb.jar;/path/to/postgres/pg.jdbc3.jar org.hsqldb.util.DatabaseManagerSwing
I am a newbie.
I am trying to publish procedures which return refcursor as webservice.
As webservices do not support ref cursor return type so I chnaged the return type to pl/sql table.
I created the jax rpc in Jdeveloper studio 11.1.2.4.0 and tested it. This runs ok. I need to deploy it on tomcat server and am failing completely.
I copied the war file generated by Jdeveloper to the webapps directory in Tomcat and started Tomcat but this didn't work, as the following exception was thrown:
java.lang.ClassCastException: omsdevconn.MyWebServicetomcatUser cannot be cast to javax.servlet.Servlet
If someone has done it then can I get the steps for the process to deploy it on Tomcat 6.0.37?
Thanks in advance
Download jaxws-rt-2.0-SNAPSHOT.jar and jaxws-2_0.jar
Copy into $CATALINA_HOME/lib folder
Add the following in web.xml under web-app
<web-app>
**<listener>
<listener-class>
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
</listener-class>
</listener>**
............<!--your other servlet definations-->
</web-app>
create sun-jaxws.xml under your applications web-inf folder and configure endpoints.You can have a look at jdeveloper generated xml file to get all the information
sample sun-jaxws.xml
<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"version="2.0">
<endpoint name="fromwsdl"
interface="com.foo.yourserviceInterface"
implementation="com.foo.yourserviceClass"
wsdl="WEB-INF/wsdl/youservice.wsdl"
service="YourService"
port="YourServicePort"
url-pattern="/serviceAccessUrl" />
</endpoints>
create war for your application and deploy you application under tomcat/webapps
start tomcat
After starting tomcat you can access the service as
http:/host:port/yourservicename/methodInService
As you are calling oracle plsql code and IF you are using any oracle specific calls like OracleCallabelStatement then on run time you will get class cast exceptions from tomcat datasource when trying to cast callabelstatement to oraclecallabelstatement for that you need to configure oracledatasource in tomcat
http://www.oracle.com/technetwork/articles/oem/ucp-jdbc-tomcat-355431.html
More information on Java API for XML Web Services (JAX-WS)
https://jax-ws.java.net/nonav/2.2.1/docs/UsersGuide.html#1.0_Introduction
Another way to deploy service generated by Jdeveloper when exposing a plsql procedure as webservice
I am not allowed to post more that 2 links so please add and extra "/" after http: to correct the links
This solution uses Apache Axis which allows you to call your web service(which is not exposed as restful) directly from browser by creating a SOAP request behind the scenes and involke the service method giving it soap message.
1)Generate a webservice in Jdeveloper .It will create java files and corresponding ".class" file , "wsdl file" in web-inf and some other xml files. Make a note of LOCATION of .class file and wsdl file.
2)Download eclipse and extract it on your hard drive (It needs java to run So you must have java installed on system .You can download eclipse from
http:/www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/junosr1
3)Download Axis plugin for eclipse from here :
http:/www.apache.org/dyn/mirrors/mirrors.cgi/axis/axis2/java/core/1.6.2/axis2-eclipse-service-plugin-1.6.2.zip
and install it in eclipse. Installation Instructions :
http:/axis.apache.org/axis2/java/core/tools/eclipse/plugin-installation.html
4)Generate the aar file via eclipse axis plugin. Instructions :
http:/axis.apache.org/axis2/java/core/tools/eclipse/servicearchiver-plugin.html#Operation
5)Make following changes in tomcat-user.xml file
<role rolename="tomcat"/>
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<role rolename="manager-jmx"/>
<role rolename="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat,manager-gui,admin-gui,manager-jmx"/>
6)IF YOU ARE USING ORACLE SPECIFIC CLASSES IN CODE (Which most probably Jdeveloper will produce) : Configure a oracle data source in tomcat (server.xml or context.xml). Instructions :
http:/www.oracle.com/technetwork/articles/oem/ucp-jdbc-tomcat-355431.html
Make sure you have ojdbc6.jar and ucp.jar in Tomcat/lib folder.
7)Download axis war file to deploy in tomcat from here :
http:/www.apache.org/dyn/mirrors/mirrors.cgi/axis/axis2/java/core/1.6.2/axis2-eclipse-service-plugin-1.6.2.zip
Unzip the zip , it will have a axis2.war file in it. Put this war file under “\Tomcat\webapps” directory
8)Start tomcat. On tomcat console see if there are any errors in deploying axis. If everything is fine you should be able to see axis page on http:/yourhost:yourport/axis2/
9)Click on Administration link . Enter user id “admin” and password “Axis2” and login
10)Click upload and browse to the location of aar file you generate in step 4 and upload. After it shows you success click on Available service. It takes a bit of time but you should be able to see you service.Click on service to see wsdl to verify
11)Call your service method from browser and cross your fingers and toes.
Note that the link to hit will be something Like
http:/yourhost:yourport/axis2/services/YourServiceName/serviceMethod?arg1=blah&
Make sure your got the arg names right.you should be able to see the correct names from wsdl