Search code examples
jbossjerseywildflyweb-deploymentdukescript

How do I deploy a Dukescript Jersey Based Server to a production enviroment?


I'm trying out Dukescript based on the "CRUD with JerseyFaces" in , and I realise the when the web module is built via , a file is generated.

How do you suggest I may deploy my web application to lets say the Wildfly Application server or JBoss AS 7.1?


Solution

  • There's a tutorial on the DukeScript Website, that does exactly what you want. I'm copying the relevant parts here (as I'm the author of the tutorial) and the link for reference: I’m using NetBeans 8.0.2 with the latest version of the DukeScript Plugin and WildFly 8.2.0 for this. I’m assuming you have already created a project using the CRUD Archetype.

    The purpose of our Jersey sample is to show how you can interact with a server via JSON messages. So the only purpose of the server module is to answer the requests from the client. For a more traditional setup you can simply create a more traditional web project, e.g. using the Maven Web Application project template.

    In the Parent Project, right-click “Modules” and select “Create New Module” from the Context Menu. In the wizard that pops up choose “Maven -> Web Application”. In the second step you can select a server. Choose Wildfly here. If it’s not in the drop down list, click add and point it to the Wildfly dir. Then confirm the settings and finish the Wizard.

    Now use “New -> Web Services -> Restful WebService from pattern” and create a Singleton Web Service. This is only needed to configure the project for Web Services. You can delete the class you just created after that. Now add the following class to your project:

    @javax.ws.rs.ApplicationPath("webresources")
    public class ApplicationConfig extends Application {
    
        @Override
        public Set<Class<?>> getClasses() {
            Set<Class<?>> resources = new java.util.HashSet<>();
            addRestResourceClasses(resources);
            return resources;
        }
    
        /**
         * Do not modify addRestResourceClasses() method.
         * It is automatically populated with
         * all resources defined in the project.
         * If required, comment out calling this method in getClasses().
         */
        private void addRestResourceClasses(Set<Class<?>> resources) {
            resources.add(fully.qualified.path.to.ContactsResource.class);
        }
    
    }
    

    Now copy the ContactsResource to the new project and delete the old server project. Make sure to add the project with „Shared Client Server Data Structures“ as a dependency, so you can again reuse the data model. If you’re using NetBeans you’ll now see the ContactsResource in the IDE under the „Restful Web Services Node“. That’s it, you can now start the server and point the client to this more traditional Web Application.

    https://dukescript.com/best/practices/2015/08/26/CRUD-Example-with-Wildfly.html