sábado, enero 15, 2011

Ubuntu 10.04 Server Subversion

Me estoy metiendo a linux, tuve que configurar el SVN.
Comparto una ruta muy buena:

La clave para mi fue la combinación de :
SVNParentPath /usr/local/svn
AuthzSVNAccessFile /path/to/access/file        



jueves, septiembre 02, 2010

java.io.IOException: JDT compilation error! WebLogic 10.3

Al desplegar un ear con un modulo EJB (3.0) en Weblogic (10.3.1 y 10.3.2, en Windows 7 con el JDK de cada instalación) obtenía el siguiente error:

Unable to deploy EJB: negocio-3.1.0.jar from negocio-3.1.0.jar:

There are 1 nested errors:

java.io.IOException: JDT compilation error!
at weblogic.ejb.container.ejbc.CompilerForJDT.compile(CompilerForJDT.java:66)
at weblogic.ejb.container.ejbc.EJBCompiler.doCompile(EJBCompiler.java:358)
at weblogic.ejb.container.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:556)

El problema era por un método sobre cargado:

boolean solicitarXxxYyyyObjeto(List listYyyyTO,
List listZzzzInstanciaTO);

Boolean solicitarXxxYyyyObjeto(
List listaZzzzInstanciaTO,
List listaYyyyTO) throws SeguridadException;

Elimine uno de los dos método tanto en la interfaz como en la implementación.
Y con eso la aplicación jalo.

lunes, abril 12, 2010

Cambiar tiitulo del browser

Para cambiar el titulo del navegador que contenga alguna pelicula creada en Flex se puede usar el siguiente código:
bm = BrowserManager.getInstance();
bm.init("", "Titulo deseado");

lunes, mayo 25, 2009

No quiero licencia

Serial number for Poseidon for UML Community Edition - 30-days free testing - Annual Subscription (1 License(s))

Wjmlmg8PFeVnXK0v9IOyq3avfPaUPDVwvbCBtw3PRCo/hGzbJFtprZpD94zi
giW6ovXQwJIgasaLXuB7lHc6DPpUA0ZaPkjuZXA8JgnEYvHaS9oJyrbvaYlp
Lzr9R9OajlmyxFv/HwUVqrhW0IFpRIb8+LVWNgqjRguCTRsovll7l8G+cw/+
uqn4s6Yz77WKTUwbNX3Ntz8UT2tHDLyXPWWtmsLpKXxuirIGNU2WzsfMFtnM
LdDMWjXDhRdDfQKhzCgNI0N3/1jrwATw7DeCbd3cGhIFfhjdpFlyJq2wa2Xb
BZrtrqqdqmWJrXDrokF//xy9+tm2sLj69Ql+6Sdwlw


*Single User Serial Number Installation* Here is a step by step procedure to install a Poseidon serial number:
1. Download the software from
<http://www.gentleware.com?redirect=download>
(Please use JDK/JRE Version 1.5, or use the installers that include a JRE) 2. Copy the key (above) to your clipboard 3. Start Poseidon for UML 4. If the License Manager dialog does not appear automatically,
please select "help" from the menu bar and choose "License Manager"
5. Click on "Paste from Clipboard" and your key will appear 6. Click the "Add" button to finish the process 7. You will have to register to get a final license key (you can register
even if your serial number has expired).
Click on the serial number in the table to select it, then click "Register"
and enter your User Information.
Click "Next" to finish your registration and get the final license
online or via our Website.
If you need support or have any questions concerning our products, please contact us at http://www.gentleware.com?redirect=contact  

jueves, junio 05, 2008

JVM bind error

Al levantar JBoss me encontre con que no podía conectar el puerto 1099.

Encontre como cambiarlo:

Mover la configuración de los puertos en los siguientes archivos

and you will find entries in lines

{JBOSS_HOME}\server\default\conf\jboss-minimal.xml
{JBOSS_HOME}\server\default\conf\jboss-service.xml
{JBOSS_HOME}\server\default\deploy\cache-invalidation-service.xml


El post original aquí.

martes, mayo 06, 2008

viernes, septiembre 28, 2007

Dates in HSQLDB

Encontre un link para el manejo de fechas en HSQL (y muestra el ejemplo con Oracle).
Para obtener
2007-09-28

Se hace:

year(current_date) '-' month(current_date) '-'
(dayOfMonth(current_date)-60

El post original está aquí.

jueves, febrero 08, 2007

Flavors to Printer

DocFlavor[] flavors = impSelected.getSupportedDocFlavors();
for (int i = 0; i < flavors.length; i++ ) {
try {
System.out.println(BeanUtils.describe(flavors[1]).toString());
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
} // for

martes, enero 02, 2007

LongRaw Datatype Oracle

      String query = "SELECT name,airline_logo FROM " +
"otn_airline_longraw WHERE code=?"
;

// Create a PreparedStatement object for executing the query
PreparedStatement pst = connection.prepareStatement(query);

// bind the parameter with code value
pst.setString(1,lcode);

// Obtain the result-set for the selected airline record
ResultSet result = pst.executeQuery();

// get user home folder name
userHome = System.getProperty("user.home");

if( result.next() ) {

// Fetch column values
name = result.getString(1); // Obtain the airline code

// append the file name with user home directory, file separator and
// file extension GIF
fullName = userHome+File.separator+name+".gif";

// LONGRAW data can be accessed in two ways:
// 1) By retrieving all the data at once (using getBytes method)
// 2) By using streams. The LONGRAW data is made available to the program
// as a stream, and the data can be retrieved chunk by chunk, which is
// more eficient in terms of memory usage
// In this sample we illustrate retrieval using streams method.
gifdata = result.getBinaryStream(2);
// create new file
File gifFile = new File(fullName);

// Write the byte array into a local file
FileOutputStream file= new
FileOutputStream(gifFile);

int chunk=0;
// write to the local file until image (LONGRAW) data is found
while( (chunk = gifdata.read()) != -1) {
file.write(chunk);
}

El ejemplo competo está acá [Cátalogo de ejemplos].
Creo que tiene las mejores practicas las clases:
Hace falta un finally para cerrar recursos.
Declarar como final algunos objetos.


sábado, diciembre 16, 2006

Error creating bean with name 'xfire.typeMappingRegistry'

IBM WebSphere Application Server - ND, 6.0.0.1
Número de build: o0445.08
Fecha de build: 11/10/04

Frameworks: Spring & XFire.

Error:
;)org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xfire.typeMappingRegistry' defined in class path resource [org/codehaus/xfire/spring/xfire.xml]: Initialization of bean failed; nested exception is java.lang.VerifyError: (class: org/codehaus/xfire/aegis/type/basic/ObjectType, method: writeSchema signature: (Lorg/jdom/Element V) Incompatible argument to method


La solución es:
WAS tiene po defecto una libreria de JDOM versión 0.7, XFire usa la versión 1.0, al levantar la aplicación el contenedor utiliza las clases de 0.7 de JDOM dado que están en el classLoader del servidor sin importarle la del classLoader de la aplicación (WEB-INF\lib).
Hay que copiar dentro de las librerias del server (C:\Archivos de programa\IBM\WebSphere\AppServer1\lib) la versión 1.0 de JDOM.

Referencia:
Error creating bean with name 'xfire.typeMappingRegistry'

jueves, junio 29, 2006

one-to-one with Hibernate

Cuando tiene una relación uno a uno en la BD, se supone que ambas tablas tiene la misma llave.
Cuando Hibernate hace el mapeo crea una relación one-to-one y como tienen la misma llave, ambas tablas deberian usar el mismo Objeto PK.
Tip: Solemos usar herramientas para generar los mapeos y las clases Java a partir de la BD que no saben identificar el escenario antes descrito (no conozco ningúna herramienta capaz), para no invertirle demasido tiempo a ésto basta con que en la clase hija (de la relación de BD) use la misma PK que la padre, y de la PK que se generó para la clase hija hacer que extienda de la clase PK del padre:
Ejemplo:
Padre en la BD:
name="mx.net.vladpax.java.hbm.Familia" table="IEC_SUBDELEGACION">
name="comp_id" class="mx.net.vladpax.java.hbm.FamiliaPK">
name="cveFamilia" column="CVE_FAMILIA" type="java.lang.Integer" length="2"/>
name="cveTipoFamilia" column="CVE_TIPO_FAMILIA" type="java.lang.Integer" length="2"/>

Hija en la BD:
name="mx.net.vladpax.java.hbm.CasaXFam" table="IEC_MPIO_XSUBDEL" >
name="comp_id" class="
mx.net.vladpax.java.hbm.FamiliaPK">
name="
cveFamilia" column="CVE_FAMILIA" type="java.lang.Integer" length="2"/>
name="
cveTipoFamilia" column="CVE_TIPO_FAMILIA" type="java.lang.Integer" length="2"/>
Si vemos tenemos la misma clase, en la hija la gerramienta me generó una llamada: 'CasaXFamPK' e identica a SubdelegacionPK
La cual modifique de la siguiente forma:

public class CasaXFamPK extends FamiliaPK {

La excepción provacada cuando caemos en el error de no usar la misma clase para relaciones one-to-one es:
exception getting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of paquete.java..nombreClaseHijaPK.?; nested exception is org.hibernate.PropertyAccessException: exception getting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of paquete.java.nombreClaseHijaPK.?

martes, junio 20, 2006

Manejo de BLOB con Hibernate, Spring y Oracle

Clase Form
public class DocumentacionProbatoriaForm extends ValidatorForm{

/**
* Crea una instancia de clase DocumentacionProbatoriaForm.
*/
public DocumentacionProbatoriaForm() {
super();
// TODO Auto-generated constructor stub
}

/**
atributo para almacenar el rutaArchivo
*/
private String rutaArchivo;

/**
atributo para almacenar el archivo
*/
private FormFile archivo;

}// end class

Clase Action
public class DocumentacionProbatoriaMappingDispatchAction extends
MappingDispatchAction {


public ActionForward cargarDocumentoProbatorio(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {

if (logger.isInfoEnabled()) {
logger.info(" #### METODO: cargarDocumentoProbatorio");
}
DocumentacionProbatoriaForm forma = (DocumentacionProbatoriaForm) form;

FormFile docto = forma.getArchivo();


if (logger.isDebugEnabled()) {
logger.debug("size ::" + docto.getFileSize());
logger.debug("name ::" + docto.getFileName());
}//
DocumentacionProbatoriaVO vo = new DocumentacionProbatoriaVO();

vo.setCvePersona4modif(cvePersona4modif);
vo.setArchivo(docto.getFileData());


service = (DocumentacionProbatoriaService) super
.getBean("documentacionProbatoriaService");
// guardamos
vo = service.guardarDocumentacion(vo);
}//end method
}//end class


Implementación de la Clase de Servicio

public class DocumentacionProbatoriaServiceImpl implements
DocumentacionProbatoriaService {

private static Logger logger = Logger.getLogger(DocumentacionProbatoriaServiceImpl.class);

private DocProbatoriaModifDAO docProbatoriaModifDAO;

private FoliadorDAO foliadorDAO;

/**
* Crea una instancia de clase DocumentacionProbatoriaServiceImpl.
*/
public DocumentacionProbatoriaServiceImpl() {
super();
// TODO Auto-generated constructor stub
}

public DocumentacionProbatoriaVO guardarDocumentacion(
DocumentacionProbatoriaVO vo) throws BusinessException {

try {
Integer cveDocProbatoriaModif = this.foliadorDAO.getCveDocProbatoriaModif(vo.getCvePersona4modif());

DocProbatoriaModifPK pk = new DocProbatoriaModifPK();
pk.setCveDocProbatoriaModif(cveDocProbatoriaModif);
pk.setCvePersona4modif(vo.getCvePersona4modif());

DocProbatoriaModif docProba = new DocProbatoriaModif();
docProba.setComp_id(pk);
docProba.setDocProbatoria(this.creaBlob(vo.getArchivo()));
docProba.setDesDocProbatoria(vo.getDesDocProbatoria());
docProba.setDesNombreArchivo(vo.getNombreArchivo());

this.docProbatoriaModifDAO.insertar(docProba);

vo.setCveDocProbatoriaModif(cveDocProbatoriaModif);

// TODO Auto-generated method stub

}
catch (InfrastructureException e) {
logger.error(e.getMessage(), e);
}
return vo;
}

public DocumentacionProbatoriaVO recuperarDocumentacion(
DocumentacionProbatoriaVO vo) throws BusinessException {
try {
DocProbatoriaModifPK pk = new DocProbatoriaModifPK();
pk.setCveDocProbatoriaModif(vo.getCveDocProbatoriaModif());
pk.setCvePersona4modif(vo.getCvePersona4modif());
DocProbatoriaModif result= this.docProbatoriaModifDAO.findByPK(pk);
vo.setArchivo(this.toByteArray(result.getDocProbatoria()));
vo.setDesDocProbatoria(vo.getDesDocProbatoria());
vo.setNombreArchivo(result.getDesNombreArchivo());
return vo;
}
catch (InfrastructureException e) {
logger.error(e.getMessage(), e);
throw new BusinessException(e.getMessage(), e);
}
}


/**
* Recupera todos los documentos de una persona.
Recupera todos los datos excepto el BLOB.

* @param cvePersona4modif
* @return Lista con objetos DocumentacionProbatoriaVO.
* @throws BusinessException
*/
public List recuperaDocumentosXPersona(Integer cvePersona4modif) throws BusinessException{
List response = new ArrayList();

try {
if (logger.isDebugEnabled()){
logger.debug("cvePersona4modif :: " + cvePersona4modif);
}

final List temp = this.docProbatoriaModifDAO.recuperaListaDoctos( cvePersona4modif);
DocProbatoriaModif persitente = null;
DocumentacionProbatoriaVO vo = null;
if (temp!= null && !temp.isEmpty()){
final Iterator it = temp.iterator();
while(it.hasNext()) {
persitente =(DocProbatoriaModif) it.next();
vo = new DocumentacionProbatoriaVO();
vo.setArchivo(null);
vo.setCveDocProbatoriaModif(persitente.getComp_id().getCveDocProbatoriaModif());
vo.setCvePersona4modif(persitente.getComp_id().getCvePersona4modif());
vo.setDesDocProbatoria(persitente.getDesDocProbatoria());
vo.setNombreArchivo(persitente.getDesNombreArchivo());
if (logger.isDebugEnabled()){
logger.debug("DesNombreArchivo :: "
+ persitente.getDesNombreArchivo() + ", "
+ vo.getCveDocProbatoriaModif());
}
response.add(vo);
}
}

return response;
}
catch (InfrastructureException e) {
logger.error(e.getMessage(), e);
throw new BusinessException(e.getMessage(), e);
}
}

/**
* Elimina un documento.
* @param vo
* @throws BusinessException
*/
public void eliminarDocumento(DocumentacionProbatoriaVO vo) throws BusinessException{

try {
DocProbatoriaModifPK pk = new DocProbatoriaModifPK();



pk.setCveDocProbatoriaModif(vo.getCveDocProbatoriaModif());
pk.setCvePersona4modif(vo.getCvePersona4modif());

if (logger.isInfoEnabled()){
logger.info("pk :: " + GeneralSimeUtil.getObjectAsString(pk));
}

DocProbatoriaModif objetoPersistente = this.docProbatoriaModifDAO.findByPK(pk);

this.docProbatoriaModifDAO.eliminar(objetoPersistente);


if (logger.isDebugEnabled()) {
logger.debug("Eliminar [OK]");
}

}
catch (InfrastructureException e) {
logger.error(e.getMessage(), e);
throw new BusinessException(e.getMessage(), e);
}

}

/**
* Crea un BLob a apartir de un arrelog de bytes.
* @param input
* @return
*/
private Blob creaBlob(byte[] input){
return Hibernate.createBlob(input);
}


private byte[] toByteArray(Blob fromBlob) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
return toByteArrayImpl(fromBlob, baos);
}
catch (SQLException e) {
throw new RuntimeException(e);
}
catch (IOException e) {
throw new RuntimeException(e);
}
finally {
if (baos != null) {
try {
baos.close();
}
catch (IOException ex) {
}
}
}
}

private byte[] toByteArrayImpl(Blob fromBlob, ByteArrayOutputStream baos)
throws SQLException, IOException {
byte[] buf = new byte[4000];
InputStream is = fromBlob.getBinaryStream();
try {
for (;;) {
int dataSize = is.read(buf);

if (dataSize == -1)
break;
baos.write(buf, 0, dataSize);
}
}
finally {
if (is != null) {
try {
is.close();
}
catch (IOException ex) {
}
}
}
return baos.toByteArray();
}

/**
* Método que establece el valor del atributo docProbatoriaModifDAO.
*
* @param docProbatoriaModifDAO
* Valor a establecer en el atributo docProbatoriaModifDAO.
*/
public void setDocProbatoriaModifDAO(
DocProbatoriaModifDAO docProbatoriaModifDAO) {
this.docProbatoriaModifDAO = docProbatoriaModifDAO;
}

/**
* Método que establece el valor del atributo foliadorDAO.
*
* @param foliadorDAO
* Valor a establecer en el atributo foliadorDAO.
*/
public void setFoliadorDAO(FoliadorDAO foliadorDAO) {
this.foliadorDAO = foliadorDAO;
}

}//end class

Clase DAO
public class DocProbatoriaModifDAOImpl extends DAOSimeBaseImpl implements DocProbatoriaModifDAO {

/**
* Crea una instancia de clase DocProbatoriaModifDAOImpl.
*/
public DocProbatoriaModifDAOImpl() {
super();
// TODO Auto-generated constructor stub
}

public DocProbatoriaModif findByPK(DocProbatoriaModifPK pk) throws InfrastructureException {
return (DocProbatoriaModif) super.getHibernateTemplate().load(DocProbatoriaModif.class, pk);
}
public List recuperaListaDoctos(Integer cvePersona4modif) throws InfrastructureException{
List response = new ArrayList();

StringBuffer query = new StringBuffer();
query.append(" from DocProbatoriaModif as obj");
query.append(" where obj.comp_id.cvePersona4modif = ");
query.append(cvePersona4modif);

response = super.getHibernateTemplate().find(query.toString());

if (logger.isDebugEnabled()){
logger.debug("query :: " + query);
logger.debug("response.size() :: " + response.size());
}

return response;
}
}//end class

Clase VO
public class DocumentacionProbatoriaVO extends GenericSimeVO {

/**
*
*/
private static final long serialVersionUID = 1L;
private java.lang.Integer cvePersona4modif;
private java.lang.Integer cveDocProbatoriaModif;
/**
* Representación en un arreglo de bytes del archivo
*/
private byte[] archivo;
private java.lang.String nombreArchivo;
private java.lang.String desDocProbatoria;
}//end class

Clase de mapeo de HB:

public abstract class BaseDocProbatoriaModif implements Serializable {

// primary key
private mx.net.vlad.integracion.hbm.DocProbatoriaModifPK comp_id;

// fields
private java.sql.Blob docProbatoria;
private java.lang.String desDocProbatoria;
private java.lang.String desNombreArchivo;
}//end class




Nota
La clases de tipo bean obviamente tienen sus métodos get&set.
La clases que considero más importante y por lo tanto la he puesto intacta es el servicio, ya que hace la transformación del arreglo de bytes al objeto BLOB y viceversa.
La configuración de Spring no tiene nada de especial es por ello que no la pongo.