I'm running into java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver
I can get around the error by putting jtds.jar file in the CATALINA_HOME/lib directory but this isn't an ideal solution as the application should be modular enough to be deployable on any server.
I have the jtds.jar file in [tomcat_dir]/webapps/myapp/WEB-INF/lib which is where I want it to be found from.
I know there are TONS of similar questions so I apologize if this is a duplicate but I've yet to be able to find a post that helps.
Why can't my app find the correct jtds.jar file which I've included in the app package? What do I need to do in order to get the app to recognize that jar file?
Tomcat 6 and higher demands that JDBC driver JARs appear in the server /lib, especially if you have JNDI data sources.
It might not be ideal, but you'll have to get over it. How often will you be changing app servers?
Related
This is my first question here, and, for some reason, when trying to upload a screenshot of my problem, I got an error message which read
Failed to upload image; couldn't reach imgur
Anyway, I have uploaded it onto Google Photos, so I will send the link after explaining a little what it is.
I am new to developping Apps in Java, specially when it is about connecting to JDBC. So, as the target database is a SyBase one, I downloaded JTDS JDBC Driver from its official website on sourceforge
Afterwards I did what was suggested here so as to set up the class path.
Include jtds1.3.1 into the library and my project, so it was supposed to work, and... voilà!
A fantastic ClassNotFoundException when executing the Class.forName() method to load the driver.
Here is the screenshot, being lines 35 and 37 the ones of interest.
I would be so grateful should someone help me a little, however stupid may be the error I may be doing to have this problem - which sure it is.
Thanks.
Looking at that screenshot, the problem is that you added the distribution zip (jtds-1.3.1-dist.zip) to your buildpath, instead of the jtds-1.3.1.jar included in that zip. So unzip, remove the zip from the build-path and add the jar-file.
You have to put the full path to the jarfile in the classpath (including the filename):
.;C:\j2sdk1.4.2_16\jre\lib;
C:\Program Files\mysql-connector-java-3.1.144\mysql-connector-java-3.1.14-bin.jar
after change path once restart your cmd
I'm running a JBoss server (inside Eclipse), with some Hibernate mixed in. I installed Oracle's ojdbc drivers from here:
Oracle Database 11g Release 2 JDBC Drivers
I specifically downloaded the file: ojdbc6dms_g.jar, which according to the site contains instrumentation to support DMS. However when I startup my AS server, I get the following:
Caused by: java.lang.ClassNotFoundException: oracle.dms.console.DMSConsole from [Module
"com.oracle:main" from local module loader #485fcf29 (roots: /usr/local/jboss-7.1.1-
final/modules)]
when the server is trying to get a new hibernate ejb exception.
I checked Oracle's jar file and sure enough it doesn't contain the class oracle.dms.console.DMSConsole, although from the notes on Oracle's site about the jar file, it seems like the jar file should contain the DMS classes.
Can anyone point me to the correct jar file? And when I do get the right file, where should this file be installed to, particularly with regards to Eclipse and JBoss?
Update: Just found another question asking the same thing here on SO.
The missing classes are indeed in dms.jar. But as I've seen asked elsewhere finding the dms.jar file is not easy. You won't find dms.jar at Oracle Database 11g Release 2 JDBC Drivers because as noted by Oracle: dms.jar is not shipped as part of the RDBMS product. It is only available as part of the Oracle Application Server product.
I hopped onto our server and grabbed the jar file from our Oracle installation directory. We have 11g installed. With 11g you should be able to find the file here:
$ORACLE_HOME/oc4j/lib/dms.jar
I got the same error for different reason and yes it was due to missing dms.jar file. I just had to find where dms.jar file was on our Oracle Application server (Release 12.2.3) and assigned it to the CLASSPATH. And it worked. Thanks for the pointing to the missing .jar file.
Out .jar file was in $ORACLE_HOME/lib/ folder. Changed the path value as :
CLASSPATH=$CLASSPATH:$ORACLE_HOME/lib/dms.jar and it started working.
Fyi..if it helps anyone i was trying to load BI/XML publisher DATA TEMPLATE using XDOLoader utility when i got this error.
-ppemavath
i too face this problem but when i removed all database related jars and added ojdbc6 (or ojdbc7) jar then application working fine. more details please see below link.
https://community.oracle.com/thread/2388722
When I was developing Struts2 application, I was getting
Exception starting filter struts2 java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter",
for this reason I was changed the filter to FilterDispatcher also. Then also I got same error. For that I placed the same jar files in WebContent\WEB-INF\lib folder then it was working fine. I didn't get why this was happening. Any one help.
I am not sure what all lib you have in your class path.Please have a look at Strut2 simple-setup which explains what all required dependencies you need to have to run application.
Alternatively best way to download sample application from Struts2 official site and run it, to have a look at what all is required to run it.
It seems like you are missing struts2-core.jar though this error can be due to other reasons
At runtime, the webserver will pick up class files from jars kept at WEB_INF\lib and other class files kept at WEB_INF\classes directory.
I have a problem trying to deploy my project:
«Found a jar file too large to upload». The problem occurs when the script tries to upload
appengine-api-1.0-sdk-1.5.3.jar (15.8 MB although only 10MB files are allowed).
The problem is well-known since 2009. There are a lot of tickets in google issue tracker and here as well. There are a lot of messages of this kind all over the web. But all of them are referring to the two solutions:
1) Using the --enable_jar_splitting. Surely I've tried to use it. No success:
# appengine-java-sdk-1.5.3/bin/appcfg.sh -e some_mail#gmail.com --enable_jar_splitting update project/war
Reading application configuration data...
......
java.lang.IllegalStateException: Found a jar file too large to upload: "/tmp/appcfg4869648953084473935.tmp/WEB-INF/classes/war/WEB-INF/lib/appengine-api-1.0-sdk- 1.5.3.jar". Consider using --enable_jar_splitting.
Unable to update app: Found a jar file too large to upload: "/tmp/appcfg4869648953084473935.tmp/WEB-INF/classes/war/WEB-INF/lib/appengine-api-1.0-sdk- 1.5.3.jar". Consider using --enable_jar_splitting.
Please see the logs [/tmp/appcfg5857347513630341491.log] for further information.
I tried to use different versions of SDK (1.4.3, 1.5.2 and the latest 1.5.3). But the script ignores the --enable_jar_splitting option.
2) Unpack appengine-api-1.0-sdk-1.5.3.jar to WEB-INF/lib. Another error arises in this case. Projects are limited by 3000 files. There are 3500 files approx. in appengine-api-1.0-sdk-1.5.3.jar archive and 100 files in my project. So, this solution does not work as well.
3) I have found the 3d solution myself. You can delete the appengine-api-1.0-sdk-1.5.3.jar from WEB-INF/lib directory. It works but only in cases you're having simple projects. But it does not work in case of projects using all the power of google appengine. I need to use datastore and some other functions. Without the appengine-api-1.0-sdk-1.5.3.jar the project could be deployed, but it does not work and produces errors in google error console (classes are missing).
I have sent a message to google. They're keeping silence, unfortunately.
Please help me, you clever guys. I will be awfully grateful. Hope, there is a little trick to get it work.
You don't need to upload the API jar - it's part of the App Engine platform. Whatever configuration you've changed that is causing the SDK to try and upload it, you should change back.
You can try to split appengine-api-1.0-sdk-1.5.3.jar manually.
Unzip the jar file.
Zip half the files to one jar file
Zip the other half to one jar file.
Update your class path and build tools.
I am building an update system in which I need to be able to replace a referenced jar of a running application jar at runtime. However, I am running into file locking issues on Windows when trying to perform file utility functions on the jar such as 'setLastModified'.
After some googling I found this snippet...
What I found in my research is that
the standard ClassLoader
implementation never closes a jar
file once it has been opened. It also
only loads resources from the jar file
as needed. So at any particular time,
there may be Classes in the jar file
that have not been loaded into memory.
Obviously, if you delete the jar file
out from under the ClassLoader, and it
tries to find a resource in the
missing file, you're going to get an
IOException at the very least.
Does anyone have any references to information on doing this, or working around this issue?
Thanks.
There is a lot of solutions for classes/lib hot-swapping :
Hotswap for ant
JRebel
OSGi
It depends on what you want to do.
The closest thing is OSGi
Please have a look at the 'See also' section of the mentioned artice for concrete products.
I don't know of any good way to deal with this. Creating a custom classloader might be an option, although I don't like that idea..
We worked around it by running an updater from a separate jar before launching the main application. This works well enough, but obviously, you can only update the jar when the application is launched.