I'm building a project on java, using jersey.
In program I need to connect to database MySql. I have download driver (*.jar file), and have put it to dir WEB-INF/lib (to other jersey libs), also I have added it in build path. If i'm creating war file and uploading it to tomcat server, than everything is ok. But if i'm trying to run it from eclipse with "Run On server", application can't find that driver. If i'm creating a small class with main method for testing that driver, and running that class as Application everything is ok.
So where I should put that lib, so my application can see it when I'm running it with eclipse.
PS Also can you recommend me some article about how best to structure project with jersey. Because I don't what to do. when I have some big peace of page written on html to do. Should I copy its content to java file and return it, or should I upload that file and read it in my class or maybe exist some other solutions?
Use Maven to handle dependencies. For servlet/HTML mapping use a MVC framework such as Spring or Struts.
Related
I'm using Spring Boot to deploy a webbased app (services on the backend, SPA app for the front end).
I'm not using Eclipse to edit my html-related files.
If I put those files under "resources", when using Eclipse to debug the app, any changes (to the html-related files) made using the other editor is not picked up by the "embedded" tomcat, unless I refresh the file in Eclipse too.
Everything works great if I put the html-related files in webapp/: I don't have to refresh the files in Eclipse; but then the files are not picked up by the jar maven build (because spring boot jar is not supposed to pick them by design...)
How do you usually work with html-resources?
I don't want to use Eclipse to edit my html-related files, and I don't want to use nodejs/other proxy-style server tool (I have a capable webserver called "tomcat", I don't see the need to have yet another tool to install/configure/update etc)
I am coding a website using java servlets and am using eclipse and tomcat. When I test it using localhost, it works fine. But when I am deploying it on my actual website, the directory structure is messed up and the files are not called properly.
My eclipse directory structure on localhost is
Project Name
.src/packageName/java files
.WebContent/HTML files.
When I make a call from the html files, I use the relative location and tomcat automatically knows to look in the src/packageName folder. For example, from the /WebContent/login.html page makes a onClick call as follows,
. This will automatically trigger the java file in /src/packageName/welcome
When I am deploying it in my actual website, the WebContent/login.html is throwing an error WebContent/welcome file is not found. How do I tell my website to search in /src/packageName folder?
Hmm...have you been sure to package the application as a war for deployment.
Hello I have a set of web services made in JAVA that are made using a Dynamic Web Project in Eclipse.
When i run an instance of Tomcat 6 in Eclipse and deploy the project on the server it works just fine, I am able to find the wsdl File and access it from a php script.
But when I export the Dynamic Web Proyect as a WAR file and deploy it on the webapps file inside the real Tomcat server, and start the server, I have no idea how to find the wsdl file or how to access it from my php scripts, its just not working.
Is there any thing i have to do to get this to work?
You should try to re-download Tomcat.
If you generate dynamic wsdl then . you can find it at URL something like
http://example.com/context/demo.wsdl
It will be easy to answer your questing if you post web.xml and other related xml config file.
I come from an Asp.Net development background and am very comfortable there. I was asked to support an existing Java Web Application w/ struts and am able to figure most of it out with my Asp.Net knowledge and my android development experience. However, I'm having a really simple but stupid problem.
All i have is the website as it exists on the server, no source project to work from. The folder on the server contains both .java and .class files, but the folder doesn't just import into netbeans as a recognized project.
What's the easiest way to get the site imported into some sort of IDE (I can work w/ eclipse too if netbeans isn't recommended), and get it to compile so I can deploy some updates.
It will not be easy to answer fully to your question here. But we should be able to achieve that by steps :)
Here i will speak for eclipse. But it is only because i'm not familiar with netbeans.
First of all create a clean "dynamic web project" under eclipse (using a J2EE enabled eclipse http://www.eclipse.org/downloads/).
Then :
copy your sources files in "Java Resources"
copy the rest of your application (without the class files) in WebContent
In order to test your application localy you will need a local server. Tomcat can be integrated easily in eclipse.
Usually you shouldn't have to (re)construct a project from a deployed web-app; the project should have been kept in version control. Source code isn't usually deployed to the server, either, but if it's been done in this case, you're in luck.
I would just make a new web project in NetBeans and manually move the .java files into it, along with the other resources (except for the .class files).
If you can use eclipse, and the source files are already in the war file as you say. You can import the war file directly into eclipse as project.
file -> import -> war file or existing project into workspce or filesystem (Several other options exists)
I earlier got to create a simple RESTful webservice on my localhost using Eclipse IDE, Tomcat, and JAX-RS libraries.
I am now trying to move the same on to a different unix server which has Tomcat installed. I am not knowing how to get started as in what is equivalent to creating a "Dynamic Web Project" that I do in Eclipse. Do I need to just create a directory myself with all the sub-directories as created by Eclipse? Should this directory be placed in webapps folder in Tomcat container. Should META-INF and WEB-INF also be created by myself?
Where should I put my Java classes?
Can somebody please clarify this or direct me to any documentation about the same.
You need to package your application in a WAR file.
The Sun Java EE 6 Tutorial has a chapter deciated to packaging.
It's pretty easy to export a web application as a war in Eclipse.
Dynamic Web Project (right click) => Export => Web =>war file =>war export dialog
Creation of web application archive - WAR is the solution for your problem,
but take care about all libraries that you need there.
You can easily extract (unzip) WAR file content
and check your project structure and libraries needed
and they will be in WAR's WEB-INF/lib.
Make sure that both Tomcats are set same way,
make sure your code is all OS friendly (users, file paths, permissions)
Always write some test simple code that will run up on app start,
and check all dependencies and libs, system clock, outside world network communication, so you can trace it in web app console or logger easily.
regards