quarta-feira, 5 de outubro de 2016
Maven packagingExcludes
Excluir todas as libs do modulo:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp</directory>
</resource>
</webResources>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
<packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
</configuration>
</plugin>
Excluir todas as libs do modulo exceto a lib específica online-converters-1.0.0.jar
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp</directory>
</resource>
</webResources>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
<packagingExcludes>%regex[WEB-INF/lib/(?!online-converters-1.0.0\.jar).*]</packagingExcludes>
</configuration>
</plugin>
sexta-feira, 24 de junho de 2016
Adicionar certificado confiável no linux:
0. Como não tinha conhecimento do local de instalação do weblogic, precisei identificar pelo processo com o comando abaixo:
host:/root:ps -aux | grep -i java
Identificado: /usr/oracle/middleware/user_projects/domains/dominioWebLogic
1. Identificar o cacert utilizado pelo Servidor Weblogic
No Console do weblogic (http://localhost:7001/console), Selecionar:
-Ambiente
-Servidores
-Selecionar o servidor
-Aba Áreas de Armazenamento de Chaves
-Informação no campo: Área de Armazenamento de Chaves Confiáveis Padrão Java:
valor encontrado: /usr/java/jdk1.7.0_79/jre/lib/security/cacerts
2. Verificar se o certificado esta instalado:
Executar como root.
Ir para o diretório bin do jdk e executar o comando abaixo:
/usr/java/jdk1.7.0_79/jre/bin:./keytool -list -keystore "/usr/java/jdk1.7.0_79/jre/lib/security/cacerts" -alias "certificadododominio.com.br"
Senha do keystore será solicitada: changeit
Exibida a mensagem abaixo informando que não existe o certificado:
keytool error: java.lang.Exception: Alias <certificadododominio.com.br> does not exist
3. Importando o certificado:
/usr/java/jdk1.7.0_79/jre/bin:./keytool -importcert -keystore "/usr/java/jdk1.7.0_79/jre/lib/security/cacerts" -file
"/home/oracle/certificado_hgeridinss.crt" -alias "certificadododominio.com.br"
Será exibido a mensagem abaixo, digitar y :
#
#: ObjectId: 2.5.29.17 Criticality=false
#SubjectAlternativeName [
# Other-Name: Unrecognized ObjectIdentifier: 2.16.76.1.3.8
# Other-Name: Unrecognized ObjectIdentifier: 2.16.76.1.3.4
# Other-Name: Unrecognized ObjectIdentifier: 2.16.76.1.3.2
# Other-Name: Unrecognized ObjectIdentifier: 2.16.76.1.3.3
# RFC822Name: #########@certificadododominio.com.br
#]
#
#Trust this certificate? [no]: y
#Certificate was added to keystore
#
O Certificado foi importado.
4. Após a importação do certificado, INICIALIZAR o weblogic.
5. No console do Weblogic , desabilitar a verificação de nome do servidor:
CONSOLE => http://HOST:7001/console
Selecionar :
- Ambiente -> Servidores
- Clicar em AdminServer(admin) -> aba SSL -> Avançado
- No combo Verificação de Nome do Host (Hostname Verification), selecionar Nenhum
- Clicar em Salvar.
host:/root:ps -aux | grep -i java
Identificado: /usr/oracle/middleware/user_projects/domains/dominioWebLogic
1. Identificar o cacert utilizado pelo Servidor Weblogic
No Console do weblogic (http://localhost:7001/console), Selecionar:
-Ambiente
-Servidores
-Selecionar o servidor
-Aba Áreas de Armazenamento de Chaves
-Informação no campo: Área de Armazenamento de Chaves Confiáveis Padrão Java:
valor encontrado: /usr/java/jdk1.7.0_79/jre/lib/security/cacerts
2. Verificar se o certificado esta instalado:
Executar como root.
Ir para o diretório bin do jdk e executar o comando abaixo:
/usr/java/jdk1.7.0_79/jre/bin:./keytool -list -keystore "/usr/java/jdk1.7.0_79/jre/lib/security/cacerts" -alias "certificadododominio.com.br"
Senha do keystore será solicitada: changeit
Exibida a mensagem abaixo informando que não existe o certificado:
keytool error: java.lang.Exception: Alias <certificadododominio.com.br> does not exist
3. Importando o certificado:
/usr/java/jdk1.7.0_79/jre/bin:./keytool -importcert -keystore "/usr/java/jdk1.7.0_79/jre/lib/security/cacerts" -file
"/home/oracle/certificado_hgeridinss.crt" -alias "certificadododominio.com.br"
Será exibido a mensagem abaixo, digitar y :
#
#: ObjectId: 2.5.29.17 Criticality=false
#SubjectAlternativeName [
# Other-Name: Unrecognized ObjectIdentifier: 2.16.76.1.3.8
# Other-Name: Unrecognized ObjectIdentifier: 2.16.76.1.3.4
# Other-Name: Unrecognized ObjectIdentifier: 2.16.76.1.3.2
# Other-Name: Unrecognized ObjectIdentifier: 2.16.76.1.3.3
# RFC822Name: #########@certificadododominio.com.br
#]
#
#Trust this certificate? [no]: y
#Certificate was added to keystore
#
O Certificado foi importado.
4. Após a importação do certificado, INICIALIZAR o weblogic.
5. No console do Weblogic , desabilitar a verificação de nome do servidor:
CONSOLE => http://HOST:7001/console
Selecionar :
- Ambiente -> Servidores
- Clicar em AdminServer(admin) -> aba SSL -> Avançado
- No combo Verificação de Nome do Host (Hostname Verification), selecionar Nenhum
- Clicar em Salvar.
terça-feira, 19 de abril de 2016
Comparar as dependencias entre dois arquivos pom.
ref: http://affy.blogspot.com.br/2007/09/extracting-dependancy-lists-from-maven.html
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class PomAnalysisDriver {
private static XPathFactory xpathFactory = XPathFactory.newInstance();
XPathExpression artifactIdExpr = null;
XPathExpression dependencyExpr = null;
XPathExpression depGroupIdExpr = null;
XPathExpression depArtifactIdExpr = null;
XPathExpression depScopeExpr = null;
XPathExpression depVersionExpr = null;
public static List<String> pomFiles = new ArrayList<String>(1);
public static void main(String[] args) throws Exception {
try {
String pathPomFile_1;
String pathPomFile_2;
if (args.length == 2) {
pathPomFile_1 = args[0];
pathPomFile_2 = args[1];
} else {
System.out.println("Usage: java ComparePom FilePathPom FilePathAnotherPom");
return;
}
PomAnalysisDriver.pomFiles.add(pathPomFile_1);
PomAnalysisDriver.pomFiles.add(pathPomFile_2);
PomAnalysisDriver pad = new PomAnalysisDriver();
pad.init();
// pad.searchForPomFiles("[ROOT_DIR]", pomFiles);
pad.execute();
} finally {
System.out.println("Done.");
}
}
public void init() throws XPathExpressionException {
XPath xpath = xpathFactory.newXPath();
artifactIdExpr = xpath.compile("/project/artifactId/text()");
dependencyExpr = xpath.compile("/project/dependencies/dependency");
depGroupIdExpr = xpath.compile("./groupId/text()");
depArtifactIdExpr = xpath.compile("./artifactId/text()");
depScopeExpr = xpath.compile("./scope/text()");
depVersionExpr = xpath.compile("./version/text()");
}
public void execute() throws SAXException, IOException, ParserConfigurationException, XPathExpressionException {
Set<String>[] sets = new HashSet[2];
/* for (String pomFilename : PomAnalysisDriver.pomFiles) { */
for (int j = 1; j <= PomAnalysisDriver.pomFiles.size(); j++) {
String pomFilename = PomAnalysisDriver.pomFiles.get(j - 1);
sets[j - 1] = new HashSet<String>();
File f = new File(pomFilename);
Document document;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(f);
// Node projectNode = document.getDocumentElement();
// NodeList children = projectNode.getChildNodes();
String projectName = (String) artifactIdExpr.evaluate(document, XPathConstants.STRING);
NodeList nodes = (NodeList) dependencyExpr.evaluate(document, XPathConstants.NODESET);
for (int i = 0; i < nodes.getLength(); i++) {
Node dependency = nodes.item(i);
String depGroupId = (String) depGroupIdExpr.evaluate(dependency, XPathConstants.STRING);
String depArtifactId = (String) depArtifactIdExpr.evaluate(dependency, XPathConstants.STRING);
String depScope = (String) depScopeExpr.evaluate(dependency, XPathConstants.STRING);
String depVersion = (String) depVersionExpr.evaluate(dependency, XPathConstants.STRING);
String depId = "GroupId: " + depGroupId + "; ArtifactId: " + depArtifactId + "; Scope: " + depScope
+ "; Version: " + depVersion;
sets[j - 1].add((String) depId);
}
}
sets[0].removeAll(sets[1]);
/*
* for (Set<String> set : sets) { System.out.println(set); }
*/
for (String k : sets[0])
System.out.println(k);
}
}
segunda-feira, 18 de abril de 2016
Different ways of loading a file as an inputstream
ref:http://stackoverflow.com/questions/676250/different-ways-of-loading-a-file-as-an-inputstream
class J {
public static void main(String[] a) {
// as "absolute"
// ok
System.err.println(J.class.getResourceAsStream("/file.txt") != null);
// pop
System.err.println(J.class.getClassLoader().getResourceAsStream("/file.txt") != null);
// as relative
// ok
System.err.println(J.class.getResourceAsStream("./file.txt") != null);
// ok
System.err.println(J.class.getClassLoader().getResourceAsStream("./file.txt") != null);
// no path
// ok
System.err.println(J.class.getResourceAsStream("file.txt") != null);
// ok
System.err.println(J.class.getClassLoader().getResourceAsStream("file.txt") != null);
}
}
segunda-feira, 21 de março de 2016
JSF get component by ID
public UIComponent findComponent(String id) {
UIComponent result = null;
UIComponent root = FacesContext.getCurrentInstance().getViewRoot();
if (root != null) {
result = findComponent(root, id);
}
return result;
}
private UIComponent findComponent(UIComponent root, String id) {
UIComponent result = null;
if (root.getId().equals(id))
return root;
for (UIComponent child : root.getChildren()) {
if (child.getId().equals(id)) {
result = child;
break;
}
result = findComponent(child, id);
if (result != null)
break;
}
return result;
}
Assinar:
Comentários (Atom)