Thursday, 7 April 2016

Spring logging

error :

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component

include the common-logging dependency.

Commons Logging is the logging framework that Spring uses to log



Jersey :
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.

In the service class provide the root path. if root is not provide or we have not annoted class with @Path.

ex :

@Service
@Path("/test")     // provide the root path
public class voice {

@Path("/hello")
public class HelloWorldService {

@GET
@Path("/{param}")
public Response getMsg(@PathParam("param") String msg) {

String output = "Jersey say : " + msg;

return Response.status(200).entity(output).build();

}

}

}
Spring

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

1) configure the required spring dependency to pom.xml

or

2) configure the spring  maven dependency library to java build path.

ex :  go to properties->deployment assembly->add ->java build path 
Skipping Tests in maven

If you want to skip test of project enable the surefire plugin in pom.xml

configuration :

type : false - enables the test suite to run.
          true  - enables to skip the test.
command : mvn install -Dmaven.test.skip=true

pom.xml configuration :

<project>
  [...]
  <properties>
    <skipTests>true</skipTests>
  </properties>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.12.4</version>
        <configuration>
          <skipTests>${skipTests}</skipTests>
        </configuration>
      </plugin>
    </plugins>
  </build>
  [...]
</project>
Ref : maven
Spring jersey :

1) Download the blank spring jersey from maven archetype catalog.

url :  spring boot jersey blank

mvn command for  windows :

ex : 
mvn archetype:generate^
 -DarchetypeGroupId=am.ik.archetype^
 -DarchetypeArtifactId=spring-boot-jersey-blank-archetype^
 -DarchetypeVersion=1.0.2







REF : Spring jersey


Tuesday, 5 April 2016

Tuesday, 29 March 2016

First node.js application

Go to URL : node.js download the software.

On window click on node.js exe to start.

output : >

Basic operation :

> var x
undefined
. define the variable and initialise the value

x= 1000
> x
output : 1000

and var y, and initialise y=09 and print variable y.

Now perform the basic operation.

> x+y
output :  1009

Now creating the application

step 1: 

create the server.js file.

a. define the module "http" for making the request
ex : var http = require("http");
b. call the server instance using http and will listen to port(8888), bind the port the server
ex:
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(8888);
c. In the above function pass the request and response parameter.
    function(request, response) {
     ...
    }
d. On making a request. it will call the request
ex : http://localhost:8888/
e. For Response bind the content-type and status code and content to display
ex : response.writeHead(200, {"Content-Type": "text/plain"});
       response.write("Hello World");

step 2 :

a. go to command prompt and go the node.exe file and open it
ex : node server.js
output : Hello World

step 3:

Go to browser and make request to nodejs server
a. http://localhost:8888/
b. output :
Hello world