terça-feira, 25 de setembro de 2012

iReport/JasperReports 4.7.1 + Hibernate 4.7.1 java.lang.NoSuchFieldError: BOOLEAN


Solution (Testado)


Solution is very simple.
1) Download the whole (with source) jasper tar.gz file from JasperReports home site
2) Untar the file (let the location be called $JASPER_SOURCE)
3) vim $JASPER_SOURCE/src/net/sf/jasperreports/engine/query/JRHibernateQueryExecuter.java
4) Add the following line in the top import statements
import org.hibernate.type.StandardBasicTypes;
5) Now from line 71 onwards change all "Hibernate" to "StandardBasicTypes" (till the end of the static block, that is till 84th line)
6) Save and exit the editor
7) Copy the latest hibernate3.jar (3.6.x version) into "$JASPER_SOURCE/lib" location
8) Now do the following ant command from $JASPER_SOURCE location
ant jar
You will get the modified jar in lib/jasperreports-4.x.x.jar location. Use that jar for your project
--------------- OR ------------------- 
(Não testado)
Another solution is to use old hibernate3.jar file (version 3.0.x) with your project

segunda-feira, 17 de setembro de 2012

ORA-00918: coluna definida de maneira ambígua

Problema: nome da propriedade duplicado.


@DiscriminatorColumn(discriminatorType=DiscriminatorType.CHAR,length=1,name="TIPO_PROCESSO")
@SequenceGenerator(name="seq_abreprocesso", sequenceName="seq_abreprocesso", allocationSize=1)
public class AbreProcesso implements Serializable {

...

@Column(length=1,insertable=false,updatable=false)
protected String tipo_processo;

...
}

Solução: Deixar tudo em lowercase.


@DiscriminatorColumn(discriminatorType=DiscriminatorType.CHAR,length=1,name="tipo_processo")
@SequenceGenerator(name="seq_abreprocesso", sequenceName="seq_abreprocesso", allocationSize=1)
public class AbreProcesso implements Serializable {

...

@Column(length=1,insertable=false,updatable=false)
protected String tipo_processo;

...
}

segunda-feira, 3 de setembro de 2012

java.io.IOException: Acesso negado (Quartz)

Ao executar uma trigger agendada no Quartz, onde um arquivo TXT é criado e salvo na rede, ocorre o seguinte erro:


Informações: Illegal access: this web application instance has been stopped already.  Could not load org.quartz.core.JobRunShell.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1597)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
at org.quartz.impl.StdJobRunShellFactory.borrowJobRunShell(StdJobRunShellFactory.java:91)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:332)

Exception in thread "DefaultQuartzScheduler_QuartzSchedulerThread" java.lang.NoClassDefFoundError: org/quartz/core/JobRunShell
at org.quartz.impl.StdJobRunShellFactory.borrowJobRunShell(StdJobRunShellFactory.java:91)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:332)
Caused by: java.lang.ClassNotFoundException: org.quartz.core.JobRunShell
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
... 2 more
java.io.IOException: Acesso negado
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(Unknown Source)
at br.com.lpc.lpcsys.integracao.IntegracaoJbsCouro.GerarTxt(IntegracaoJbsCouro.java:46)
at br.com.lpc.lpcsys.quartz.JobIntegraBysoft.execute(JobIntegraBysoft.java:48)
at org.quartz.core.JobRunShell.run(JobRunShell.java:191)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:516)

Solucação:

Acesse a ferramenta (Configure TomCat) "C:\Program Files\Apache Software Foundation\Tomcat 7.0\bin\Tomcat7w.exe //ES//Tomcat7". Abra a guia (Log On) e informe uma conta com permissões suficientes no diretório onde o TXT será criado.

Ou no serviço: Painel de Controle > Ferramentas Administrativas > Serviços > Apache Tomcat.

quinta-feira, 30 de agosto de 2012

Oracle update com select



UPDATE PERMISSAO
SET
  PERMISSAO.SELECIONAR = 0,
  PERMISSAO.ALTERAR = 0,
  PERMISSAO.INCLUIR = 0,
  PERMISSAO.EXCLUIR = 0
WHERE
  PERMISSAO.TELA_ID = 99
AND
  (SELECT USUARIO.CLIENTE FROM USUARIO WHERE USUARIO.ID = PERMISSAO.USUARIO_ID) = 1;


segunda-feira, 27 de agosto de 2012

Substituir string por outra string no oracle.


Substituir string por outra string no oracle.

UPDATE USUARIO
  SET USUARIO.PATH_FOTO =  REPLACE( USUARIO.PATH_FOTO ,'/Sistema/','/sistema/')

Altera de /Sistema/ para /sistema/.

Ex: /Sistema/fotos/
Altera para: /sistema/fotos/

sexta-feira, 24 de agosto de 2012

java.lang.NullPointerException java.lang.Class.isAssignableFrom(Native Method)


Erro: Ao clicar no botão salvar.
java.lang.NullPointerException java.lang.Class.isAssignableFrom(Native Method)

Local do problema:
<h:commandButton
 actionListener="#{contatoMB.save(tabHawb)}"
 value="Salvar"/>

Solução:
<h:commandButton
 actionListener="#{contatoMB.save('tabHawb')}"
 value="Salvar"/>

segunda-feira, 20 de agosto de 2012

Tomcat 7 + SSL (Windows)


1) Criar o arquivo keystore:

Em %JAVA_HOME%/bin execute o seguinte comando:

keytool -genkey -alias meuCertificado -keyalg DSA -keypass senha -storepass senha -keystore C:/certificados/meuCertificado.jks -dname "cn=empresa, ou=area, o=grupoDeTrabalho, l=Cidade, S=Estado, c=Pais" -validity 365

2)Configurar o arquivo server.xml do TomCat:

Localize a seguinte declaração:

<!--<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" />-->

Descomente e altere conforme abaixo:

Connector SSLEnabled="true" acceptCount="100" clientAuth="false"    disableUploadTimeout="true" enableLookups="false" maxThreads="25"    port="8443" keystoreFile="C:\certificados\meuCertificado.jks" keystorePass="senha"    protocol="org.apache.coyote.http11.Http11NioProtocol" scheme="https"    secure="true" sslProtocol="TLS" />

3)Testando:
Acesse https://localhost:8443.

4)Configurar a aplicação para usar SSL:

Adicione no web.xml

<security-constraint>  
  <web-resource-collection>    
    <web-resource-name>securedapp</web-resource-name>      
    <url-pattern>/*</url-pattern>  //Ativar SSL em todas as páginas
    <url-pattern>/login.jsf</url-pattern> // Ativar SSL em páginas específicas
    <url-pattern>/cadastro/*</url-pattern>  //Ativar SSL em pastas
  </web-resource-collection>  
  <user-data-constraint>      
    <transport-guarantee>CONFIDENTIAL</transport-guarantee>  
  </user-data-constraint>
</security-constraint>

Para desativar mude o CONFIDENTIAL para NONE.