JDBC Driver class not found: oracle.jdbc.OracleDriver - oracle

I have installed a third party java webservice which uses Oralce jdbc thin driver to write data into Oracle database. When i run this, i get the following error;
JDBC Driver class not found: oracle.jdbc.OracleDriver
I have oracle installed and set classpath variable to following value:
*D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.zip;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.zip;C:\Program Files\Java\jdk1.7.0\jre\lib\rt.jar*
and path variable to following value;
*D:\oracle\product\10.2.0\client_1\bin;C:\Program Files\Java\jdk1.7.0\bin\;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.zip;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.zip*
Any suggestion why web service is not able to identify jdbc driver?
Thanks

I know 2 ways of turning Java app into Windows service and both do not use CLASSPATH. One is Java Service Wrapper by Tanuki Software. This tool uses wrapper.conf where you can show directories with .jar libraries:
# Java Classpath (include wrapper.jar) Add class path elements as
# needed starting from 1
wrapper.java.classpath.1=c:\jars\*
wrapper.java.classpath.2=myservice.jar
Second tool I know is JSL: Java Service Launcher. In this tool there is jsl.ini where you put command line to run your server. It can use java with -cp option to show location of .jar libraries:
[defines]
MY_LIBS=d:\jars\*
AXIS_LIBS=d:\axis2-1.5.4\lib\*
CLASSPATH=.;%MY_LIBS%;%AXIS_LIBS%
export = CLASSPATH
...
[java]
...
cmdline = -Dfile.encoding=utf8 -cp %CLASSPATH% example.my.server
In both configuration you can use * to add all .jar files or you can show those files one by one (just like in CLASSPATH).
At first you should know what Windows is trying to execute. Check it in the service properties page. Then try to localize its configuration. If it uses one of tools I know then you know what to change. Other tools probably have similar configuration.

Method 1:
Download ojdbc.jar
add ojdbc6.jar to deployment assembly.
Right click on project->properties->select deployment assembly->click on 'Add'
->select 'Archives from File System'->browse to the folder where ojdbc6.jar is saved.->add the jar->click finish->Apply/OK.
Method 2:
if you want to add ojdbc.jar to your maven dependencies you follow this link:
http://www.mkyong.com/maven/how-to-add-oracle-jdbc-driver-in-your-maven-local-repository/
.
.
Even if you're using a maven project it is not necessary to add ojdbc to maven dependencies(method 2), method 1 (adding directly to deployment assembly) works just fine.

Make sure you have the ojdbc jar file (make sure you are using the correct one because depending on java version you may need to choose a different one).
use ojdbc14.jar for Java 1.4
use ojdbc5.jar for Java 1.5
ojdbc6.jar for Java 1.6
here is linke where you can download ojdbc6.jar file
http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html

You also have to add the jdbc jar to your server classpath. if tomcat, rigth-click on your Project->run as->run configurations, click on classpath and add your jdbc jar in Add external jars option

add ojdbc-6.jar to your lib directory of tomcat installation. Maven will downlowd this jar for you in .m2 directory, but you need to have this jar in tomcat lib as well.

Related

No main manifest attribute found in Corda Standalone Shell jar of Corda Enterprise v4.0

I want to evaluate Corda Standalone Shell of Corda Enterprise v4.0.
I have downloaded corda-shell-4.0.jar from below URL
https://www.r3.com/corda-enterprise-download/
And refering to below document
https://docs.corda.r3.com/releases/4.0/shell.html?highlight=standalone%20shell#the-standalone-shell I am analysing the Standalone Shell and when I run java -jar corda-shell-4.0.jar command then I get the following error:
no main manifest attribute, in corda-shell/corda-shell-4.0.jar
When I checked the MANIFEST.MF file then there is no Main-Class specified in the Manifest file.
Can anyone please guide me how to use the standalone shell?
Have a read of this - https://docs.corda.r3.com/releases/4.0/cli-application-shell-extensions.html .
It the jar is not meant to be run via java -jar. Instead, you install the CLI commands and need to set up some config to get it all to work.

How to set the JDBC driver JAR in Telosys CLI to create a dbmodel

I use Telosys Eclipse Plugin regularly to generate my Java code from a “dbmodel” built from a PostgreSQL database. In Eclipse with a Java Project the JDBC driver is already in the Java Build Path so it’s very easy to create the “dbmodel”.
Now I’m trying to use Telosys CLI (instead of the Eclipse Plugin) to generate JavaScript code for NodeJS. I’d like to create a new “dbmodel” from another PostgreSQL database, the question is: with Telosys CLI how can I specify the JDBC driver (jar file) that must be used to create this new “dbmodel”?
When your project is not a Java project you just have to put the JDBC driver jar file in the "lib" directory of the "TelosysTools" folder. Once you have do that you can reference the driver in the "databases.dcfg" file (as usual) and Telosys will find it.
For example : "TelosysTools/lib/derbyclient.jar"
In Telosys-CLI this is the only way to use a JDBC driver to create a "dbmodel"
In the Eclipse plugin you can also use the "lib" folder if the jar is not defined in the "Java Build Path"

Configure patched module in jboss eap 7

We use eclipselink in our applications therefore we configured JBoss to use eclipselink as persistence provider. We configured this by putting the eclipselink.jar into the following path:
JBOSS_HOME/modules/system/layers/base/org/eclipse/persistence/main
In addition we have changed the module.xml accordingly. After that we could use it and it worked fine.
Now we want to configure the jboss with a command line script to avoid manual work. In addition the jboss should be patched to the current patch level (jboss eap 7.0.7).
After applying the patch the eclipse persistence module is in the following path:
JBOSS_HOME/modules/system/layers/base/.overlays/layer-base-jboss-eap-7.0.7.CP/org/eclipse/persistence/main
With a later patch the path could be different therefore we don't want to copy files in absolute paths.
Is it somehow possible to use the jboss-cli to configure this module (add jar and change module.xml)?
You can use
module add --name=MODULE_NAME --resources=PATH_TO_RESOURCE --dependencies=DEPENDENCIES --module-xml=YOUR_MODULE.XML
--module-xml - (used with add, optional) filesystem path to the module.xml
file which should be used for the added module. The file will
be copied to the created module's directory. If this argument
is not specified, module.xml file will be generated in the
new created module's directory.
MODULE_NAME should be org/eclipse/persistence/main in your case

Installing Log4J 2 on Windows 10

I am trying to install log4j (2) on Windows 10. I downloaded and extracted log4j from https://logging.apache.org/log4j/1.2/download.html
However I don't know what do add to the path variable or how to call log4j on windows 10.
The latest steps on Linux for log4j where:
$ export CLASSPATH=$CLASSPATH:/usr/local/apache-log4j-1.2.15/log4j-1.2.15.jar
$ export PATH=$PATH:/usr/local/apache-log4j-1.2.15/
The Problem here is, as far as I know, Windows has no classpath and there is no log4j.jar file just log4j-core and log4j-api (and similar) jars.
If someone could help me set this up correctly I'd greatly appreciate this.
Log4j does not require installation. It is a set of libraries. You should not specify the CLASSPATH as a system-wide environment variable (however it is acceptable). If you want your application make use of log4j you should propagate the class path to log4j libraries as a parameter to java.exe. If you need those libs on development phase you should either specify the path in your IDE project settings (the way how to do this is specific for each particular IDE), or, if you use standard maven project type, specify the appropriate dependency in pom file so that IDE takes care of proper classpath configuration.
Please also refer to this post helping you to get started with log4j.

Unable to start Spring Boot executable jar using IBM JRE 1.8

We have a Spring Boot application which is built as an executable jar and runs fine using both the Oracle and OpenJDK JREs (using 1.8 versions).
Attempting to run it using the IBM 1.8 JRE however results in the following error at the command line.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
This occurs if we execute the jar (using ./application.jar) or using java -jar application.jar
This led us to change the packaging to not make the jar executable and this allows us to start the application using java -jar application.jar. So it appears the IBM JRE doesn't like the launch script.
The problem is we don't want to have two packaging methods for different deployment environments, if possible.
Does anyone have any experience of why the IBM JRE doesn't like the script on the front of the jar file and whether there are any command line options to disable whatever checking its doing?
From your post it is unclear if you have problem with
1) running jar from Linux like chmod a+x application.jar and executing
Or
2) running via /opt/IBM/java/jre/bin/java -jar application.jar
For option 1) it is not a good idea as you do not explicitly choose jvm binary and rely on OS to choose one for you.
Read about binfmt_misc mechanism:
https://en.m.wikipedia.org/wiki/Binfmt_misc
For option 2)-it might be class loading problem, please add
/opt/IBM/java/jre/bin/java -verbose:class -jar application.jar
and consult documentation here: https://www.ibm.com/developerworks/library/j-dclp1/index.html

Resources