heroku-logo

(Italiano) Heroku: un servizio Cloud di Platform as a Service multilinguaggio

Leggi tutto »

Condividi:
1 Stella2 Stelle3 Stelle4 Stelle5 Stelle (2 voti, media: 5.00 di 5)
Loading ... Loading ...
paas

(Italiano) Panoramica sui servizi di Platform as a Service

Leggi tutto »

Condividi:
1 Stella2 Stelle3 Stelle4 Stelle5 Stelle (3 voti, media: 5.00 di 5)
Loading ... Loading ...
google-Maps

(Italiano) Google Maps Api: otteniamo la API key per poter utilizzare le mappe sul nostro sito web

Leggi tutto »

Condividi:
1 Stella2 Stelle3 Stelle4 Stelle5 Stelle (2 voti, media: 5.00 di 5)
Loading ... Loading ...
logo-mysql-110x57

(Italiano) Come reimpostare la password di root di MySQL Server

Condividi:
1 Stella2 Stelle3 Stelle4 Stelle5 Stelle (2 voti, media: 5.00 di 5)
Loading ... Loading ...
Google_WindowBuilder_Pro_Logo_200-5b92158e1f026768

(Italiano) Creare interfacce grafiche Java con Google WindowBuilder Pro

Leggi tutto »

Condividi:
1 Stella2 Stelle3 Stelle4 Stelle5 Stelle (4 voti, media: 5.00 di 5)
Loading ... Loading ...
db2 logo

(Italiano) Installazione e configurazione del database IBM DB2

Condividi:
1 Stella2 Stelle3 Stelle4 Stelle5 Stelle (1 voti, media: 5.00 di 5)
Loading ... Loading ...
Come configurare l'Heap Size di un'applicazione Java

How to size a Java application Heap Space

In this article we will see how to configure and size the heap of a Java application running on a Java Virtual Machine.

The Java Virtual Machine, or JVM, is the virtual machine that executes programs written in bytecode, according to this simple scheme:

Java code: compilation: bytecode: VM -> real execution of the program

The bytecode is generally produced from the compilation of sources written in Java, although it is possible to produce starting bytecode from other languages, in fact, there are already implementations, partial or complete, of compilers that work in this direction.

To understand the functionality of the heap, we must first understand how memory is managed by the JVM, which is part of this heap. Leggi tutto »

Condividi:
1 Stella2 Stelle3 Stelle4 Stelle5 Stelle (2 voti, media: 4.50 di 5)
Loading ... Loading ...
Apache Tomcat 7

Installing and configuring Apache Tomcat 7

In the past, Tomcat was run in the context of the Jakarta Project, and was therefore identified as Jakarta Tomcat, currently is the subject of an independent project.

Tomcat is released under the Apache license, and is written entirely in Java, so it can run on any platform on which a JVM is installed.

The major features provided in Release 7 are:

  • support of Servlet 3.0 specification;
  • Annotation support;
  • support of the JSP 2.2 specification;
  • support of 2.2 EL (Expression Language) specification;
  • greater ease in integrating Tomcat in other Application Server such as JBoss;
  • Memory leak detection and prevention;
  • use of nonces to prevent attacks like cross-site request forgery (CSRF);
  • Asynchronous logging.

We can download the package containing the A.S. (short for Application Server) by going to http://tomcat.apache.org/download-70.cgi, here we can choose between various formats .zip or .tar.gz distribution, the 32 or 64 bits and in case of installation of Windows, we can download the zip file containing the script to activate the corrisponding Windows service.
Once installed Tomcat (for versions .zip and .tar.gz just unzip the package into any directory), we can launch it by going into the /bin directory and lunching  the startup script (.bat for Windows and .sh for Linux).

At this point at http://localhost:8080/  we get the Tomcat welcome page:

tomcat7 300x172 Installing and configuring Apache Tomcat 7

In order to deploy a Java application in .war packet, there are two alternatives:

  • just place the .war file  in the /webapps directory of Tomcat installation, it will be automatically unzipped into a folder with the same file name of .war and also the context root will have the same name of the .war file;
  • access to the Tomcat Web Application Manager at http://localhost:8080/manager/html/ (you must activate the role managers, see below), and deploy the application from the Deploy panel.

By default, the status page and the Tomcat Web Application Manager (web console) are disabled, to enable them we must act on the tomcat-users.xml file located under the /conf directory and adding a user with manager role.

In Tomcat 6 we must add a user with manager role, that role now in Tomcat 7 was divided into 4 other roles. This allows an assignment more detailed of roles and of their functionality to end users, such as before a manager user could access both to the status page, which lets you see informations about the Server and about JVM installed, and to the list of applications and web console pages with which we can deploy the applications, now those roles are distinct. The four roles available are:

  • manager-gui: the user with this role can access the page status (http://localhost:8080/manager/status) and the web console (http://localhost:8080/manager/html);
  • manager-script: the user can access to all the features provided by the role manager-gui but in text mode instead of graphics, for example, to deploy a war that is in a local directory (on Windows) just type in the bar browser address http://localhost:8080/manager/text/deploy?path=/test&war=file:C:/pathdelfile/file.war, if the operation is successful we get the following message: OK – Deployed application at context path /test and we find the war file unzipped folder webapps Tomcat root context with the same test, for Linux the syntax is the same naming just delete C:;
  • jmx-managers: the user can access to the jmxproxy page (http://localhost:8080/manager/jmxproxy) where we can obtain information regarding the properties of Tomcat; for example we want to know what are the active Application Server Thread Pool, they can get thi by using this query: http://localhost:8080/manager/jmxproxy/?qry = *: type = ThreadPool, name = *,  instead to know wich Servlet are running we use the following command: http://localhost:8080/manager/jmxproxy /? qry = *: j2eeType = Servlet, *;
  • manager-status: the user with this role can only access the status page (http://localhost:8080/manager/status).

The XML syntax for the assignment of a role to a user is as follows:

<user username="username" password="password" roles="ruolo1, ruolo2"/>

so we can add more of a role separating them with a comma.
The tomcat-users.xml file will be of the form:

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<user username="admin" password="admin" roles="manager-gui,manager-jmx"/>
<user username="user" password="user" roles="manager-status"/>
</tomcat-users>

we therefore added two users with two different roles always within the "family" manager.
To change the port, on which Tomcat responds, we must edit the server.xml file  located under/conf directory and find the definition of Connector with HTTP protocol:

<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

at this point just change the number reported in port (8080 by default) in the port number you want. Save the file and reboot to make changes tane effect.
Now let's see how we can change the folder where we can deploy .war applications and where the A.S. runs the jsp: to do that we must act on the file server.xml of  Tomcat, where is the directive:

<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">

just change it  from webapps (the default folder name) to C ://webapps//pathname//foldername (in Windows you have to specify the double forward slash for each directory level):

<Host name="localhost" appBase="C://pathname//foldername"
unpackWARs="true" autoDeploy="true">

the unpackWARs = true option means that each .war file that we put in this directory will be unpacked and the autodeploy = true will cause a .war to deploy automatically when just insert it into the directory.

Condividi:
1 Stella2 Stelle3 Stelle4 Stelle5 Stelle (5 voti, media: 5.00 di 5)
Loading ... Loading ...

How to know which Linux distribution you are using

In this post we get to know the Linux distribution we are using currently.

The first command is that we can try:

dmesg | head -1

which gives us an output like this:

Linux version 2.6.18-194.32.1.el5 (mockbuild@builder10.centos.org)
(gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) # 1 SMP Wed Jan 5 17:52:25 EST2011

This line shows the kernel version (2.6.18) of the internal compiler (gcc) and version ofoperating system, which is not ”perfectly” true, as the system in use was a CentOS distribution (which is a Red Hat Open Source).

Leggi tutto »

Condividi:
1 Stella2 Stelle3 Stelle4 Stelle5 Stelle (2 voti, media: 5.00 di 5)
Loading ... Loading ...
PrimeFaces: una suite di componenti Open Source per Java Server Faces

PrimeFaces: an Open Source component suite for Java Server Faces

Leggi tutto »

Condividi:
1 Stella2 Stelle3 Stelle4 Stelle5 Stelle (2 voti, media: 5.00 di 5)
Loading ... Loading ...