I have a JAVA application that runs fine in my local Windows7 environment on Tomcat7. I am trying to put this into production in a Linux environment.
Everything is done and is working fine except when my application tries to access the DB. Operations where DB is not involved, it works fine.
The error I get is
java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory
This class is part of tomcat-dbcp.jar. This is placed in my $CATALINA_HOME/lib folder. Why is this still not getting picked up? Please help!
UPDATE: I also opened up the .jar file and checked. The org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory.class file is present.
Was finally able to crack it. My mistake - I was relying only on echo $CATALINA_HOME to check its location. Turns out that this can be misleading.
It is better to use
ps aux | grep catalina
In the output that comes look for catalina.base and catalina.home. The path given in front of these variables is the path from where Tomcat libs are being fetched. I had done a default installation and found the libs under /usr/share/tomcat7. As it turns out, the default installation done using yum did not provide the tomcat-dbcp.jar file. Instead it provided the commons-dbcp.jar. Read about tomcat-dbcp vs commons-dbcp
Changing the lib files under the usr/share/tomcat7 folder required me to use sudo bash. Also you may notice that the lib folder under /usr/share/tomcat7 is a simlink. Just do ls /usr/share/tomcat7 -l to get the parent location. You will be able to make changes only in the parent location.
Similar things can be checked for server.xml which is also finally being picked from /usr/share/tomcat7 itself.
The best way to manage all these is to create your own simlinks so that you don't need to bother about going to various locations after the first time.
Thanks to everyone who tried to help.
Related
I followed the steps given from the official source here.
To deploy Webswing to Tomcat, follow the following steps:
Create a new folder named webswing in Tomcat’s home folder and unzip
the Webswing distribution to this folder.
Move webswing-server.war from the distribution package to Tomcat’s
webapps folder.
In conf/catalina.properties file add the following properties.
webswing.warLocation=webapps/webswing-server.war
webswing.configFile=webswing/webswing.config
webswing.tempDirBase=webswing/tmp
I followed all the steps above. But the result seems it's ERROR.
Then i tried to access(but no luck):
localhost:8080/webswing
nor
localhost:8080/webswing-server
Please take note that I'm currently using Tomcat server normally.
My specs are:
Windows 7 with 64bit, 8gb ram
JDK 8 for 64bit
Tomcat8.5.31
I thought there's no tmp folder, but after i check it out, the folder still exists there. And i also check the catalina properties, it's exactly 3lines code written already. So, What should i do to resolve this case? Any other clues?
I just tried from scratch according to documentation and have the same result.
The issue is starting directly the startup.bat
When I start the tomcat from CATALINA_HOME everything works fine, I assume starting as a service would work.
This is how I started the tomcat:
c:\_DEV\apache-tomcat-8.5.31>.\bin\startup.bat
When you start the startup.bat directly, you will see this as root cause (notice the bin in the path):
Root Cause
org.webswing.server.model.exception.WsInitException: Invalid system property webswing.warLocation: File c:\_DEV\apache-tomcat-8.5.31\bin\webapps\webswing-server.war or c:\_DEV\apache-tomcat-8.5.31\bin\webapps\webswing-server.war not found.
I've installed zookeeper v 3.4.9 on suse using the following package:
http://download.opensuse.org/repositories/home:/nicolasbock:/midokura/openSUSE_Leap_42.2/x86_64/zookeeper-3.4.9-1.1.x86_64.rpm
Starting the server works just fine an the various application that need to connect to it seem to be able to do so just fine, however I'm getting a strange error when I try to start the client:
zkCli.sh -server 127.0.0.1:2181
Error: Could not find or load main class org.apache.zookeeper.ZooKeeperMain
I've tried searching around the internet but the only answer I've come up with is setting the env variable $CLASSPATH. I tried looking what classpath is used internally by the serve starting script and set $CLASSPATH to that but with no results.
I'm running openjvm v 1.8.0_121
I encountered this problem today on Ubuntu 18.04. On zookeper official download page once one follows the given mirror link and chooses stable version, he can see 2 files available. In my case those were:
apache-zookeeper-3.5.5-bin.tar.gz
apache-zookeeper-3.5.5.tar.gz
I chose apache-zookeeper-3.5.5.tar.gz, observed the same problem. Tried to print CLASSPATH as #Jonathan suggested, it was printing different paths however, problem is that the archive file did not contain zookeper jars, probably it is expected that user packages to jar himself as I could find source code in that archive file.
Downloading larger apache-zookeeper-3.5.5-bin.tar.gz archive, extracting and running ./zkCli.sh went smooth as it had everything necessary, so whoever faces the same problem, try that and see if it does the trick for you.
Are you trying on Unix or Windows?
I dont think, you need "-server 127.0.0.1:2181"
Just run zkCli.sh or zkCli.cmd
That is a classpath problem. The zkCli.sh script is attempting to launch a java app where the main class is ZooKeeperMain. However, java cannot find the ZooKeeperMain class file because the classpath being passed to java does not contain a jar file that contains the ZooKeeperMain class.
Typically, the ZooKeeperMain.class file is contained in a jar file at something like $ZOOKEEPER_HOME/zookeeper-3.4.13.jar.
You might trying modifying the zkCli.sh script to print out the classpath just before the script attempts to launch ZooKeeperMain. The classpath should contain the jar that contains the ZooKeeperMain class.
On my Windows 10 machine, my classpath looks like this:
/c/Program Files (x86)/Zookeeper/bin/../build/classes:/c/Program Files (x86)/Zookeeper/bin/../lib/slf4j-log4j12-1.7.25.jar:/c/Program Files (x86)/Zookeeper/bin/../lib/slf4j-api-1.7.25.jar:/c/Program Files (x86)/Zookeeper/bin/../lib/netty-3.10.6.Final.jar:/c/Program Files (x86)/Zookeeper/bin/../lib/log4j-1.2.17.jar:/c/Program Files (x86)/Zookeeper/bin/../lib/jline-0.9.94.jar:/c/Program Files (x86)/Zookeeper/bin/../lib/audience-annotations-0.5.0.jar:/c/Program Files (x86)/Zookeeper/bin/../zookeeper-3.4.12.jar:/c/Program Files (x86)/Zookeeper/bin/../conf:
I encountered a similar errors as yours when launching zkCli.sh from Git Bash for Windows on my Windows 10 machine. My issue was because of the way Git Bash was handling wildcards in the classpath. I initially had some *.jar entries in my classpath that I removed to get zkCli.sh to launch.
I am configuring my study environment :) on Linux server: I have installed java, oracle database, tomcat, and I have set JAVA_HOME, ORACLE_HOME variables for all users and modified the .bash_profile files as I read it is the only way to make things permanently set. However I am not sure what variables do I need to set for TOMCAT, when I try to start tomcat from another user different from root[even here I have to go inside tomcat's bin folder], I see that the process is trying to use CATALINA_HOME, CATALINA_BASE,CATALINA_TMPDIR and CLASSPATH [for bootstrap.sh (I am not sure why it needs bootstrap.sh)], anyway my question is which variables do I need to set for tomcat? Do I need to set all of them in root and all other users .bash_profile files? I need some clearification because I am really fed up with configuration having a lot to know beyond that, just need help.
More to that I think I have installed MAVEN [MAVEN_HOME not set either], I say I think because when I try
locate maven
I have the following result:
/etc/maven
/etc/maven/maven2-depmap.xml
/usr/local/apache/tomcat/apache-tomcat-6.0.37/webapps/docs/maven-jars.html
/usr/share/java-utils/xml/maven2jpp-mapdeps.xsl
If I try the following I have not output
locate maven | grep bin
[Not sure if this is a good question to ask the server, since deep in /etc/maven ls -la show me there is total 32 but I can only see maven2-depmap.xml]
The question is, looking at the files found when I tried locate maven, can anyone tell if I have installed it or not? :):)
Further I need To install GIT following some installation guide I had found it is been a week I don't really remember which one was that, I started by downloading curl_devel, gettext_devel some other *_devel stuff [I don't know what they are and not sure if I should know about them] and when I tried to install them, they required git to be installed I looked around for git packages to download but after 7 to 10 minutes I didn't find where I can really get git packages, but since I didn't give it much attention this question is not as important as others. what I want to know is, once I get git installed which environment variables will I have to set?
Thank you very much for taking time to read and help. I appreciate.
I think the other simple round about can the changing the user of the TOMCAT. Set it to the root user.
This will be useful only if you have set correct path and tomcat is working properly with root user.
I also dont know if this is recommended or not.
I can't get any pages of my webapp to load (locally on Tomcat 7.0.2.6), due to this NoClassDefFound error. I'm at my wits end trying to figure out what the cause is, here is what I know:
My coworker has this project successfully running locally (on Tomcat) and on our development server (WebLogic).
I have done a fresh pulldown from svn so my code is exactly the same as his. I've verified that I have a shared library reference to Aspose (and that the required .jars are in there), and that weblogic.xml has an entry for it.
We saw this same error when initially deploying on WebLogic because the Aspose library was named incorrectly, but it ran fine locally on his Tomcat server.
I've tried cleaning and rebuilding the project to no effect.
As best as I can figure, it has to be either a Tomcat issue, or maybe an Eclipse setting.
Has anyone encountered a similar situation? Any ideas on what to try to resolve this?
First thing you need to do is determine if you are colliding with another class with the same name and package. The easiest way to do this is with the cygwin/linux console, save this shell script to a file say, findjar
find "$1" -name "*.jar" -exec sh -c 'jar -tf {}|grep -H --label {} '$2'' \;
put it in your path and navigate to the root of the server instance and run the script like this
findjar . yourclass
Note the period, dont forget it. this will return if you have multiple classes with the same name in your project.
once your sure the project is clean and there is only one copy of the class, i would try actually adding your shared libraries folder to the websphere server instances JVM arguments. to do that:
Go into the admin, click on servers
Open server types, click on websphere application servers
You should see your server listed there, click on it
On the right hand side, you will see a section “server infrastructure” and below that is a subsection “Java and process Management”
Open that section and click on “Process Definition”
On the process definition screen is another right hand column. Click on “Java Virtual Machine”
Yes, finally we are on the correct screen, there is an end in sight here, I promise
On the virtual machine page, there is a large text field labeled “Classpath” What you need to do is enter the full path to the shared libraries folder
its odd and makes no sense to have to do it, but i have had to do that in the past to allow my code to see the properties files in a shared resource.
It is possible that your colleague has java librarys installed within his Tomcat instance itself.
Take a look in the Tomcat directory for some lib folders (I cant remember the exact location and I think it changes based on the version) but something like ${CATALINE_HOME}/common/lib
Verify that he doesnt have differen JAR files in his tomcat installation as yours.
From this question: Does Tomcat load the same library file into memory twice if they are in two web apps?
They are apparently stored here:
Tomcat 6 $CATALINA_HOME/lib
Tomcat 5 $CATALINA_HOME/common/lib
Is there a workaround or a solution to having to place the javax.comm.properties file and the win32com.dll file in their respective folders?
My program works fine when I have the files stored as below:
%JAVA_HOME%/jre/lib/ext/comm.jar
%JAVA_HOME%/bin/win32com.dll
%JAVA_HOME%/lib/javax.comm.properties
This worked well until IT changed the permissions on our computers so that we can no longer write to these folders. I'd like to be able to install the Java program I wrote that uses the serial port once without needing to re-install it every time IT decides to update our JVMs. Does anyone know of a way to do this?
It's always a good practice to decouple the execution of your application from the configuration of the machine it is running on. In your case the first task will be identifying where you want to store the extra libraries and configuration files that are needed (its probably best to bundle them with your application). Once that is done, then you can configure your application to find them at launch:
Assuming the following directory tree:
myapp
|
--lib (archives and shared libraries stored here)
|
--resources (configuration files go here)
You could do:
java -Xbootclasspath/a:myapp/lib/comm.jar -cp "myapp/lib/*:myapp/resources" -Djava.library.path="myapp/lib"
Your JAR and DLL files would go into the lib sub-folder, and the property file would go into the resources subfolder.