Skip to content

Instantly share code, notes, and snippets.

Start with INSTANCE
The first initialization was wrong with this ErrorMessage:
java.lang.ExceptionInInitializerError
The error message by every next acces:
The first initialization was wrong with this ErrorMessage:
at de.mosst.spielwiese.no_class_def_found_error.Tester.main(Tester.java:9)
Caused by: java.lang.RuntimeException: RuntimeException by instance with field
at de.mosst.spielwiese.no_class_def_found_error.SingeltonClass_with_INSTANCE_as_field.<init>(SingeltonClass_with_INSTANCE_as_field.java:8)
at de.mosst.spielwiese.no_class_def_found_error.SingeltonClass_with_INSTANCE_as_field.<clinit>(SingeltonClass_with_INSTANCE_as_field.java:5)
package de.mosst.spielwiese.no_class_def_found_error;
import java.util.logging.Logger;
@SuppressWarnings("unused")
public class Tester {
public static void main(String[] args) {
System.out.println("Start with INSTANCE");
try {
package de.mosst.spielwiese.no_class_def_found_error;
public class SingeltonClass_with_INSTANCE_as_field {
public static SingeltonClass_with_INSTANCE_as_field INSTANCE = new SingeltonClass_with_INSTANCE_as_field();
private SingeltonClass_with_INSTANCE_as_field() {
throw new RuntimeException("RuntimeException by instance with field");
}
package de.mosst.spielwiese.no_class_def_found_error;
public class SingeltonClass_with_getInstanceO_Method {
private static SingeltonClass_with_getInstanceO_Method INSTANCE;
private SingeltonClass_with_getInstanceO_Method() {
throw new RuntimeException("RuntimeException by instance with getInstanceO_Method");
}
@markstein
markstein / build.gradle
Created November 21, 2012 22:00
Gradle Script zum Herunterladen der abhängigen JARs von RESTEasy JAX-RS
apply plugin: 'java'
repositories {
mavenCentral()
mavenRepo urls: "http://repository.jboss.org/nexus/content/groups/public/"
}
dependencies {
compile 'org.jboss.resteasy:resteasy-jaxrs:2.3.5.Final'
}
@markstein
markstein / SausageServlet.java
Created November 16, 2012 12:49
Sausage with HSQLDB over Tomcat
public class SausageServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/SausageDB");
@markstein
markstein / test.properties
Created July 11, 2012 11:41
Liferay School
portal-dependency-jars=\
jstl-api.jar,\
jstl-impl.jar
portal-dependency-tlds=\
c.tld
@markstein
markstein / analyse_db_and_report_to_another_db.groovy
Created June 13, 2012 13:29
Groovy ist cool! Eine Datenbank auswerten und in die andere ablegen - nur in 5 Zeilen
import groovy.sql.Sql
Sql liferayDB = Sql.newInstance("jdbc:mysql://localhost:3306/liferay", "user1", "pass1", "com.mysql.jdbc.Driver")
Sql statisticsDB = Sql.newInstance("jdbc:mysql://localhost:3306/statistics", "user2", "pass2", "com.mysql.jdbc.Driver")
firstRow = tugetherDB.firstRow("SELECT count(*) as anzahl FROM User_ WHERE loginDate &gt; (NOW() - INTERVAL 1 HOUR)")
statisticsDB.execute("INSERT INTO loginsPerHour (zeit, useranzahl) VALUES (NOW(), $firstRow.anzahl)")
@markstein
markstein / portal-log4j-ext.xml
Created June 13, 2012 11:38
Customize logging by Liferay portal
<?xml version="1.0"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<category name="com.liferay.portal">
<priority value="ERROR" />
</category>
<category name="my.portlet.soccer">