one important contribution to programmers life from microsoft are the backslash path separators.
A really nice example of why this is so brain dead I discovered using Microsofts own nmake tool which can be integrated into visual studio.
For example, if you use a rule like below and you forget to put a space behind the trailing backslash
suddenly the smart nmake semantics decides to use the backslash as a line continuation causing a syntax error.
As a trailing space is clearly not visible this is a nasty ditch to fall into.
Thanks Microsoft for such a smart choice for the path separator.
CopyFdoComponentsDebug : ..\..\..\Oem\FDO\*.*
if NOT EXIST ..\..\bin\debug\FDO\nul mkdir ..\..\bin\debug\FDO
if EXIST ..\..\..\Oem\FDO\bin\Release xcopy /r /d /y /s ..\..\..\Oem\FDO\bin\Release ..\..\bin\debug\FDO\[space]
if EXIST ..\..\..\Oem\FDO\bin\Debug xcopy /r /d /y /s ..\..\..\Oem\FDO\bin\Debug ..\..\bin\debug\FDO\
Sunday, June 26, 2011
Friday, June 24, 2011
STOP 7E error on VISTA SP2 WORKAROUND
My Vista installation on Lenovo SL500 (otherwise a surprisingly fine machine)
repeatedly crashes on Driver Power State Failure BSOD STOP 9F
The fun bit is that when I try to reboot I end up with another BSOD STOP 7E.
This happens after loading CRCDISK.SYS.
However, the following procedure turned out to boot up the system again:
repeatedly crashes on Driver Power State Failure BSOD STOP 9F
The fun bit is that when I try to reboot I end up with another BSOD STOP 7E.
This happens after loading CRCDISK.SYS.
However, the following procedure turned out to boot up the system again:
- Unplug all external harddrives!
- Try LAST KNOWN GOOD Configuration (boot -> F8)
- If that does not boot do a CHKDSK of the Vista drive
- Try Again.
I did this like > 20 times now and this seems to be a reliable approach.
Would love to find instructions how to identify the faulty driver which causes all this......
Would love to find instructions how to identify the faulty driver which causes all this......
Tuesday, June 21, 2011
debugging Apache Tomcat 6 webapps in eclipse
Its sometimes useful to run the java webapp in a tomcat container external from eclipse.
This way the eclipse source lookup bug
(not finding the sources in the maven repository) can be avoided.
The default tomcat installer leaves this nifty little manager to control the service.

In order to debug the tomcat jvm as an external java application you need add some properties to the java options to fire up tomcat.
This way the eclipse source lookup bug
(not finding the sources in the maven repository) can be avoided.
The default tomcat installer leaves this nifty little manager to control the service.
In order to debug the tomcat jvm as an external java application you need add some properties to the java options to fire up tomcat.
The options have to be added one per line to work!
This way the source lookup via maven repository is working splendid.
I use the following combination to permit remote debugging access on 8789
and access to jvm analysis with jvisualvm on port 8888
-Xdebug
-Xnoagent
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8789
-Dcom.sun.management.jmxremote.port=8888
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
This way the source lookup via maven repository is working splendid.
Monday, June 20, 2011
DB Creation using maven hibernate
nice to have is a profile to create the database from the jpa annotations.
We can setup hibernate tools to do that for us in a separate profile.
IT IS IMPORTANT to run the hbm2ddl goal AFTER the compile phase since the information collected from the annotations in the compile are defining the schema in an application solely relying on annotations for config!
mvn -P createDb process-classes
We can setup hibernate tools to do that for us in a separate profile.
IT IS IMPORTANT to run the hbm2ddl goal AFTER the compile phase since the information collected from the annotations in the compile are defining the schema in an application solely relying on annotations for config!
mvn -P createDb process-classes
<profile>
<id>createDb</id>
<!-- CREATE application DATABASE ******************************************************* -->
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<configuration>
<driver>${jdbc.driverClassName}</driver>
<!-- connect to root DB -->
<url>jdbc:mysql://localhost/root</url>
<!-- settingsKey is name for server setting in settings.xml used for authentication -->
<settingsKey>${tomcat.root.server}</settingsKey>
</configuration>
<executions>
<execution>
<id>drop-schemas</id>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<autocommit>true</autocommit>
<sqlCommand> DROP SCHEMA IF EXISTS ${jpa.persistenceUnit}; </sqlCommand>
<onError>continue</onError>
</configuration>
</execution>
<execution>
<id>create-schema</id>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<autocommit>true</autocommit>
<sqlCommand> CREATE SCHEMA IF NOT EXISTS ${jpa.persistenceUnit}; </sqlCommand>
<onError>continue</onError>
</configuration>
</execution>
<execution>
<id>grant-access</id>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<sqlCommand>grant ALL PRIVILEGES ON ${jpa.persistenceUnit}.* TO ${jdbc.username}@'%';</sqlCommand>
<onError>continue</onError>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<executions>
<execution>
<id>createTables</id>
<phase>process-classes</phase>
<goals>
<goal>hbm2ddl</goal>
</goals>
</execution>
</executions>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>jpaconfiguration</implementation>
<outputDirectory>target/hibernate3/sql</outputDirectory>
</component>
</components>
<componentProperties>
<drop>true</drop>
<create>true</create>
<update>true</update>
<export>true</export>
<scan-classes>true</scan-classes>
<persistenceunit>${jpa.persistenceUnit}</persistenceunit>
<outputfilename>${jpa.persistenceUnit}_schema.sql</outputfilename>
</componentProperties>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Maven Hibernate Spring Configuration
its a good idea to have the tests running against another database.
We can setup 2 persistence units in the persistence.xml one for main and one for test.
The spring context in the test classes then plugs into the other jpa unit.
How to set up?
Trying to create a separate & different persistence.xml in the test resources fails as the annotations in the main source tree still needs a persistence.xml in their visible classpath to enable the orm.
Since the test classpath is not visible to the main java classes this has to stay in the main resources!
Working Config
The working solution turned out to be one main/resources/META-INF/persistence.xml containing the 2 persistence units.
We need a separate test/resources/applicationContext.xml to shadow the main resource version to connect the datasource and the entitymanager Beans with the test persistence unit!
Caveats
Dont forget to enable resource filtering for both resource directories to substitute your config values into all relevant places
org.hibernate.ejb.HibernatePersistence
org.hibernate.ejb.HibernatePersistence
We can setup 2 persistence units in the persistence.xml one for main and one for test.
The spring context in the test classes then plugs into the other jpa unit.
How to set up?
Trying to create a separate & different persistence.xml in the test resources fails as the annotations in the main source tree still needs a persistence.xml in their visible classpath to enable the orm.
Since the test classpath is not visible to the main java classes this has to stay in the main resources!
Working Config
The working solution turned out to be one main/resources/META-INF/persistence.xml containing the 2 persistence units.
We need a separate test/resources/applicationContext.xml to shadow the main resource version to connect the datasource and the entitymanager Beans with the test persistence unit!
Caveats
Dont forget to enable resource filtering for both resource directories to substitute your config values into all relevant places
Subscribe to:
Posts (Atom)