Connecting Java-Spring application war to AWS RDS Oracle DB instance - amazon-rds

I have an AWS EC2 windows instance and have my application war running there on Tomcat server. Following is my db.properties file -
driverClassName=oracle.jdbc.driver.OracleDriver
url=jdbc:oracle:thin:#whitelabeldb.cyor6spheonu.ap-south-1.rds.amazonaws.com:1521:ORCL
username=admin
password=pwc12345
initialSize=2
maxConnections=10
maxIdle=1
minIdle=1
My application-context file is reading this properties file. When i try to hit any service of my application i get the below error -
Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'
java.lang.ClassNotFoundException: Could not load requested class : oracle.jdbc.driver.OracleDriver
I tried manually adding the ojdbc6.jar in the lib of the WAR file. By doing that, i stop getting any error in the logs but a 404 in postman. I cannot change the complete architecture of my application and convert into spring boot or something because it is a big application.
Please help me with some solution.

Add ojdbc7 jar to the pom.xml and download the dependency. If not able to add it, try to dowload from https://mvnrepository.com/artifact/com.oracle/ojdbc7/12.1.0.2 and add it to build path.
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2</version>
</dependency>

Related

Azure Application Insights agent for Java causing Could not find or load main class %JAVA_OPTS on JBoss 18

I am implementing Azure Application Insights in Java application. Azure Docs
I have added below configure in standalone.conf JBOSS/WildFly configuration
However when I start the server I am getting below error
[root#server-1 bin]# ./standalone.sh
=========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /opt/wildfly
JAVA: /usr/lib/jvm/jdk1.8.0_261/bin/java
JAVA_OPTS: -server %JAVA_OPTS% -javaagent:/tmp/azurejar/applicationinsights-agent-2.6.1.jar
=========================================================================
Error: Could not find or load main class %JAVA_OPTS
Could you please help me to resolve this issue ? Any help is much appreciated.
That's Windows syntax. In a Unix-based environment like Linux you use the $ to access environment variables. Change the %JAVA_OPTS% part of the line to $JAVA_OPTS, i.e.:
JAVA_OPTS="$JAVA_OPTS -javaagent:/tmp/lib/applicationinsights-agent-2.6.1.jar"

Running Spark2.3 on Kubernetes with remote dependency on S3

I am running spark-submit to run on Kubernetes (Spark 2.3). My problem is that the InitContainer does not download my jar file if it's specified as an s3a:// path but does work if I put my jar on an HTTP server and use http://. The spark driver fails, of course, because it can't find my Class (and the jar file in fact is not in the image).
I have tried two approaches:
specifying the s3a path to jar as the argument to spark-submit and
using --jars to specify the jar file's location on s3a, but both fail in the same way.
edit: also, using local:///home/myuser/app.jar does not work with the same symptoms.
On a failed run (dependency on s3a), I logged into the container and found the directory /var/spark-data/spark-jars/ to be empty. The init-container logs don't indicate any type of error.
Questions:
What is the correct way to specify remote dependencies on S3A?
Is S3A not supported yet? Only http(s)?
Any suggestions on how to further debug the InitContainer to determine why the download doesn't happen?

Error opening zip file or JAR manifest missing : jrebel.jar

When configuring JRebel on my remote server (JBoss on linux) I have configured the JVM arg as
-javaagent:/home/user/jrebel.jar" -Drebel.remoting_plugin=true
The jrebel.jar is absolutely definitely in that location, yet the server fails to start with the error:
Error opening zip
file or JAR manifest missing : /home/user/jrebel.jar Error occurred
during initialization of VM agent library failed to init: instrument
So the arg is oviously being passed to the JVM correctly, but for the life of me I can't work out why it can't find the jar. I've been through every Zero Turnaround article I can find + looked at the solutions that have resolved it for other people, but no luck. Any ideas?
Turned out to be a permissions problem - the JBoss user didn't have the permissions to access the directory that I had placed jrebel.jar into.
Would have been nice to have a more meaningfull error - e.g. 'permissions denied'. Shows my lack of Linux knowledge though I guess.
After the jar was moved to a directory within the JBoss installation + the jar owner was changed to the JBoss user and Read/Write/Execute permissions added, all is well.
Yes , the permission is the reason that this error happens to me when I tried to open PHPSTORM and that error was :
Error opening zip file or JAR manifest missing : ${JetbrainsIdesCrackPath}
Error occurred during initialization of VM
agent library failed to init: instrument
so before running PHPSTORM I had to run the command : sudo -i to get the root permission to run the program.

Cobertura -java.lang.IllegalArgumentException: Class does not have a default interface

I am using Cobertura to code coverage for Integration test. I am facing below issue while deploying instrumented jar in JBoss server.
DEPLOYMENTS IN ERROR: Deployment "vfszip:/D:/jboss-5.1.0.GA/server/test/some_jar.jar/" is in error due to the following reason(s):
java.lang.IllegalArgumentException:
Class class com.someclass does not have a default interface
Here are the steps I followed so far:
Downloaded cobertura-1.9.4.1.
Using this command obertura-instrument.bat C:\some_jar.jar I generated the .ser file and instrumented jar for some_jar.jar.
Placed the jar in JBoss server test/ folder.
Copied the .ser file to JBoss/bin folder.
Copied the Cobertura.jar to Jboss/lib folder.
Run the JBoss server.
Please let me know if I am missing any thing here.
Probably a configuration file error because you possibly have not adjusted a setting before starting for the first time.

Could not open Hibernate Session for transaction when deploying web application on tomcat on centOS5/linux

Tomcat version : 7
OS: CentOS-5
Description : Deployed a .war file /web application on Tomcat7 on Centos5 through jenkins
the deployment is successful and able to view the web application. But when i access the feature which uses the DB , below exception is thrown with no further stack trace
Exception when connecting to DB : org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection
DB parameters specified
In /conf/context.xml
<ResourceLink name="jdbc/com/gtspt/vrs"
global="jdbc/com/gtspt/vrs"
type="javax.sql.DataSource"/>
In /conf/server.xml
<Resource
name="jdbc/com/gtspt/vrs"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:#gts-ora-rac-gns.dmz.gtspt.corp:1521/edged"
username="XXXXX"
password="XXXXX"
maxActive="10"
maxIdle="10"
maxWait="-1"/>
Same set-up/configuration Works on tomcat 7 on windows locally. Please guide me. i am new to linux
.Telnet from the linux system to the db is successfull

Resources