views:

374

answers:

1

This is after the last unsuccessful run of my program. I notice that the file size has changed and I can no longer run the Java class for my program:

root@dbs01 ~
$ ls -l lifecycle-0.1-SNAPSHOT.jar
-rw-r--r--   1 root     root     24740243 Jun  4 20:48 lifecycle-0.1-SNAPSHOT.jar

This is after I copy the new copy of the original JAR file:

root@dbs01 ~
$ ls -l lifecycle-0.1-SNAPSHOT.jar
-rw-r--r--   1 root     root     24833475 Jun  4 20:55 lifecycle-0.1-SNAPSHOT.jar

I then run the Java command:

root@dbs01 ~
$ java -cp lifecycle-0.1-SNAPSHOT.jar com.abc.lifecycle.cli.LifecycleManagerCli -dm web 0001 lm2-dom0.sfbay.abc.com ZONE /path/to/bits
Jun 4, 2009 8:55:51 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@186c6b2: display name [org.springframework.context.support.ClassPathXmlApplicationContext@186c6b2]; startup date [Thu Jun 04 20:55:51 GMT+00:00 2009]; root of context hierarchy
Jun 4, 2009 8:55:51 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [lifecycle_lite.xml]
Jun 4, 2009 8:55:51 PM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@186c6b2]: org.springframework.beans.factory.support.DefaultListableBeanFactory@88e2dd
Jun 4, 2009 8:55:51 PM org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
INFO: Loading properties file from class path resource [lifecycle.properties]
Jun 4, 2009 8:55:51 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@88e2dd: defining beans [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,com.abc.lifecycle.util.LoggingConfigurer#0,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,txAdvice,lifecycleOperations,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,dataSource,hibernateSessionFactory,moduleDefinitionDao,moduleHostDao,moduleInstanceDao,physicalHostDao,serviceDefinitionDao,serviceInstanceDao,numericOffsetDao,virtualHostDao,broker,jmsConnectionFactory,lifecycleMessageQueue,lifecycleMessageXmlConverter,lifecycleMessageListener,lifecycleMessageListenerContainer,jmsTemplate,lifecycleProcessor,statusChecker,lifecycleComponentBuilder,lifecycleManagerInitializer,lifecycleManagerCli]; root of factory hierarchy
Hibernate:
    insert
    into
        SERVICE_INSTANCE
        (CREATED_DATE, OPTIMISTIC_LOCKING_VERSION, UPDATED_DATE, MODULE_INSTANCE_ID, serviceDefinition_ENTITY_ID)
    values
        (?, ?, ?, ?, ?)
Hibernate:
    delete
    from
        NUMERIC_OFFSET
    where
        ENTITY_ID=?
        and OPTIMISTIC_LOCKING_VERSION=?
Exception in thread "lifecycleMessageListenerContainer-1" java.lang.NoClassDefFoundError: org/springframework/jms/support/JmsUtils
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.clearResources(DefaultMessageListenerContainer.java:1024)
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:887)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: org.springframework.jms.support.JmsUtils
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        ... 3 more

At this point i kill it with Ctrl-C:

^CException in thread "ActiveMQ ShutdownHook" java.lang.NoClassDefFoundError: org/apache/activemq/broker/TransportConnection$3
        at org.apache.activemq.broker.TransportConnection.stopAsync(TransportConnection.java:920)
        at org.apache.activemq.broker.TransportConnection.stop(TransportConnection.java:902)
        at org.apache.activemq.util.ServiceStopper.stop(ServiceStopper.java:41)
        at org.apache.activemq.broker.TransportConnector.stop(TransportConnector.java:270)
        at org.apache.activemq.util.ServiceSupport.dispose(ServiceSupport.java:43)
        at org.apache.activemq.transport.vm.VMTransportFactory.stopped(VMTransportFactory.java:226)
        at org.apache.activemq.broker.BrokerService.stop(BrokerService.java:518)
        at org.apache.activemq.broker.BrokerService.containerShutdown(BrokerService.java:1754)
        at org.apache.activemq.broker.BrokerService$4.run(BrokerService.java:1732)
Caused by: java.lang.ClassNotFoundException: org.apache.activemq.broker.TransportConnection$3
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        ... 9 more

Then you can see that the JAR file has been changed:

root@dbs01 ~
$ ls -l lifecycle-0.1-SNAPSHOT.jar
-rw-r--r--   1 root     root     24740243 Jun  4 20:56 lifecycle-0.1-SNAPSHOT.jar

I can find the JmsUtils class and the ActiveMQ TransportConnection class it is complaining about in my Maven repository, what else could I try?

root@dbs01 ~
$ jar tf lifecycle-0.1-SNAPSHOT.jar | grep JmsUtils
org/springframework/jms/support/JmsUtils.class
root@dbs01 ~
$ jar tf lifecycle-0.1-SNAPSHOT.jar | grep TransportConnection                                               
org/apache/activemq/broker/MapTransportConnectionStateRegister.class
org/apache/activemq/broker/SingleTransportConnectionStateRegister.class
org/apache/activemq/broker/TransportConnection$1.class
org/apache/activemq/broker/TransportConnection$2.class
org/apache/activemq/broker/TransportConnection$3.class
org/apache/activemq/broker/TransportConnection.class
org/apache/activemq/broker/TransportConnectionState.class
org/apache/activemq/broker/TransportConnectionStateRegister.class
org/apache/activemq/broker/jmx/ManagedTransportConnection.class

What can be modifying the JAR file's state during execution? What if I attach a debugger from a remote machine -- should this have any effect (I assume no)?

Thanks in advance.

--James

+6  A: 

First thing to try is change the mode on your jar file to 444 or even 400, and see what blows up.

Java, the JRE itself, shouldn't be modifying the jar file at all; it only needs read access to it. The most probable case is that something, somewhere, mistakenly is getting the jar file path for a data file path, God alone knows how.

Make the file read-only, and you should get an exception where the access (or at least the open) occurs.

Charlie Martin
Same thing happens when I make the file 444 or 400 permissions. What gives -- how can the file be being written to when it's read only?
James Adams
Don't run the application as root.
Robert Munteanu