import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import clojure.lang.RT;
import com.vaadin.Application;
import com.vaadin.terminal.gwt.server.AbstractApplicationServlet;
public class Clojure4Vaadin extends AbstractApplicationServlet {
#Override
protected Class<? extends Application> getApplicationClass()throws ClassNotFoundException {
return Application.class;
}
.... Some code .....
}
How to write this in Clojure?
I'm trying to write the vaadin srvlet class in clojure:
http://dev.vaadin.com/wiki/Articles/ClojureScripting
I think what you're looking for is the following:
(def Clojure4Vaadin
(proxy [com.vaadin.terminal.gwt.server.AbstractApplicationServlet] []
(getApplicationClass [] com.vaadin.Application)))
Have a look at the documentation of proxy.
The code you have given above is used to serve a webapp written in clojure via the vaadin framework.
This code is meant to be run as Java Servlet as it is and the webapp logic would be in the clojure code (test.tlp), you would have to compile the servlet and package it with the clojure script in the webapp root directory.
Regards,
Shanmu
Related
I'm following this simple tutorial: https://www.mkyong.com/webservices/jax-ws/jax-ws-hello-world-example-document-style/?fbclid=IwAR0vxhYrj9MKy1Q28h6luFVJoSxDP4KWBOLEu_v_Ss4uQztmB-9JuYsS4RI and at step 3 it mentions that I should receive the error:
Wrapper class com.mkyong.ws.jaxws.GetHelloWorldAsString is not found.
Have you run APT to generate them?
However, I do not get such error(no error at all) and I'm worried that it is not working as expected.
My classes:
Interface:
package com.soap3sk.ws;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import javax.jws.soap.SOAPBinding.Use;
// Service Endpoint Interface
#WebService
#SOAPBinding(style= Style.DOCUMENT, use= Use.LITERAL) // optional
public interface NoteEndpoint {
//#WebMethod ArrayList<ToDoNote> getNotes();
#WebMethod String getHelloWorldAsString(String name);
}
Implementation:
package com.soap3sk.ws;
import javax.jws.WebService;
#WebService(endpointInterface = "com.soap3sk.ws.NoteEndpoint")
public class NoteEndpointImpl implements NoteEndpoint {
#Override
public String getHelloWorldAsString(String name) {
return "Hello World JAX-WS " + name;
}
}
Publisher:
package com.soap3sk.endpoint;
import javax.xml.ws.Endpoint;
import com.soap3sk.ws.NoteEndpointImpl;
public class NoteEndpointPublisher {
public static void main (String[] args) {
Endpoint.publish("http://localhost:5000/ws/hello", new NoteEndpointImpl());
}
}
Project structure: https://imagizer.imageshack.com/img924/3514/BAuOcl.png
What I also noticed that those 2 .class files(asString and Response that are mentioned in the guide) are not generated anywhere as well. I'm using Eclipse and created a maven project with the quickstart archetype. Runnning it as a standard java application.
I can access the wsdl file going here: http://localhost:5000/ws/hello?wsdl and the I can see getHelloWorldAsString and getHelloWorldAsStringResponse there, but they are nowhere to be seen in my project and no error is thrown that they could not be found as mentioned in the guide that it should.
I also tried downloading the sample project and deleting the .java files that should be required, but it is stil the same(no error, not asking to create those classes).
I would be very grateful if someone could help. Thank you.
EDIT
I found a similiar question here: Java web service not giving error message Could someone explain his answer? Is the creation of those two classes not necessary?
you're trying to replicate a situation reported almost 10 years ago. Don't you want to try a newer tutorial like the following:
https://www.baeldung.com/jax-ws
https://spring.io/guides/gs/producing-web-service/
The below code has no compilation error:-
import java.*;
class Test{
public static void main(String[] args){
}
}
My question is does the package named java only includes sub-packages or it also includes any class/classes. If yes then which class(s). If no then why we are able to import it.
There are no class directly under java. All the JDK's classes are under subpackages.
Having an empty package (or a package with no classeses in it) is perfectly legal in Java. You can import all the classes in it (which is no classes) with the * syntax. This isn't wrong - it's just pointless.
I am using jython interpreter programmatically (PythonInterpreter) in my java application, and I'd like to add a specific class, eg. MyJythonLib as a Jython import module so that my Jython script could have something like:
import MyJythonLib
a = MyJythonLib.getStuff()
where MyJythonLib.java is
public class MyJythonLib
{
private Object stuff;
public Object getStuff()
{
return stuff;
}
}
How do I set this class to be a module for my Jython interpreter?
Ensure MyJythonLib is in your classpath.
import MyJythonLib with reference to its fully qualified name.
For example:
import com.mycompany.MyJythonLib
Or:
from com.mycompany import MyJythonLib
Or:
import com.mycompany.MyJythonLib as MyJythonLib
Here's the code for the source file:
package moa4;
public class Book {
....
}
And for the destination file:
import moa4.Book;
public class Library {
...
}
The source and the destination are both saved in the same directory with the address:
C:\Users\\java\M\moa4
I'm getting the following error: package moa4 does not exist
You asked Library to import a package moa4.Book but you defined no such package. Instead, you defined a type Book inside package moa4, and that is not consistent with your import directive.
You could either import the package, or make that an import static of the class, but since Book and Library are both in the same package you don't need the import directive at all.
As mentioned, C:/Users/java/M needs to be in your classpath ("-cp" option).
I wrote an HttpServlet and I named it "Stick" and then defined a Class named "John" in it.
In addition, I wrote another HttpServlet and named it "StickDetails".
Both of the Servlets are in the same package.
I want StickDetails servlet to function as a Main function (I want to use the "Stick" class inside it).
The problem starts when I try to write the command in StickDetails "John j = new John;"
but john isen't recognized! (""String cannot resolved to a type"")
what did I do wrong here?
Here you see StickDetails servlet:
package wood;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class StickDetails extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException,ServletException {
Stick a; // Stick is not recognized "String cannot resolved to a type"
}
}
I am using Eclipse IDE for java Developers
You Need To define a new class John, don't put it Stick Servlet.
In your Stick Servlet you can create instance of John Class(if required) and after your logic, set attributes which are required in StickDetails Servlet and then use RequestDispatcher in Stick Servlet to forward request to StickDetails.