Deploy web application on Tomcat - java

I created a simple web application in eclipse which connect to sql server. I downloaded the sql driver and added it to build path like this:
Build Path->Configure Build Path->Add External JARs.
When I run my application on Tomcat I get exception: ClassNotFoundException. I think that I know what it reason is (the folder WEB-INF->lib of my application is empty). When I put jar file of driver in WEB-INF->lib - everything is good. How I can add jar file(sql driver) to folder WEB-INF->lib of my application using eclipse?

Putting the JDBC driver JAR in [Tomcat-install-root]/lib will solve your problem, and you can do that outside of Eclipse.

Related

WildFly deploy fails

I have been trying to work with WildFly, however I'm facing some odd issues, for example I can deploy from a *.war withouth any problem with connection to the database, but an unmanaged deployment is a headache, never starts, same when trying to do this throught Eclipse.
I'm doing a normal deploy for debugg using Eclipse, but anytime I'm getting this message:
WFLYEE0027: Could not load oracle.jdbc.driver.OracleDriver referenced in env-entry.
I have all the runtime configuration in Eclipse and also I did all the module configuration inside WildFly for standalone. I have added the *.jar to the proyect manually.
This is a maven project, any idea of how to solve this?
Okay, for this time I could solve the problem by adding the *.jar files this way:
So now WildFly can load the libraries from the lib folder

ClassNotFound for Mysql connectivity in JavaEE application

I've added mysql connector jar file, but class not found exception still arises.
*
Your error clearly says that the MySql connector jar is not placed in the correct folder. The correct folder is WEB-INF/lib. So place your jar in this folder.
You have your eclipse project referencing the mysql library. This allows the compiler, in eclipse, to find the classes when compiling. However, you do not have the library as part of your web app when you publish it to your tomcat server. You need to remove the library from the project, and copy the jar file into your app's WEB-INF/lib directory.
java.lang.classnotfoundexception com.mysql.jdbc.MySql issued by WebAppClassLoader. This tells that you need to include MySql connector jar in your web path under WEB-INF/lib directory.

Spring application Could not load JDBC driver class [oracle.jdbc.driver.OracleDriver]

Why application is not able to read the class from the build path? I did added ojdbc6.jar in the build path of the application.
Now when I kept this jar in the WEB-INF/lib directory, it worked fine.
Can someone please explain why it was not read from the project build path.
When you add it on the build path in your IDE , it is used for compiling the code (if there is a dependency on it).
Unless you package this and deploy on the server , the server has no reference to these files that were used for compilation. When you place it on WEB-INF/lib and package it , the jar file is also packaged in your .war file that is deployed and hence at runtime you will not get a Class missing or Driver missing error.

NoClassDefFoundError when deploying WebLogic application from Eclipse

I'm working with Maven and WebLogic. When building my application with Maven, I can successfully install it manually on my local Weblogic, using the Admin Console.
When trying to deploy this same application on the server using Eclipse IDE, I get a NoClassDefFoundError. (I tried both with "Publish as virtual application" and "Publish as an exploded archive" in the Oracle Weblogic Server tools in Eclipse).
The structure of my application is the following:
MyApp.ear contains:
- MyWar1.war
- MyWar2.war
- MyEjb.jar (ejb module, using maven-ejb-plugin)
- MyJar.jar (another project, as dependency)
And it's this MyJar.jar that seems to be not found in the classpath. I've checked that in the Eclipse settings, this project is include in the Java Build Path\Project, Java Build Path/Order and Export and in the Deployment Assembly for the MyEjb project.
I've also checked the folder build by Eclipse, eclipse-workspace\.metadata\.plugins\org.eclipse.core.resources\.projects\MyApp, where I can see the folder APP-INF\lib\MyJar.jar with the corresponding .class files. And when I try to manually manually install this folder, I got the same error (NoClassDefFoundError).
I'm using Weblogic 10.3.3, Maven 3.2.1, Eclipse 4.4.0 (20140612-0600) and Oracle WebLogic Server Tools 7.2.1.201407111426.
Any ideas how I can investigate this problem ?
Moving the dependencies from APP-INF/lib/ to lib/ folder seems to fix the problem, but I have no idea why.

How to deploy Java/Spring application on my own system in Apache tomcat server.?

Hello all master minds,
I have created a java spring application in eclipse with mysql db.
Now I can run this application using >Run on server in eclipse,but I want to know how to deploy this application on my own laptop(windows 7).
I have already configured server,by localhost://8080 I can see Apache tomcat is configured.
Give me simple steps so that i can just run that software using browser via its link like
http://localhost:8080/PMS
PMS is my project name.
Thanks in advance.
You can install tomcat-manager in order to deploy your war using a web interface: Tomcat 7 manager
Another option is to copy your war file into tomcat webapps folder. Your container will auto deploy your war: http://tomcat.apache.org/tomcat-7.0-doc/appdev/deployment.html#Deployment_With_Tomcat.
The easiest way, since you are using eclipse is to just export your project as war and then put that war (naming it PMS) in webapps directory in your tomcat.
Once started, Tomcat will deploy that war on http://localhost:8080/PMS
You have to do the following steps:
Right click on project>> Export (Export as WAR file).
or if you are using a maven project then you can give a maven build.
Copy that WAR file, (you will get that war file inside the project folder in your workspace) to the tomcat_Installed_Folder/ webapps
Inorder to deploy the app from outside eclipse,
goto tomcat_Installed_Folder/bin
and double click on startup.bat
then you could see a console.
For detailed logs of deployment, goto tomcat_Installed_Folder/logs
ALL THE BEST :)

Categories