.Net환경에서만 개발하다보니 Java 및 OSGi쪽에는 거의 문외한 입니다.
초보 질문을 드려서 미안합니다 ^^;
이거 가지고 2틀째 헤매고 있습니다. ㅠ.ㅠ
testclass.xml은 작업폴더에 강제로 넣어놨습니다.
==========
테스트환경
==========
Window XP, STS2.1.0RC1, JDK1.6.0
=========
문제점
=========
STS2.1.0을 설치만 하고 바로 프로젝트 작성해서 돌려보고 있습니다.. 다른 작업 일체 없습니다.
아래의 오류사항이 실행시에 TestClass.class파일을 못 찾아서 생기는것 같은 느낌이 많이드는데
잘못 생각하고 있는지 모르겠네요(ClassPath를 어떻게 줘야되는지 감이 안옵니다)
==============
testclass.xml 내용 (default-lazy-init을 빼도 같은 오류가 납니다)
==============
<?xml version="1.0" encoding="UTF-8"?>
<beans default-lazy-init="true"
xmlns="
http://www.springframework.org/schema/beans"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="testclass" class="testclass.TestClass" />
</beans>
아래의 내용으로 안되서 위의 내용으로 해봤습니다
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://
www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="testclass" class="testclass.TestClass" />
</beans>
===========
오류
===========
osgi> Hello World!!
testclass
2009. 11. 20 오후 4:20:52
org.springframework.context.support.AbstractApplicationContext
prepareRefresh
정보: Refreshing
org.springframework.context.support.FileSystemXmlApplicationContext@e1d5ea:
startup date [Fri Nov 20 16:20:52 KST 2009]; root of context hierarchy
2009. 11. 20 오후 4:20:52
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
정보: Loading XML bean definitions from file [E:\source
\suite2\testclass.xml]
2009. 11. 20 오후 4:20:53
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons
정보: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@1aae94f:
defining beans [testclass]; root of factory hierarchy
111111111111111111111
Bean 0 : testclass
Cannot find class [testclass.TestClass] for bean with name 'testclass'
defined in file [E:\source\suite2\testclass.xml]; nested exception is
java.lang.ClassNotFoundException: testclass.TestClass
Persistence bundle starting...
ProviderTracker: New service detected...
ProviderTracker: Added service
org.eclipse.persistence.jpa.osgi.PersistenceProviderOSGi
Persistence bundle started.
==========
소스
==========
package testclass;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
private TestClass testclass_ = new TestClass();
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start
(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
System.out.println("Hello World!!");
testclass_.outmsg("testclass");
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop
(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
System.out.println("Goodbye World!!");
}
}
//-----------------------------------------------------------
package testclass;
import org.springframework.context.ApplicationContext;
import
org.springframework.context.support.ClassPathXmlApplicationContext;
import
org.springframework.context.support.FileSystemXmlApplicationContext;
public class TestClass {
public void outmsg(String msg) {
System.out.println(msg);
String filename = msg + ".xml";
try {
//ApplicationContext ctx = new FileSystemXmlApplicationContext
(filename);
FileSystemXmlApplicationContext ctx = new
FileSystemXmlApplicationContext(filename);
//ApplicationContext ctx = new ClassPathXmlApplicationContext
(filename);
System.out.println("111111111111111111111");
String[] arrayBean = ctx.getBeanDefinitionNames();
System.out.println("Bean 0 : " + arrayBean[0].toString());
TestClass testclass_ = (TestClass)ctx.getBean(arrayBean[0]);
System.out.println("22222222222222222222222");
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
}
========
Import 내용
========
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Testclass
Bundle-SymbolicName: testclass
Bundle-Version: 1.0.0
Bundle-Activator: testclass.Activator
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.osgi.framework;version="1.3.0",
org.springframework.beans;version="3.0.0.SNAPSHOT",
org.springframework.context;version="3.0.0.SNAPSHOT",
org.springframework.context.support;version="3.0.0.SNAPSHOT",
org.springframework.core.io;version="3.0.0.SNAPSHOT"
===============
Build Property내용
===============
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.