DI 샘플 따라해보기

83 views
Skip to first unread message

유동철

unread,
Nov 19, 2009, 12:01:12 AM11/19/09
to OSGi &SpringDM
책 잘보고 있습니다.. 제 환경에서 실행이 안되는 몇개의 샘플이 있어서 고생중입니다. ^^

=========
XP SP3
SpringSource Tool Suite 2.1.0.SR01
==========================

chapter10.hello을 그대로 따라해보고 있습니다.
프로젝트만 Plug-in용으로 따로 만들고, 소스는 예제소스를 그대로 복사했습니다..
실행을 하면 Cannot find class 메세지가 뜨는데, 뭐가 문제일까요?
혹시나 해서 FileSystemXmlApplicationContext 대신 ApplicationContext도 사용해봤지만 오류
가 뜨고
FileSystemXmlApplicationContext appContext =
new FileSystemXmlApplicationContext(new String[] {"spring/
spring.xml"});
ApplicationContext appContext =
new FileSystemXmlApplicationContext(new String[] {"spring/
spring.xml"});

===========================
main대신 Activator를 사용했습니다.
===========================
package chapter10;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.springframework.context.ApplicationContext;
import
org.springframework.context.support.FileSystemXmlApplicationContext;

public class Activator implements BundleActivator {

private Hello hello;

/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start
(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
System.out.println("Hello World!!");

FileSystemXmlApplicationContext appContext =
new FileSystemXmlApplicationContext(new String[] {"spring/
spring.xml"});

System.out.println("Hello World222222!!");

hello = (Hello)appContext.getBean("hello");
System.out.println("Hello World333333!!");
hello.hello("test");
System.out.println("Hello World555555!!");
}

/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop
(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
System.out.println("Goodbye World!!");
}
}

======================
Dependencies에 추가한 내용
======================
org.springframework.beans;version="3.0.0.SNAPSHOT",
org.springframework.context.support;version="3.0.0.SNAPSHOT",
org.springframework.core.io;version="3.0.0.SNAPSHOT"

========
오류내용
========
2009. 11. 19 오후 1:56:31
org.springframework.context.support.AbstractApplicationContext
prepareRefresh
정보: Refreshing
org.springframework.context.support.FileSystemXmlApplicationContext@73305c:
startup date [Thu Nov 19 13:56:31 KST 2009]; root of context hierarchy
2009. 11. 19 오후 1:56:31
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
정보: Loading XML bean definitions from file [D:\dev\springsourcesuite
\sts-2.1.0.SR01\spring\spring.xml]
2009. 11. 19 오후 1:56:31
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons
정보: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@1fc1a6:
defining beans [hello,consolePrinter,errorPrinter]; root of factory
hierarchy
2009. 11. 19 오후 1:56:31
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry
destroySingletons
정보: Destroying singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@1fc1a6:
defining beans [hello,consolePrinter,errorPrinter]; root of factory
hierarchy
org.osgi.framework.BundleException: Exception in
chapter10.Activator.start() of bundle chapter10.hello.
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator
(BundleContextImpl.java:805)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start
(BundleContextImpl.java:754)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker
(BundleHost.java:352)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:280)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:272)
at
org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._start
(FrameworkCommandProvider.java:253)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute
(FrameworkCommandInterpreter.java:155)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand
(FrameworkConsole.java:303)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console
(FrameworkConsole.java:288)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run
(FrameworkConsole.java:224)
at java.lang.Thread.run(Thread.java:619)
Caused by:
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot
find class [chapter10.Hello] for bean with name 'hello' defined in
file [D:\dev\springsourcesuite\sts-2.1.0.SR01\spring\spring.xml];
nested exception is java.lang.ClassNotFoundException: chapter10.Hello
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass
(AbstractBeanFactory.java:1161)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType
(AbstractAutowireCapableBeanFactory.java:556)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean
(AbstractBeanFactory.java:1213)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean
(AbstractBeanFactory.java:789)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons
(DefaultListableBeanFactory.java:495)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization
(AbstractApplicationContext.java:716)
at
org.springframework.context.support.AbstractApplicationContext.refresh
(AbstractApplicationContext.java:383)
at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>
(FileSystemXmlApplicationContext.java:140)
at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>
(FileSystemXmlApplicationContext.java:94)
at chapter10.Activator.start(Activator.java:22)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run
(BundleContextImpl.java:782)
at java.security.AccessController.doPrivileged(Native Method)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator
(BundleContextImpl.java:773)
... 14 more
Caused by: java.lang.ClassNotFoundException: chapter10.Hello
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 org.eclipse.core.runtime.internal.adaptor.ContextFinder.loadClass
(ContextFinder.java:129)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:255)
at
org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass
(AbstractBeanDefinition.java:397)
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass
(AbstractBeanFactory.java:1158)
... 26 more
Nested Exception:
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot
find class [chapter10.Hello] for bean with name 'hello' defined in
file [D:\dev\springsourcesuite\sts-2.1.0.SR01\spring\spring.xml];
nested exception is java.lang.ClassNotFoundException: chapter10.Hello
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass
(AbstractBeanFactory.java:1161)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType
(AbstractAutowireCapableBeanFactory.java:556)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean
(AbstractBeanFactory.java:1213)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean
(AbstractBeanFactory.java:789)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons
(DefaultListableBeanFactory.java:495)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization
(AbstractApplicationContext.java:716)
at
org.springframework.context.support.AbstractApplicationContext.refresh
(AbstractApplicationContext.java:383)
at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>
(FileSystemXmlApplicationContext.java:140)
at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>
(FileSystemXmlApplicationContext.java:94)
at chapter10.Activator.start(Activator.java:22)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run
(BundleContextImpl.java:782)
at java.security.AccessController.doPrivileged(Native Method)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator
(BundleContextImpl.java:773)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start
(BundleContextImpl.java:754)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker
(BundleHost.java:352)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:280)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:272)
at
org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._start
(FrameworkCommandProvider.java:253)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute
(FrameworkCommandInterpreter.java:155)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand
(FrameworkConsole.java:303)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console
(FrameworkConsole.java:288)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run
(FrameworkConsole.java:224)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: chapter10.Hello
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 org.eclipse.core.runtime.internal.adaptor.ContextFinder.loadClass
(ContextFinder.java:129)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:255)
at
org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass
(AbstractBeanDefinition.java:397)
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass
(AbstractBeanFactory.java:1158)
... 26 more
Nested Exception:
java.lang.ClassNotFoundException: chapter10.Hello
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 org.eclipse.core.runtime.internal.adaptor.ContextFinder.loadClass
(ContextFinder.java:129)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:255)
at
org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass
(AbstractBeanDefinition.java:397)
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass
(AbstractBeanFactory.java:1158)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType
(AbstractAutowireCapableBeanFactory.java:556)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean
(AbstractBeanFactory.java:1213)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean
(AbstractBeanFactory.java:789)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons
(DefaultListableBeanFactory.java:495)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization
(AbstractApplicationContext.java:716)
at
org.springframework.context.support.AbstractApplicationContext.refresh
(AbstractApplicationContext.java:383)
at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>
(FileSystemXmlApplicationContext.java:140)
at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>
(FileSystemXmlApplicationContext.java:94)
at chapter10.Activator.start(Activator.java:22)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run
(BundleContextImpl.java:782)
at java.security.AccessController.doPrivileged(Native Method)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator
(BundleContextImpl.java:773)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start
(BundleContextImpl.java:754)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker
(BundleHost.java:352)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:280)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:272)
at
org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._start
(FrameworkCommandProvider.java:253)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute
(FrameworkCommandInterpreter.java:155)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand
(FrameworkConsole.java:303)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console
(FrameworkConsole.java:288)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run
(FrameworkConsole.java:224)
at java.lang.Thread.run(Thread.java:619)
Nested Exception:
java.lang.ClassNotFoundException: chapter10.Hello
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 org.eclipse.core.runtime.internal.adaptor.ContextFinder.loadClass
(ContextFinder.java:129)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:255)
at
org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass
(AbstractBeanDefinition.java:397)
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass
(AbstractBeanFactory.java:1158)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType
(AbstractAutowireCapableBeanFactory.java:556)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean
(AbstractBeanFactory.java:1213)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean
(AbstractBeanFactory.java:789)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons
(DefaultListableBeanFactory.java:495)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization
(AbstractApplicationContext.java:716)
at
org.springframework.context.support.AbstractApplicationContext.refresh
(AbstractApplicationContext.java:383)
at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>
(FileSystemXmlApplicationContext.java:140)
at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>
(FileSystemXmlApplicationContext.java:94)
at chapter10.Activator.start(Activator.java:22)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run
(BundleContextImpl.java:782)
at java.security.AccessController.doPrivileged(Native Method)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator
(BundleContextImpl.java:773)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start
(BundleContextImpl.java:754)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker
(BundleHost.java:352)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:280)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:272)
at
org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._start
(FrameworkCommandProvider.java:253)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute
(FrameworkCommandInterpreter.java:155)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand
(FrameworkConsole.java:303)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console
(FrameworkConsole.java:288)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run
(FrameworkConsole.java:224)
at java.lang.Thread.run(Thread.java:619)
Nested Exception:
java.lang.ClassNotFoundException: chapter10.Hello
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 org.eclipse.core.runtime.internal.adaptor.ContextFinder.loadClass
(ContextFinder.java:129)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:255)
at
org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass
(AbstractBeanDefinition.java:397)
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass
(AbstractBeanFactory.java:1158)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType
(AbstractAutowireCapableBeanFactory.java:556)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean
(AbstractBeanFactory.java:1213)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean
(AbstractBeanFactory.java:789)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons
(DefaultListableBeanFactory.java:495)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization
(AbstractApplicationContext.java:716)
at
org.springframework.context.support.AbstractApplicationContext.refresh
(AbstractApplicationContext.java:383)
at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>
(FileSystemXmlApplicationContext.java:140)
at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>
(FileSystemXmlApplicationContext.java:94)
at chapter10.Activator.start(Activator.java:22)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run
(BundleContextImpl.java:782)
at java.security.AccessController.doPrivileged(Native Method)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator
(BundleContextImpl.java:773)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start
(BundleContextImpl.java:754)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker
(BundleHost.java:352)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:280)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:272)
at
org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._start
(FrameworkCommandProvider.java:253)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute
(FrameworkCommandInterpreter.java:155)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand
(FrameworkConsole.java:303)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console
(FrameworkConsole.java:288)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run
(FrameworkConsole.java:224)
at java.lang.Thread.run(Thread.java:619)
Nested Exception:
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot
find class [chapter10.Hello] for bean with name 'hello' defined in
file [D:\dev\springsourcesuite\sts-2.1.0.SR01\spring\spring.xml];
nested exception is java.lang.ClassNotFoundException: chapter10.Hello
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass
(AbstractBeanFactory.java:1161)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType
(AbstractAutowireCapableBeanFactory.java:556)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean
(AbstractBeanFactory.java:1213)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean
(AbstractBeanFactory.java:789)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons
(DefaultListableBeanFactory.java:495)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization
(AbstractApplicationContext.java:716)
at
org.springframework.context.support.AbstractApplicationContext.refresh
(AbstractApplicationContext.java:383)
at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>
(FileSystemXmlApplicationContext.java:140)
at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>
(FileSystemXmlApplicationContext.java:94)
at chapter10.Activator.start(Activator.java:22)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run
(BundleContextImpl.java:782)
at java.security.AccessController.doPrivileged(Native Method)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator
(BundleContextImpl.java:773)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start
(BundleContextImpl.java:754)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker
(BundleHost.java:352)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:280)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:272)
at
org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._start
(FrameworkCommandProvider.java:253)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute
(FrameworkCommandInterpreter.java:155)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand
(FrameworkConsole.java:303)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console
(FrameworkConsole.java:288)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run
(FrameworkConsole.java:224)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: chapter10.Hello
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 org.eclipse.core.runtime.internal.adaptor.ContextFinder.loadClass
(ContextFinder.java:129)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:255)
at
org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass
(AbstractBeanDefinition.java:397)
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass
(AbstractBeanFactory.java:1158)
... 26 more
Nested Exception:
java.lang.ClassNotFoundException: chapter10.Hello
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 org.eclipse.core.runtime.internal.adaptor.ContextFinder.loadClass
(ContextFinder.java:129)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:255)
at
org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass
(AbstractBeanDefinition.java:397)
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass
(AbstractBeanFactory.java:1158)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType
(AbstractAutowireCapableBeanFactory.java:556)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean
(AbstractBeanFactory.java:1213)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean
(AbstractBeanFactory.java:789)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons
(DefaultListableBeanFactory.java:495)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization
(AbstractApplicationContext.java:716)
at
org.springframework.context.support.AbstractApplicationContext.refresh
(AbstractApplicationContext.java:383)
at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>
(FileSystemXmlApplicationContext.java:140)
at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>
(FileSystemXmlApplicationContext.java:94)
at chapter10.Activator.start(Activator.java:22)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run
(BundleContextImpl.java:782)
at java.security.AccessController.doPrivileged(Native Method)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator
(BundleContextImpl.java:773)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start
(BundleContextImpl.java:754)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker
(BundleHost.java:352)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:280)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:272)
at
org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._start
(FrameworkCommandProvider.java:253)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute
(FrameworkCommandInterpreter.java:155)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand
(FrameworkConsole.java:303)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console
(FrameworkConsole.java:288)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run
(FrameworkConsole.java:224)
at java.lang.Thread.run(Thread.java:619)
Nested Exception:
java.lang.ClassNotFoundException: chapter10.Hello
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 org.eclipse.core.runtime.internal.adaptor.ContextFinder.loadClass
(ContextFinder.java:129)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:255)
at
org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass
(AbstractBeanDefinition.java:397)
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass
(AbstractBeanFactory.java:1158)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType
(AbstractAutowireCapableBeanFactory.java:556)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean
(AbstractBeanFactory.java:1213)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean
(AbstractBeanFactory.java:789)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons
(DefaultListableBeanFactory.java:495)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization
(AbstractApplicationContext.java:716)
at
org.springframework.context.support.AbstractApplicationContext.refresh
(AbstractApplicationContext.java:383)
at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>
(FileSystemXmlApplicationContext.java:140)
at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>
(FileSystemXmlApplicationContext.java:94)
at chapter10.Activator.start(Activator.java:22)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run
(BundleContextImpl.java:782)
at java.security.AccessController.doPrivileged(Native Method)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator
(BundleContextImpl.java:773)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start
(BundleContextImpl.java:754)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker
(BundleHost.java:352)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:280)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:272)
at
org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._start
(FrameworkCommandProvider.java:253)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute
(FrameworkCommandInterpreter.java:155)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand
(FrameworkConsole.java:303)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console
(FrameworkConsole.java:288)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run
(FrameworkConsole.java:224)
at java.lang.Thread.run(Thread.java:619)
Nested Exception:
java.lang.ClassNotFoundException: chapter10.Hello
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 org.eclipse.core.runtime.internal.adaptor.ContextFinder.loadClass
(ContextFinder.java:129)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:255)
at
org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass
(AbstractBeanDefinition.java:397)
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass
(AbstractBeanFactory.java:1158)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType
(AbstractAutowireCapableBeanFactory.java:556)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean
(AbstractBeanFactory.java:1213)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean
(AbstractBeanFactory.java:789)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons
(DefaultListableBeanFactory.java:495)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization
(AbstractApplicationContext.java:716)
at
org.springframework.context.support.AbstractApplicationContext.refresh
(AbstractApplicationContext.java:383)
at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>
(FileSystemXmlApplicationContext.java:140)
at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>
(FileSystemXmlApplicationContext.java:94)
at chapter10.Activator.start(Activator.java:22)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run
(BundleContextImpl.java:782)
at java.security.AccessController.doPrivileged(Native Method)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator
(BundleContextImpl.java:773)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start
(BundleContextImpl.java:754)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker
(BundleHost.java:352)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:280)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:272)
at
org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._start
(FrameworkCommandProvider.java:253)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute
(FrameworkCommandInterpreter.java:155)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand
(FrameworkConsole.java:303)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console
(FrameworkConsole.java:288)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run
(FrameworkConsole.java:224)
at java.lang.Thread.run(Thread.java:619)

xguru

unread,
Nov 19, 2009, 12:53:44 AM11/19/09
to OSGi &SpringDM
11장에 있는 기본 Spring Framework 예제를 그냥 OSGi 형태로 바꾸신듯 한데요.

OSGi 환경에서 스프링 컨텍스트를 SpringDM 에 의해 만들지 않고
Spring Framework 에 있는 Context로 직접 만들면 클래스로더에서 클래스를 잘 못찾게 됩니다.

지금 테스트 하신 소스에서도 spring/spring.xml 파일 자체를 못찾아서
D:\dev\springsourcesuite\sts-2.1.0.SR01\spring\spring.xml
에 직접 복사하신 듯 하네요.

OSGi 는 각 번들당 클래스로더가 따로 동작하기 때문에..
현재 개발환경인 SpringSourceSuite 의 클래스패스인 D:\dev\springsourcesuite
\sts-2.1.0.SR01 만 인식하기에
프로젝트 안에 들어있는 chapter10.hello 클래스를 못찾게 됩니다.

SpringDM 을 이용하지 않고 꼭 SpringFramework 의 컨텍스트를 이용하셔야할 이유가 있으신 건가요 ?
그게 아니시라면 11장 뒤쪽에 있는것 처럼 SpringDM 를 사용하셔서 Context 를 생성하시는게 좋을듯 합니다.

유동철

unread,
Nov 19, 2009, 12:59:02 AM11/19/09
to OSGi &SpringDM
답변 감사드립니다..

spring.xml을 직접 복사한거는 맞습니다.. ^^ 하지만 파일을 못찾은건 아니구요...
파일을 못 찾을 경우 FileNotFoundException이 발생하더군요..

현재 이것저것 테스트를 하는 도중이라... ^^

자답을 한다면 1번 항목을 2번으로 수정해서 실행하면 클래스를 못 찾는 경우는 사라지네요.. 또 다른 문제가 나오기는 하지만
^^
1. FileSystemXmlApplicationContext appContext = new
FileSystemXmlApplicationContext(new String[] {"spring/spring.xml"});
2. FileSystemXmlApplicationContext appContext = new
FileSystemXmlApplicationContext(new String[] {"classpath*:spring/
spring.xml"});

혹시 1번과 2번에 대한 차이점을 설명 부탁드려도 될지 모르겠습니다... 여러 자료를 찾고는 있지만 이해하기가 쉽지 않네요

xguru

unread,
Nov 19, 2009, 1:12:44 AM11/19/09
to OSGi &SpringDM
앞에 classpath* 를 붙이면 모든 클래스패스를 다 찾게 됩니다.
실제로 내부에서 ClassLoader.getResources() 를 호출해서 전체를 뒤지게 된다는데
OSGi 의 Bundle 내부상에서는 클래스로더 동작이 조금 달라서 확실한 내부구현까지는 모르겠네요.

해당 자료는 OSGi 쪽보다는 SpringFramework 자체 문서에 내용이 많을꺼 같습니다 ^^;

Reply all
Reply to author
Forward
0 new messages