Wednesday, December 14, 2011

oscommerce & wordpress

Goal would be to plug all product data straight into the wordpress post system

WHY

all wordpress themeing could be applied to the shop without any coding!

oscommerce & wordpress

  1. start using oscommerce plugin:
    1. it provides access to the osc database -> ok
    2. catalog & product data are listed with inline HTML -> unflexible
  2. develop  a jquery based viewer on the product data -> funky
  3. use injected JSON for initial data download to delegate rendering on javascript completely -> fast
  4. use jquery templates to split design from logic -> nice
  5. add templates to PHP class osc_products using inheritance -> neat
  6. use osc shop for shopping cart -> no existing classes can be used
    1. use the application_top for setup
    2. remove all output modules
    3. return the oscid only to reference the cart again
    4. use ajax based shopping cart in wordpress

Sunday, June 26, 2011

nmake postbuild.mak visual studio command failure backslash missing trailing space

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\

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:

  1. Unplug all external harddrives! 
  2. Try LAST KNOWN GOOD Configuration (boot -> F8)
  3. If that does not boot do a CHKDSK of the Vista drive
  4. 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......

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.

The options have to be added one per line to work!

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


<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