Deprecated: Assigning the return value of new by reference is deprecated in /home/mangar.com.br/blogv3/wp-settings.php on line 399

Deprecated: Assigning the return value of new by reference is deprecated in /home/mangar.com.br/blogv3/wp-settings.php on line 414

Deprecated: Assigning the return value of new by reference is deprecated in /home/mangar.com.br/blogv3/wp-settings.php on line 421

Deprecated: Assigning the return value of new by reference is deprecated in /home/mangar.com.br/blogv3/wp-settings.php on line 456

Strict Standards: Declaration of Walker_Page::start_lvl() should be compatible with Walker::start_lvl(&$output) in /home/mangar.com.br/blogv3/wp-includes/classes.php on line 576

Strict Standards: Declaration of Walker_Page::end_lvl() should be compatible with Walker::end_lvl(&$output) in /home/mangar.com.br/blogv3/wp-includes/classes.php on line 576

Strict Standards: Declaration of Walker_Page::start_el() should be compatible with Walker::start_el(&$output) in /home/mangar.com.br/blogv3/wp-includes/classes.php on line 576

Strict Standards: Declaration of Walker_Page::end_el() should be compatible with Walker::end_el(&$output) in /home/mangar.com.br/blogv3/wp-includes/classes.php on line 576

Strict Standards: Declaration of Walker_PageDropdown::start_el() should be compatible with Walker::start_el(&$output) in /home/mangar.com.br/blogv3/wp-includes/classes.php on line 593

Strict Standards: Declaration of Walker_Category::start_lvl() should be compatible with Walker::start_lvl(&$output) in /home/mangar.com.br/blogv3/wp-includes/classes.php on line 687

Strict Standards: Declaration of Walker_Category::end_lvl() should be compatible with Walker::end_lvl(&$output) in /home/mangar.com.br/blogv3/wp-includes/classes.php on line 687

Strict Standards: Declaration of Walker_Category::start_el() should be compatible with Walker::start_el(&$output) in /home/mangar.com.br/blogv3/wp-includes/classes.php on line 687

Strict Standards: Declaration of Walker_Category::end_el() should be compatible with Walker::end_el(&$output) in /home/mangar.com.br/blogv3/wp-includes/classes.php on line 687

Strict Standards: Declaration of Walker_CategoryDropdown::start_el() should be compatible with Walker::start_el(&$output) in /home/mangar.com.br/blogv3/wp-includes/classes.php on line 710

Strict Standards: Redefining already defined constructor for class wpdb in /home/mangar.com.br/blogv3/wp-includes/wp-db.php on line 58

Deprecated: Assigning the return value of new by reference is deprecated in /home/mangar.com.br/blogv3/wp-includes/cache.php on line 99

Strict Standards: Redefining already defined constructor for class WP_Object_Cache in /home/mangar.com.br/blogv3/wp-includes/cache.php on line 404

Deprecated: Assigning the return value of new by reference is deprecated in /home/mangar.com.br/blogv3/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/mangar.com.br/blogv3/wp-includes/theme.php on line 576

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method Add_to_Any_Subscribe_Widget::init() should not be called statically in /home/mangar.com.br/blogv3/wp-includes/plugin.php on line 311

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method GoogleSitemapGeneratorLoader::Enable() should not be called statically in /home/mangar.com.br/blogv3/wp-includes/plugin.php on line 311

Deprecated: Function eregi() is deprecated in /home/mangar.com.br/blogv3/wp-content/plugins/wp-statpress/statpress.php on line 1139

Deprecated: Function eregi() is deprecated in /home/mangar.com.br/blogv3/wp-content/plugins/wp-statpress/statpress.php on line 1140

Deprecated: Function eregi() is deprecated in /home/mangar.com.br/blogv3/wp-content/plugins/wp-statpress/statpress.php on line 1141

Deprecated: Function eregi() is deprecated in /home/mangar.com.br/blogv3/wp-content/plugins/wp-statpress/statpress.php on line 1142

Deprecated: Function ereg() is deprecated in /home/mangar.com.br/blogv3/wp-content/plugins/wp-statpress/statpress.php on line 979
Tomcat at Marcio Garcia

Marcio Garcia

Software Empowerment²

Archive for the ‘Tomcat’ tag

Configurar Datasource no Tomcat 6

with 2 comments

Edite o arquivo server.xml, e procure pelo context da sua aplicação, caso não exista, esta é uma boa hora para criar.
    
    <Context docBase="ProjetoWEB1" path="/projetoweb1"
        reloadable="true"
        source="org.eclipse.jst.jee.server:ProjetoWEB1">
 
        <Resource name="jdbc/ProjetoWEB01" auth="Container"
            type="javax.sql.DataSource" maxActive="100" maxIdle="30"
            maxWait="10000" username="tomcatjpauser" password="tomcatjpauser"
            driverClassName="com.mysql.jdbc.Driver"
            url="jdbc:mysql://localhost:3306/tomcatjpa?autoReconnect=true" />
 
    </Context>
    
O driver de conexão do MySQL pode ser obtido no site do produto. (http://dev.mysql.com/downloads/connector/j/5.1.html)
Após extraído, este deve ser colocado em: %TOMCAT%/lib

Algumas informações a respeito da configuração:

Context (server.xml)

path: url que servira de acesso no browser
source: diretorio root da aplicacao

Resource (serverl.xml)

Configuração do DataSource, este no caso está configurado para acessar um banco de dados no MySQL.

Edite o arquivo web.xml da sua aplicação e inclua no final deste, antes do  uma referencia para o DataSource recen configurado:
    
    <resource-ref>
        <description>DB Connection</description>
        <res-ref-name>jdbc/ProjetoWEB01</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

Testando


Se ainda não tiver, baixe as Taglibs (http://jakarta.apache.org/site/downloads/downloads_taglibs-standard.cgi) copie os arquivos: jstl.jar e standart.jar para o diretório WEB-INF/lib de sua aplicação.

No banco de dados recem criado cria uma tabela chamada com o seguinte comando:

CREATE TABLE testdata (
   id int(11) NOT NULL AUTO_INCREMENT,
   foo varchar(25) DEFAULT NULL, 
   bar int(11) DEFAULT NULL,
   PRIMARY KEY (id)
)

Insira alguns registros apenas para fins de teste.

Crie um jsp com o seguinte conteúdo na home de sua aplicação:

<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 
<sql:query var="rs" dataSource="jdbc/ProjetoWEB01">
select id, foo, bar from testdata
</sql:query>
 
<html>
  <head>
    <title>DB Test</title>
  </head>
  <body>
 
  <h2>Results</h2>
 
<c:forEach var="row" items="${rs.rows}">
    Foo ${row.foo}<br/>
    Bar ${row.bar}<br/>
</c:forEach>
 
  </body>
</html>


Inicie o Tomcat e acesse a página criada.

A página deverá mostrar todos os registros que constam na tabela.

Written by Marcio

September 14th, 2008 at 5:18 pm

Posted in Tomcat

Tagged with

Tomcat + Ubuntu antes de iniciar….

without comments

Após baixar o Tomcat e descompacta-lo pode ocorrer o seguinte erro quando tentar inicia-lo atraves do comando startup.sh:
The BASEDIR environment variable is not defined correctly

Vá para o diretorio bin do tomcat e de permissao 777 ou +x para todos os arquivos .sh:
sudo chmod 777 *.sh

Written by Marcio

September 14th, 2008 at 12:23 pm

Posted in Tomcat, Ubuntu

Tagged with ,

Tomcat Embedded

without comments

No último dia eu estava desenvolvendo uma aplicação de missão critica com alguns requisitos bem próprios desse tipo de applicativo:

  • - Não pode parar nunca, nem para alteraçoes em parametros;

  • - Precisa reportar status constantemente;
Os requisitos não foram apenas esses mas todos os demias, são resolvidos desenvolvendo um software descente.

Ambos os requisitos mais “cabeludos” achei uma solução:

  • - Todos os parametros (ou a grande maioria) nao poderiam ser cacheados

  • - Aplicação web que servisse de console para a aplicação.
O primeiro foi fácil, criei uma classe que obtem os valores dos arquivos de configuração ou da base de dados, na verdade ele faz uma checagem com o timestamp, se foi alterado, é porque algo no arquivo foi alteraro, portanto o parametro deve ser expirado e obtido diretamente do arquivo.

O Segundo não foi tão fácil, mas foi muito legal, nas proximas linhas, vou descrever como colocar um servidor Tomcat junto com sua applicação, da mesma maneira que se faz com o Derby DB ou o HBSQLDB.

Read the rest of this entry »

Written by Marcio

July 5th, 2007 at 2:39 am

Posted in Java, Tomcat

Tagged with