... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)


BEA WebLogic 8.1 vs license.bea

If you manually move your BEA installation directory somewhere else, the WebLogic server will fail to start with a license exception.  Further digging will reveal that it is looking for the license file, license.bea, in the old directory. 

WebLogic 8.1 seems to use a hard-coded pathname to the license file.  I could not find where it was hard-coded -- it was not in any of the generated start-up scripts.  Their installer must put it into a JAR somewhere, or maybe even compile up a class file that contains it.  There is, however, a work-around.  Add the following system property to the command that starts the WLS server:


Of course, to have a hope of this working, you must edit the various BEA scripts to point to the new directory as well (or, a novel thought, to use relative pathnames).


Windows BAT vs. Spaces in Filenames

The BAT construct FOR %%I in (%~dp0\somefile.txt) will fail if the current directory has a space in the fully qualified path.  It will interpret the path as a list of space-separated paths instead.  The usual solution, to put the path in quotes, will not work in this context since FOR treats a quoted string as a literal line to be processed instead of as a single filename.

The workaround is to use %~dps0 instead of %~dp0.  Thus, short 8.3 filenames will be used instead, eliminating the problem.


Splitting a Cross-product in Mathematica

In Mathematica, the following expression will split a relational cross-product back into its component parts (assuming that common keys are sorted together):

SplitCrossProduct[keys_, list_] :=
    #[[1, keys]],
    #[[Complement[Range[1, Length[list]], keys]]] & /@ #
  }& /@ Split[list, SameQ[#1[[keys]], #2[[keys]]] &]


Graph Gear

Graph Gear is a Flash plug-in that renders interactive graphs (of the node and arc variety).



The Joda Time project has been proposed as the basis for the JSR-310 Date and Time API (also see the JCP page).


JAMWiki is an implementation of MediaWiki in Java.


Controlling Java Visibility in Eclipse

If you configure the Eclipse Java compiler to issue warnings for missing Javadoc comments on non-overridden public members, it provides feedback that encourages one to minimize visibility declarations (e.g. favour private over package over protected over public visibility).  It is easier to downgrade a member from public to package visibility then to write an inane comment.


Greenshot is a nice little open-source, .NET utility enhances the usual Windows PRINT SCREEN capability so that you can take screenshots of screen regions.  You can also perform simple markup of the captured images.

Hibernate 3.3: Lazy Collections vs. Multiple Sessions

Using Hibernate, there is a problem with lazy-loaded collections in detached objects.  Consider this sequence of events.  In one session, load an object with a lazy-loaded collection property.  Close the session and open a new session.  Associate the object with the new session.  Access an element of the collection (e.g. myCollection.first()).  The following exception occurs:

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: MyEntity.myCollection, no session or session was closed
	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
	at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
	at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
	at org.hibernate.collection.PersistentSortedSet.first(PersistentSortedSet.java:93)

A quick trip in the debugger shows that the session is closed.  Apparently, attaching an entity to a session does not attach its lazy collection properties.  So, how does one do that?  Well, you could try Hibernate.initialize(myCollection).  But then you would get:

org.hibernate.HibernateException: disconnected session
	at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:452)
	at org.hibernate.Hibernate.initialize(Hibernate.java:309)

Perhaps mySession.lock(myCollection, LockMode.NONE)?  Nope, this gives:

org.hibernate.MappingException: Unknown entity: org.hibernate.collection.PersistentSortedSet
	at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550)
	at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1338)
	at org.hibernate.event.def.DefaultLockEventListener.onLock(DefaultLockEventListener.java:50)
	at org.hibernate.impl.SessionImpl.fireLock(SessionImpl.java:584)
	at org.hibernate.impl.SessionImpl.lock(SessionImpl.java:576)

Okay, surely this will work:

PersistentCollection collection = (PersistentCollection) myCollection;
collection.setCurrentSession((SessionImplementor) mySession);


org.hibernate.HibernateException: collection was evicted
	at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:38)
	at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
	at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:454)
	at org.hibernate.Hibernate.initialize(Hibernate.java:309)

onInitializeCollection is calling PersistenceContext.getCollectionEntry(collection) and coming up empty -- the new session has no clue about the collection.

I'm stumped.  I can't figure out how to bring an uninitialized collection into a new session.  It looks like you must initialize a collection in the session that first accesses it.

Blog Archive