Restlet : Requested resource not found - restlet

I am new to rest, so I followed this tutorial exactly the way its mentioned here:
However, I get a requested resource not found error when I hit the URI mentioned there, that is,
http://localhost:8080/RestletDemo/service/helloWorld
My build was successful.
This is the first time I am posting a question, my apologies for any ambiguity. Do let me know if you need more information.

It's difficult to figure out your problem like that. I have a look at your link and the problem of the provided code is that there are a lot of plumbing. Things could be much more simpler leveraging for example bean converters (Jackson one for example).
However, I didn't see anything strange in this code. Perhaps it's a configuration problem within your servlet container. For example, when using Tomcat with WTP in Eclipse, I need to check the item "Publish module contexts to separate XML files" to make things work.
I just submitted a very simple Restlet project targetting servlet and without all these plumbing. I made it work under Eclipse with WTP 2 (Tomcat7). You can reach it here:
https://github.com/templth/restlet-stackoverflow/tree/master/restlet/test-restlet-servlet
Since it use Maven, to use it, you can simply :
mvn eclipse:eclipse and then import it into Eclipse. You can then create a server (WTP) and add the project
mvn package and deploy the corresponding war into a servlet container (Tomcat or something else)
Hope it helps you,
Thierry

Related

Beginner's Guide to Setup Xuggler__Help

I've found the "Beginner's Guide to Setup Xuggler" article from here. I was trying to follow the best chosen answer. While going through the steps, I got stuck # "Run ivy from command-line as follows:" I didn't had Ivy at first, so I headed to Ivy's download page, and downloaded from the Snapshot Build section of the site. Then, I tested with both jar files, but while running the command stated in the Beginner's Guide, I'm getting this message: "ivy configuration file not found: ivysettings.xml". So, what did I do wrong, need I follow the "Building from source" section from the site? If so, can you please give me a detailed description of how to do it, I'm kinda new in these things. Long story short, I need to know how o get a legit "ivy.jar" file as stated in the command line of the Guide.
Ok, so I've solved the problem my own way, kind of. So, I'm gonna share it here so that other fellows like me may profit from it. So, what I did was that I (obviously) downloaded Xuggler 5.4. Then, I downloaded its dependencies manually as listed here. Then, on my IDE, I just had to import Xuggler and all of its dependencies which I previously downloaded and BAM, it worked like a charm. So, if any of you are having problem finding those dependencies or have any queries concerning this "unofficial" method of mine, you can contact me via email. I'll gladly help. :)
I don't know from Xuggler, but... the error message said you're missing ivysettings.xml. The message is probably from ivy.jar, so you definitely have that. ivysettings.xml is a required Ivy config file that tells what repositories you want to pull jars from. There may be a default one in the Xuggler distro, but probably not. You need to look at the ivy documentation to get farther. Or, use Maven instead. While I'm not a fan of Maven, for this kind of situation it may be easier.

Confusion about maven-war-plugin and jetty-maven-plugin

I am trying to get the run-exploded goal of the jetty-maven-plugin to work correctly. I find the documentation somewhat lacking on what I need to do to set this up.
I believe I have a standard WAR-file setup. (The reason I wrote "believe" is that I find the maven-war-plugin documentation lacking as well.) When I build my webapp using maven package, I get the following in my target folder:
classes
maven-archiver
surefire-reports
test-classes
tmp
mywebapp-version
mywebapp-version.war
where mywebapp-version is the exploded war and mywebapp-version.war is the packaged one. So far so good (I think?).
Now, running mvn jetty:run-exploded, it seems the default deploy folder is target/tmp/webapp/mywebapp-version.war/. This folder exists, but contains no files except for a webapp-cache.xml. This seems wrong to me.
I also tried to actively set the webApp configuration element to ${project.build.directory}/mywebapp-version/, but run-exploded seems to ignore it (despite the documentation stating otherwise).
What am I doing wrong? It looks as if I am missing something simple since no one else appears to be running into the same problem.
Now, running mvn jetty:run-exploded, it seems the default deploy folder is target/tmp/webapp/mywebapp-version.war/. This folder exists, but contains no files except for a webapp-cache.xml. This seems wrong to me.
According to the documentation of the jetty:run-exploded mojo, the default value for the tmpDirectory is target/jetty-tmp.
I also tried to actively set the webApp configuration element to ${project.build.directory}/mywebapp-version/, but run-exploded seems to ignore it (despite the documentation stating otherwise).
The webApp defaults to ${project.build.directory}/${project.build.finalName} so I'm not sure your "active" configuration changed anything.
What am I doing wrong? It looks as if I am missing something simple since no one else appears to be running into the same problem.
Well, what is the problem actually? :) What are you expecting exactly (I'm suspecting a misunderstanding of what is supposed to happen).
By the way, I find the Maven Jetty Plugin Configuration Guide and the documentation of Jetty's mojos pretty decent.

How do I avoid having to manually tweak Import-Package headers with Maven bundle-plugin?

I'm happily using the Maven bundle-plugin to create OSGi manifest headers for my modules. However, when there are configuration files that pull in classes which aren't referenced directly in the code, the plugin can't tell which packages it's going to need.
One example is a bundle with domain models that constitute a Persistence Unit for JPA. The driver class is part of the PU configuration and either set in an XML file or at runtime when the EntityManager is instantiated. I have to manually add an Import-Package header for the driver class that I want to load, or I get CNF errors.
Another example is a Struts war, where the web.xml pulls in the Struts dispatcher that's otherwise not found anywhere in the code and has to be manually added to the headers.
How can I avoid this?
I tried adding the required packages as dependencies with a provided scope, but that didn't help.
In the plug-in section of the bnd configuration you can specify plug-ins to analyze these files and contribute to the import-package header. For spring it looks like this:
<_plugin>aQute.lib.spring.SpringComponent</_plugin>
I am not sure, what descriptors are supported on top of spring. Just take a look at the source (it's in the Apache Felix SVN) and see for yourself. In the worst case you have to write your own plug-in, but at least it is possible! Also peter kriens site about the bnd explains the usage and some internals.
Other then that I am not aware of any simple solution.

struts setup sample application on eclipse

I am new to strut/web programming and I thought I could learn a lot by reading a sample app. On google, I searched and found a sample app at
http://www.roseindia.net/struts/struts2/struts2tutorial.zip , the tutorial is really nice and it gives a sample login page.
However, I couldn't run this sample app. I tried posting on the roseindia.net site and got no help neither.
There is no error logged during the start of the server, but when I try and open one of the helloworld's link the following is outputted
I am getting this error
SEVERE: Could not find action or result There is no Action mapped for
action name HelloWorld. - [unknown location]
The folder structure of this thing on my eclipse is
/WebContent/WEB-INF/java/net/roseindia/Struts2HelloWorld.java
/WebContent/pages/HelloWorld.jsp
/WebContent/WEB-INF/struts.xml
while in strut.xml the sample had..
<action name="HelloWorld" class="net.roseindia.Struts2HelloWorld">
<result>/pages/HelloWorld.jsp</result>
</action>
I am suspecting something in the strut.xml is wrong? I am using eclipse J2EE and tomcat6, I have already tried posting on roseindia's site and got no help.
You will learn a lot by reading sample apps. If your sample doesn't work, perhaps your sample is wrong.
Perhaps you need the actual authoritative documentation. See How to setup a basic struts project using Eclipse. This is the as official as any Eclipse - Struts documentation can be.
Perhaps you need a better example. See the Struts Community Projects and Examples web site for numerous examples.
Did you name the file "strut.xml" or "struts.xml"? It should be the latter (although you could override it if you wanted). Also, in Struts 2 the struts.xml file has to be in the classpath, not at the root of WEB-INF. So, in your project, you should put in the "src" folder, so when it deploys it goes into WEB-INF/classes. You can verify it goes into the correct place by doing an "Export" of the web application to a WAR file and verifying it went into WEB-INF/classes.
I've just downloaded a copy of this tutorial, and deployed it to Tomcat 6 - and it works!
Perhaps they have fixed the bug since you last tried? Or perhaps there's something wrong with the way you have Eclipse configured.
Al I did was to unzip the tutorial; copy the directory into the Tomcat webapps directory; start Tomcat; navigate to the Tomcat manager page on my PC; and click the link to the struts2tutorial application.
Give it another try...
I had the same issue in Eclipse and solved it by changing the output folder of the source folder to:
WebContent/WEB-INF/classes

How to deploy a WAR onto an existing Tomcat 6 instance using Cargo?

I installed Tomcat using the Windows installer ages ago and it runs fine as a service on my development laptop. Now I'm mavenising my project and would like to use Cargo (or something similar) to deploy updated WARs onto the local Tomcat.
I can't find any fully worked examples of a POM file containing the right XML to do this and am struggling with the partial examples on the Cargo site.
Does anyone have a POM they can post or know of an example in the wild they can link to?
FWIW the error I get is this - though I've tried many different combinations of parameters:
Cannot create configuration. There's
no registered configuration for the
parameters (container [id =
[tomcat6x], type = [local]],
configuration type [existing]).
Actually there are no valid types
registered for this configuration.
Maybe you've made a mistake spelling
it?
I'm not even sure I know exactly what the error means by a "type" in the first place!
Update: I eventually found the m2eclipse WTP integration plugin, which frankly rocks!
Is there a reason to use just cargo?
You can try the maven tomcat plugin in order to deploy your wars to tomcat. See the instructions about configuration and deployment.