Netbeans does not give me wadl file - java

I'm trying to deploy a RESTful application with Netbeans to a remote server (with domain name "agdata.se") by following this guide. Once I've built and deployed, then entering the url "http://agdata.se:8080/WebTest/test-resbeans.html" I get the following error message:
"Cannot access WADL: Please restart your RESTful application, and refresh this page."
When I look in the project folder and unzip the war file, there's no wadl to be found. It's like Netbeans never created one.
I created the project (let's call it project A) using dedicated folders. I choosed Java EE 6Web and JavaServer Faces as the framework. I didn't configure the framework so I didn't choose PrimeFaces or any other of the components.
I then made a "RESTFful web service from a database" by rightclicking the project node. I created the datasource, just like the guide said, since I use a MySQL-database and not a Derby.
I left "Generate Named Query Annotations for Persistent Fields" checked.
I didn't check "Use Jersey Specific Features".
Then, I created another Web Application, also with Faces as framework. Letäs call this project B.
I run "Test RESTful Web Services" and check "Web Test Client in Project". I then choose project B and I can deploy and build it without any errors. I then enter the REST-test url into Firefox and it says it cannot access the WADL file. Again, there is no such file in the project folder when I look into the war file. Just to be clear, this is a remote server I'm deploying to, not localhost. The server is Ubuntu 13, I'm on a Mac OSX.
Thankful for all the help I can get!

Related

How to deploy a Spring MVC Maven project from Eclipse to an existing Glassfish server

I've got a Spring MVC Maven project written in Eclipse that was verified as working with an Apache Tomcat 7 as the web container.
I am trying to transfer it to my "server" pc where I want to deploy it to the my existing glassfish (4.1) server as the web container.
I am having a very hard time finding a big enough partial answer to get the rest of the way.
I have tried to just export the .war file to the autodeploy folder which resulted in a "deployfailed" file.
I have tried to setup a "new server" using glassfish tools, but I realized that this is creating a new server and the existing server blocks the socket connection.
Eclipse doesn't see to have standard web commands like build, clean or deploy, but I would happily settle for advice on how to tell it to deploy to the existing glassfish server similar to how I was able to with tomcat at my training location.
Check this answer. Then follow the following steps.
Go to the project in the Project Explorer.
Select the web project.
Right click and select "Run As", you will see glashfish. Select it and click run.

How to upload a eclipse dynamic web project to a live server?

I have developed a dynamic web project using eclipse and i am having a domain name and a web hoster. all i want to do is to upload my eclipse project to my web hosting site. Currently i am using html 5 template on my website but i want to upload my own project on it. I have heard that we can do it by using war file but i am not sure how to do it as my html 5 template contains many html page like index.html and it is more in size as compare to war file which i have exported. Please tell me i am totally clueless about it
Your web host needs to support Java and some Servlet container. If they don't already have those two things installed, you'll need to install them yourself. Once that is done, in Eclipse, you will need to export your project in the form of a .war file and place it in the appropriate folder of your Servlet Container. For example, with Tomcat, you would place it in its /webapps directory. You then start your Servlet Container. Your web application will be up and running.
If your web project includes Java web technologies such as Servlets and JSP, you will need to
Build your war file first either with Ant, or Maven.
Then you can upload the war file to your web server using some type of deployment tool that is usually available on the hosting web server. For Apache Tomcat for example, you can use the Tomcat Manager tool to deploy your war file.

What happens behind the scenes of deploying a Spring MVC application to tomcat outside of eclipse?

I guess a drawback of using such an awesome IDE like eclipse is that you miss the point for what happens behind the scenes of an application. I'm a ruby developer so not a java veteran. So I've been coding a project in java and using the spring framework for IOC and MVC. Can someone explain to me what is going on when I select run on server in eclipse? Because eventually I will be deploying this masterpiece of an application to a Linux server. Here is my setup. I am using Spring MVC 3 and the maven plugin in eclipse. In the pom.xml file, I have stuff like latest spring release version, log4j, spring mvc, spring context etc.
I have been testing my application on localhost using the handy option of run on server in the eclipse IDE. The server configuration in eclipse is pointing to the tomcat directory location for where I have installed tomcat 7. Please demystify what happens behind the scenes and what I will need to do if I want to deploy this application on a production server. The more detail the better. Thanks a ton in advance.
Deploying a web application to Tomcat is as simple as this (assuming Tomcat is installed)
Bundle your application in a .war with the correct format.
Move the generated .war file to the /webapps directory of your Tomcat installation folder.
Run the /bin/startup.[sh|bat] script in the Tomcat installation folder.
Note that there are intermediate steps you can do to configure the deployment, like changing your context path. Go through the Tomcat documentation for details.
In step 3, Tomcat will extract the .war contents to a directory in the /webapps folder with the same name as your .war file. It will use this as the context path. The script itself launches a java process by putting the WEB-INF/[class|lib|...] onto the classpath along with some Tomcat libraries.
So Eclipse basically does all the steps above for you.
Ultimately you are deploying an web application that means you are deploying a war file to the server. Regardless of using frameworks like spring, struts anything.
SO a web application request starts from web.xml file. SO for spring mvc application, you are mapping all request coming from browser to DispatcherServlet and then this guy is responsible to manage whole life cycle of your application.
For more details of how MVC works please see
http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/mvc.html
So in order to deploy your application (a war) on server first of all you have to create a war from your source code. You can go to traditional approach to use java given utility like using jar from command prompt or you can use ANT, GRADLE, MAVEN and such build tool that creates war for you in automated way.
Spring is not doing anything extra for you. I believe you to research a bit more on how these tools works.
Once a war is ready for you, you can simply go to tomcat UI and there you will find options to deploy your war.
I hope it helps you.
All the majic happens in two places.
The first is your 'Servers' directory in the root of your Eclipse Package Explorer. These are your server configuration files that Eclipse will use (mostly) when it creates a new server instance.
The second is in the ./metadata/.plugins/org.eclipse.wst.server.core/ file system directory in your Eclipse workspace. This is where the tomcat application is actually deployed by eclipse.
The Tomcat Documentation is pretty good actually and helps explain how to do deployments. FYI, I do not know many people that use the Manager, from my experience most people deploy their applications by hand.

Windows Azure application in Java and JSF

I wrote web application using JSF, xhtml, CSS and Apache Tomcat in Eclipse and I want to start it on Windows Azure emulator. I installed "Windows Azure plugin for eclipse" (here is instruction).
When I choose option "Package for Windows Azure" and I want to run application on WA emulator everything is ok - I see information on console "BUILD SUCCESSFUL", server started etc. But when I type application url adress on web browser, it displays
HTTP status 404 The requested resource (/ChatAzure/) is not available.
How is this caused and how can I solve it?
sounds like your app might not be getting into Tomcat's webapps. One way to troubleshoot is AFTER you try to run it in the emulator, go into your Azure project's "deploy" folder, navigate the folder hierarchy until you get to the specific role folder (like WorkerRole1 if using default names) go inside approot, find the tomcat folder in there, and look into its webapps folder. You can see the effects of your deployment logic this way. If your app isn't inside webapps, there may be an app deployment problem.
(The actual directories may be different depending on how you've customized the deployment logic)

what are the steps in order to run java enterprise application

Sorry for this simple questions but i am too much confused with how to run java application. Whenever i ask some each one tells his own tools to proceed and i have learn that thing.
So provided i have simple basic eclipse with no plugin and i have downloaded the sample web application which uses spring , hibernate , mysql ,
The folder structure of app is
.setting
src--main,test
target
.classpath
.project
Now i want to run this using localhost in browser
what thing i need to do. i will tell from my knowledge and u guys can correct it
i don't want to use STS or install any plugin in eclipse.
I imported the project from eclipse
menu and i appeared on left window
As it uses spring do i have to add
the spring jar files in build path
of spring. or anything else
Same for hibernate jar files
Fior simple java app i used to
compile the class which contain the
void main function but i have no
idea which file to compile to run
this app
I added the mysql connector in build
path to connect with mysql in simple
java app. will same thing work here?
I knoow we need web server for that.
so if i want to install glass fish
server then how will i connect it to eclispe or that app. will tomcat be
ok than glass fish??? i know tthere
is eclispe ide with embedded glass
fish but i want integrate evrything
myself
IN browser i which url i need to use
to see that app
I don't know how did maven , appfuse fit in here. Can i run app without maven if yes then what does maven really do , i mean does it compile the java files or what. If i require maven then
Do i need to install it separately i
mean exe file or jar file
how to link with eclipse
I have read about building with
maven , what will ahppen after
building i mean what is the result
of building , will i see browser
after building or after building
there are some steps further. do
maven needs to link with web server
installed
sorry for basics questions but i am confused with all new trminology
Building a webapp is complicated. I will try and address your specific questions.
Utimately you don't need Maven or Appfuse, both can be very helpful.
Maven is a build tool. Maven and Eclipse do some similar tasks. Both can compile your code and manage a classpath. Maven handles a lot of things out of the box that Eclipse can't do by default. Maven can manage dependencies (i.e. download the spring jars for you) and create complex build processes.
If you are unfamiliar with Maven and creating a build file from scratch then it probably won't be much help. If you have a pom.xml (Maven build file) from somewhere else then Maven can be a big help. The result of Maven depends on how your build file is structured. The result is most often either a .war file (described below as step 5) or that your application is deployed directly to your web server (described below as step 6).
Appfuse is also not mandatory but can be useful. Appfuse will create a skeleton project for you. When it does this it will create a pom.xml (Maven build file) to automatically build your project. Appfuse by itself doesn't do anything other than help get projects started. Most people don't start building web apps from scratch anymore since getting the directory structure right and creating the build file can be a lot of work and it's easy to make mistakes. A tool similar to Appfuse is Spring Roo.
Tomcat, Glassfish, Jetty, and JBoss are web servers. They are also often called Servlet Containers which is just another name for a web server that hosts servlets in a certain fashion. Any of them will work for your project, they all have different learning curves. Integrating them into Eclipse may work for you, when I got started I found it was easier (although a little slower) to keep them separate.
In the JDK there is an interface named javax.servlet.Servlet. This is the interface that the entry class of your web application must implement. In particular the method service(ServletRequest req, ServletResponse res) is called every time there is a request for a URL. If you want your web application to respond to HTTP it may be simpler to extend the abstract class HttpServlet (which implements Servlet) instead. Most libraries (i.e. Spring web framework) have their own implementations of Servlet that are the entry point to the library.
I will now describe the basic process for building a web application. This is a complicated process and most people eventually automate it with Maven. I do not suggest trying to manually walk through the process yourself it can be very complicated but you can if you want. I am going to assume that you are placing all of your built files in a folder named $BUILD
Compile your source code. The compiled classes need to end up in a folder called $BUILD/WEB-INF/classes
Place all your jar files (external libraries) in a folder named $BUILD/WEB-INF/lib
Create a deployment descriptor, this is a file that tells your web server how to deploy your code. The most important thing in this file is a mapping from URLs to Java classes that implement Servlet. It should be named web.xml and put in $BUILD/WEB-INF
jar up the all this code with the root of the jar being at $BUILD. You could call this code application.jar
Rename the jar file extension to war. A war file is simply a jar file that has the required WEB-INF directory inside of it.
Deploy this war file to your web server (Tomcat/JBoss/Jetty/Glassfish/etc.), the process for doing this is different for each web server
That is the basics of web application deployment. Your web server will extract the war file and load all of the jars in the lib folder into the classpath. It will then take any URL requests it receives and send them to the appropriate Servlet implementations declared in your deployment descriptor.
As you can see this is not a simple process. This is the reason tools like Appfuse and Roo exist. They try and give you a starting point which does all of this basic stuff for you. If you are having trouble I would suggest trying again from scratch with Appfuse/Roo. As you start to get the hang of things I would also suggest learning more about Maven (or Ivy+Ant) to handle dependencies for you.
You should download the Java EE edition of Eclipse - it contains the code needed to work with enterprise applications.
You will also need an enterprise server (like JBoss or Glassfish) and the corresponding server adapter, which is a bit much for a beginner.
The easiest way to get started is to download Netbeans with Glassfish and use that instead - at least for now - as everything is configured correctly and it is very fast to get started! When you are more familiar with the way things work, you can switch back to Eclipse if you want to.

Categories