On Nov 10, 2009, at 8:46 AM, bhardage wrote:



David Sean Taylor-3 wrote:

It appears that the Jetspeed preferences factory is not overriding
Java's default preferences factory. We override the Java preferences
during the Spring container construction, see WEB-INF/assembly/
prefs.xml:

   <bean id="java.util.prefs.PreferencesFactory"
class="org.apache.jetspeed.prefs.impl.PreferencesFactoryImpl"
         name="prefsFactory" depends-on="preloadPrefsProvider" init-
method="init" destroy-method="destroy">
        <!-- dummy constructor argument to distinguish it from the
default constructor invoked by the Java Preferences itself -->
        <constructor-arg><value>1</value></constructor-arg>
        <property name="prefsProvider">
            <ref bean="prefsProvider" />
        </property>
    </bean>

and here is the constructor:

 public PreferencesFactoryImpl(int dummy)
    {
        System.setProperty("java.util.prefs.PreferencesFactory",
getClass()
                .getName());
    }

Setting the java.util.prefs.PreferencesFactory system property
overrides the default Java preferences implementation, which stores
preferences in the Windows registry, to using the Jetspeed Preferences
provider, storing preferences in the database

The problem is, something is going wrong in the sequence of setting
this property. My guess would be one of the following:

1 * some other code in your application is accessing preferences
before our Spring container, maybe in a static initializer. Could be
in your command line class path, Tomcat's class loader, or a number of different places. Try to isolate Jetspeed as much as possible, using a
clean Tomcat installation, no custom web applications, and an empty
class loader when starting Tomcat

2 * somehow the preferences factory assembly has been removed or
commented out

If this is a fresh installation, then my guess would be #1
If its a Jetspeed that you are upgrading, then something might have
gone wrong in the upgrade procedure, and the prefs.xml might not be
correct

NOTE: for version 2.2.0 and higher, the above does not apply since we
no longer use the Java Preferences API


One difference I do notice is in the way the bean is defined. My definition:

 <bean id="java.util.prefs.PreferencesFactory"
       class="org.apache.jetspeed.prefs.impl.PreferencesFactoryImpl"
       name="prefsFactory"
       init-method="init">
   <property name="prefsProvider">
     <ref bean="prefsProvider" />
   </property>
 </bean>

The constructor arg is missing, and there is no constructor which takes an
argument in the PreferencesFactoryImpl class. I don't know if this is
relevant, but it is a difference.

I hesitate in asking about this because it seems like a simple spring/java problem, but I attempted to add this constructor with some errors. I just
added the constructor-arg in "prefs.xml" and modified
"WEB-INF/lib/jetspeed-prefs-2.0.jar" (which I assume is where it's pulling
the class from) by adding the constructor you mentioned to the
PreferencesFactoryImpl class. However, for some reason it's not recognizing the new constructor; I get a bean exception when Jetspeed is starting up:

I see you are on version 2.0. I gave you the constructor for version 2.1.3. I was under the impression you were using version 2.1.3, sorry. Also, you said you are using Java version 1.6, but you were using version 1.5. Were the preferences working with Java 1.5? Perhaps there is a problem with Java 1.6 and version 2.0 of Jetspeed (I haven't used 2.0 in a long time now....)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to