2012年11月6日火曜日

Spring-Axis2連携 on OSGi 其の2(完結)

其の1の続き

java.lang.ClassNotFoundException: org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier
 
のExceptionが出ていたので、SpringServletContextObjectSupplierクラスを参照したけど、よくわからん。
なので、親クラスのSpringObjectSupplierをみると、public static Object createServiceObject(final AxisService service) な
メソッドがあるではないか!
 
そして、このメソッド見たら、こんな文字が!(下の赤字) 
 
  /**
     * Create a service object for a given service. The method first looks for
     * the {@link Constants#SERVICE_OBJECT_SUPPLIER} service parameter and if
     * this parameter is present, it will use the specified class to create the
     * service object. If the parameter is not present, it will create an
     * instance of the class specified by the {@link Constants#SERVICE_CLASS}
     * parameter.
     *
     * @param service
     *            the service
     * @return The service object or <code>null</code> if neither the
     *         {@link Constants#SERVICE_OBJECT_SUPPLIER} nor the
     *         {@link Constants#SERVICE_CLASS} parameter was found on the
     *         service, i.e. if the service doesn't specify how to create a
     *         service object. If the return value is non null, it will always
     *         be a newly created instance.
     * @throws AxisFault
     *             if an error occurred while attempting to instantiate the
     *             service object
     */
 
つまり、他のサイトなどで参考にしていたServiceObjectSupplierの指定を外せば、
ServiceClassのインスタンスを生成してくれると!
そして、ServiceClassはwsdlでservices.xmlを生成した際に記述済み!

という事で、ServiceObjectSupplierの記載をservices.xmlからコメントアウトすると、
今度は以下のException
 
[ERROR][11/06/2012 20:14:26:883] loader constraint violation: loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) previously initiated loading for a different type with name "javax/activation/DataHandler" (org.apache.axis2.transport.http.AxisServlet) 
 java.lang.LinkageError: loader constraint violation: loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) previously initiated loading for a different type with name "javax/activation/DataHandler"
 at java.lang.Class.getDeclaredFields0(Native Method)
 at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
 at java.lang.Class.getDeclaredFields(Class.java:1743)
...
 
何やら、javax/activation/DataHandlerが怪しいなー、という事で、javax.actionvationを文字列検索して
ヒットした、com.springsource.javax.activationバンドルをRequired Plug-insに追加して再起動!

目的のメソッドにデータが受信できた!!!


※このBundleを起動する前に、WebServerBundle(Jetty等)を起動しておかないと、Serviceの登録ができていないため、Serviceがちゃんと動きません。

0 件のコメント:

コメントを投稿