Mark Derricutt's Disturbing Thoughts

SpringFramework - Classpath issues

posted Tuesday, 28 September 2004
If it's one thing that drives me insane with java development its the classpath. I'm starting to look at the Spring Framework...
  • I've copied spring.jar to my WEB-INF/lib
  • I've edited my struts-config.xml to define the context plugin
  • I've modified one action to use DelegatingActionProxy
  • I've defined one bean in action-servlet.xml to match the action
Without setting doing any dependency injection or anything fancy, I deploy my application and see that it still runs, and that Spring is has hapilly delegated to my action and everything works as it did. So now I want to inject the reference to my EJB and add the following bean definition:
<bean id="mailLogSearch" class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean">
  <property name="jndiName"><value>bulletinmail/MailLogSearch</value></property>
  <property name="businessInterface"><value>com.bulletinwireless.bulletinmail.ejb.MailLogSearch</value></property>
</bean>
Now I restart the application server and blam:
15:29:47,162 INFO  [XmlBeanDefinitionReader] Loading XML bean definitions from resource
    [/WEB-INF/action-servlet.xml] of ServletContext
15:29:47,332 ERROR [ContextLoaderPlugIn] Context initialization failed
    org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name
    'mailLogSearch' defined in resource [/WEB-INF/action-servlet.xml] of ServletContext: Bean class 
[org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean] not found;
    nested exception is java.lang.ClassNotFoundException: 
org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean
java.lang.ClassNotFoundException: org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean
        at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:219)
        at org.springframework.beans.factory.support.BeanDefinitionReaderUtils.createBeanDefinition(
            BeanDefinitionReaderUtils.java:50)
The jar's in place, the class is there... if I reference other classes from the same jar in action-servlet.xml they're found, but not this. And so ends my first day of spring...

Any one know whats up? Note: I downloaded spring-framework-1.1-with-dependencies.zip, deploying under JBoss 3.2.5, on Fedora Core 2.

links: digg this    del.icio.us    technorati    reddit




1. a reader left...
Wednesday, 29 September 2004 2:20 am

I can't say for sure without seeing everything you've deployed, but...There's more stuff to be moved over than just spring.jar. The spring.jar file has only the Spring stuff in it. But that Spring stuff depends on other things. At minimum, you're going to need commons-logging and (I think) log4j. Given that it's complaining about LocalStatelessSessionProxyFactoryBean, I'd also guess that

Craig Walls


2. a reader left...
Wednesday, 29 September 2004 2:26 am

Picking up where I left off before accidentally hitting the "add comment" button...

I'd guess you'd also need the aopalliance JAR. And there could still be some other stuff. That's why you have the "with dependencies" distribution so that you can get all of that other stuff from the lib directory.

Again...I don't know what you're deployment looks like, so you may already have everything in place and this is some other problem.

Craig Walls


3. Mark Derricutt left...
Thursday, 30 September 2004 11:15 am

Adding the aopalliance.jar did the trick... Now it's time to start enjoying the fact the suns coming out and Spring is here...