Skip to content

Instantly share code, notes, and snippets.

@kevinhooke
kevinhooke / gist:3ffd0707609daf4cfbcf
Last active January 24, 2020 00:31
Maven properties to configure java version
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
@kevinhooke
kevinhooke / gist:c73ee974a706491265d9
Created October 4, 2014 01:56
Log4j 2 basic xml config
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%C - %m%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="example.logger.name" level="debug"/>
<Root level="debug">
@kevinhooke
kevinhooke / gist:6f7cd1a83da09dad813d
Created October 4, 2014 01:58
Log4j 1.x basic log4j.properties
log4j.rootLogger=DEBUG, console
#console appender
log4j.appender.console=org.apache.log4j.ConsoleAppender
#define patternlayour for console appender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
@kevinhooke
kevinhooke / gist:d1ead9a8bed8c3c57736
Created December 10, 2014 06:22
Maven dependency: EE5
<dependency>
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
<version>5</version>
<scope>provided</scope>
</dependency>
@kevinhooke
kevinhooke / gist:7db4a60c1b8cc2c2c6c4
Created December 10, 2014 06:23
Maven dependency: EE6
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
@kevinhooke
kevinhooke / gist:52eae47ad0ca9ee0b09e
Last active August 29, 2015 14:11
Maven dependency: EE7
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
@kevinhooke
kevinhooke / gist:97f5142d4859287c1492
Last active August 29, 2015 14:13
Disable JAXP DTD loading and validation
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(false);
dbf.setNamespaceAware(true);
//one of these pairs of properties will work depending on which xml api impl is in use
dbf.setFeature("http://xml.org/sax/features/namespaces", false);
dbf.setFeature("http://xml.org/sax/features/validation", false);
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
@kevinhooke
kevinhooke / gist:804ae15dbfaffc064805
Created March 7, 2015 22:35
JAX-WS client generation
wsimport -keep -p package.name url_to_wsdl
<?xml version="1.0"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd" />
@kevinhooke
kevinhooke / gist:5daf864a0f9a58bd2c96
Created April 14, 2015 23:04
JPA persistence.xml with JTA and Weblogic transaction manager
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="SimplePU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/datasourcename</jta-data-source>
<properties>
<property name="hibernate.hbm2ddl.auto" value="create" /> <!-- remove this if not creating tables at init -->
<property name="hibernate.show_sql" value="true" />