Hi Matteo,

I think that you haven't yet seen my previous e-mail :)

No, you should remove com.mysql.jdbc from Import-Package definition.

Now, you have a ClassCastException. As you have add all maven dependencies in your bundle, maybe you have imported Xerces from your dependencies. Could you check that ?

In all case, it's better to add only your requirement into the bundle classpath (not all dependencies). So try defining only MySQL connector into the bundle classpath (not all maven dependencies).

Regards
JB

Matteo Redaelli wrote:
Do I have to keep " com.mysql.jdbc" inside "<Import-Package>"?

If I remove it, my bundle become active but failed

[ 306] [Active     ] [Failed ] [   60] A CXF WSDL First OSGi Project
(1.0.0.SNAPSHOT)

with the followin log/d


10:58:18,497 | ERROR | xtenderThread-80 | OsgiBundleXmlApplicationContext  |
gatedExecutionApplicationContext  366 | Post refresh error
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'org.apache.cxf.wsdl.WSDLManager' defined in OSGi
resource[classpath:META-INF/cxf/cxf.xml|bnd.id=306|bnd.sym=test-wsdl-first-osgi]:
Instantiation of bean failed; nested exception is
org.springframework.beans.BeanInstantiationException: Could not instantiate
bean class [org.apache.cxf.wsdl11.WSDLManagerImpl]: Constructor threw
exception; nested exception is java.lang.ClassCastException:
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:883)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:839)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
        at java.security.AccessController.doPrivileged(Native Method)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
        at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
        at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:68)
        at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:343)
        at
org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
        at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:308)
        at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:138)
        at java.lang.Thread.run(Thread.java:595)
Caused by: org.springframework.beans.BeanInstantiationException: Could not
instantiate bean class [org.apache.cxf.wsdl11.WSDLManagerImpl]: Constructor
threw exception; nested exception is java.lang.ClassCastException:
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
        at 
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:115)
        at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:877)
        ... 18 more
Caused by: java.lang.ClassCastException:
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
        at
javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:98)
        at java.util.XMLUtils.getLoadingDoc(XMLUtils.java:75)
        at java.util.XMLUtils.load(XMLUtils.java:57)
        at java.util.Properties.loadFromXML(Properties.java:701)
        at
org.apache.cxf.common.util.PropertiesLoaderUtils.loadAllProperties(PropertiesLoaderUtils.java:71)
        at
org.apache.cxf.wsdl11.WSDLManagerImpl.registerInitialExtensions(WSDLManagerImpl.java:224)
        at
org.apache.cxf.wsdl11.WSDLManagerImpl.registerInitialExtensions(WSDLManagerImpl.java:219)
        at 
org.apache.cxf.wsdl11.WSDLManagerImpl.<init>(WSDLManagerImpl.java:109)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
        at 
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100)
        ... 20 more



Matteo Redaelli wrote:
Many thanks for your usefull suggestions. I like very much the possibility
to use maven dependences (as in jbi packaging)

BUT i doesn't work. can you do it starting from my zip sample?

I changed my pom.xml adding (initially only one and finally all your
suggestions)
                <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>5.0.8</version>
                </dependency>
                ...
                    <instructions>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
                        <Bundle-ClassPath>
                            .,{maven-dependencies}
                        </Bundle-ClassPath>
<Include-Resource>{maven-resources}</Include-Resource> <Embed-Dependency>mysql-connector-java:scope=runtime|compile</Embed-Dependency> <Import-Package>
                            javax.jws,
                            javax.wsdl,
                            javax.xml.bind,
                            javax.xml.bind.annotation,
                                        javax.xml.namespace,
                                        javax.xml.ws,
                                        META-INF.cxf,
                            META-INF.cxf.osgi,
                            org.apache.cxf.bus,
                            org.apache.cxf.bus.spring,
                            org.apache.cxf.bus.resource,
                            org.apache.cxf.configuration.spring,
                            org.apache.cxf.resource,
                            org.apache.cxf.jaxws,
                            org.apache.servicemix.cxf.transport.http_osgi,
                            org.springframework.beans.factory.config,
                            org.springframework.jdbc.datasource,
                            com.mysql.jdbc, *

then
  mvn clean install

But I get
 | Deploying:
/usr/local/apache-servicemix-4.0.0/deploy/test-wsdl-first-osgi-1.0-SNAPSHOT.jar
10:39:46,788 | WARN | Timer-1 | FileMonitor | x.kernel.filemonitor.FileMonitor 552 | Failed to start bundle:
test-wsdl-first-osgi [305]. Reason: org.osgi.framework.BundleException:
Unresolved constraint in bundle 305: package; (package=com.mysql.jdbc)
org.osgi.framework.BundleException: Unresolved constraint in bundle 305:
package; (package=com.mysql.jdbc)
        at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3059)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1439)
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:770)
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:751)
        at
org.apache.servicemix.kernel.filemonitor.FileMonitor.refreshPackagesAndStartOrUpdateBundles(FileMonitor.java:549)
        at
org.apache.servicemix.kernel.filemonitor.FileMonitor.onFilesChanged(FileMonitor.java:299)
        at
org.apache.servicemix.kernel.filemonitor.FileMonitor$1.filesChanged(FileMonitor.java:151)
        at
org.apache.servicemix.kernel.filemonitor.Scanner.reportBulkChanges(Scanner.java:431)
        at
org.apache.servicemix.kernel.filemonitor.Scanner.reportDifferences(Scanner.java:327)
        at
org.apache.servicemix.kernel.filemonitor.Scanner.scan(Scanner.java:261)
        at
org.apache.servicemix.kernel.filemonitor.Scanner$1.run(Scanner.java:221)
        at java.util.TimerThread.mainLoop(Timer.java:512)
        at java.util.TimerThread.run(Timer.java:462)


my osgi/list

[ 259] [Active     ] [Started] [   60] Apache ServiceMix CXF Transport for
OSGi (4.0.0)
[ 272] [Active     ] [       ] [   60]
mvn:mysql/mysql-connector-java/5.0.8
[ 305] [Installed  ] [       ] [   60] A CXF WSDL First OSGi Project
(1.0.0.SNAPSHOT)

what's wrong?

Jean-Baptiste Onofré wrote:
Hi Matteo,

In your case, you want more to add several dependencies into your OSGi bundle.

Using the felix bnd maven plugin, you can use:
- <Embed-Dependency/> notation. For example, you can use <Embed-Dependency>mysql-connector:scope=runtime|compile</Embed-Dependency> where mysql-connector is the artifactId. - for the <Bundle-Classpath/>, you can use directly the directory path (for example <Bundle-Classpath>.,{maven-dependencies}</Bundle-Classpath> - you can use <Include-Resource/> notation too, like this <Include-Resource>{maven-resources}</Include-Resource>

All is explained here: http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

Regards
JB

Matteo Redaelli wrote:
Can "Bundle-Classpath" be used to add a folder where I can add the jars
I
want to include?
Please can you show me how should I use it?

I tried with <Bundle-ClassPath>
                            .,/home/matteo/tmp/test-wsdl-first-osgi/lib,
                        </Bundle-ClassPath>

and in /home/matteo/tmp/test-wsdl-first-osgi/lib
I have
  mysql-connector-java-5.0.8.jar

but I get

[WARNING] Warning building bundle
com.yourcompany:test-wsdl-first-osgi:bundle:1.0-SNAPSHOT : No sub JAR or
directory /home/matteo/tmp/test-wsdl-first-osgi/lib
[WARNING] Warning building bundle
com.yourcompany:test-wsdl-first-osgi:bundle:1.0-SNAPSHOT : Bundle uses
Require Bundle, this can generate false errors because then not enough
information is available without the required bundles
[ERROR] Error building bundle
com.yourcompany:test-wsdl-first-osgi:bundle:1.0-SNAPSHOT : Cannot find a
file or directory for Bundle-Classpath entry:
/home/matteo/tmp/test-wsdl-first-osgi/lib

Regards
Matteo


Jean-Baptiste Onofré wrote:
Matteo,

another solution is to add required dependencies into the OSGi bundle
using:
Bundle-Classpath:
notation.

Regards
JB

Freeman Fang wrote:
Hi Matteo,
Which smx4 version are you using?
I tried with both Apache Servicemix 4.0 release and FUSE ESB 4.1
release with
osgi/install wrap:mvn:mysql/mysql-connector-java/5.0.8
But bundle status is
[ 158] [Resolved ] [ ] [ 60] wrap_mvn_mysql_mysql-connector-java_5.0.8 (0) which means it's not started, but from your mail, you mention your bundle can start like
[ 272] [Active ] [ ] [ 60] mvn:mysql/mysql-connector-java/5.0.8
I'm wondering how it could be.
You can use wrap your normal jar as osgi bundle, but you will have to have all dependent packages available as bundles in the container already, I don't think all mysql needed package already available as bundles.
Could you please tell me exactly your process?
Freeman

Matteo Redaelli wrote:
I use linux debian. In any case. here is my project in zip file

http://www.nabble.com/file/p23827756/test-wsdl-first-osgi.zip
test-wsdl-first-osgi.zip
Regards
Matteo



Freeman Fang wrote:
Hi,
Somehow I can't extract the test-wsdl-first-osgi.tgz you append on
my linux box. I guess you are using Mac, right? Would you please append your testcase as zip file?
Freeman

Matteo Redaelli wrote:
Ciao

Thanks for you suggestions: I'll look deeply at the links you
suggested

But in any case I'd like to know howto create a service with
servicemix-osgi-cxf-wsdl-first-archetype that can get/put data in a
database.

what is wrong/missing in my package/smx4?

Thanks in advance
Matteo


Freeman Fang wrote:
Hi,
If you want to port cxf-wsdl-first(bc + se) example to osgi bundle in smx4, then you shouldn't use servicemix-osgi-cxf-wsdl-first-archetype, since this archetype generate cxf endpoint deployed in smx4 using osgi http service transport directly, which means in this case there's no cxf bc + se get involved at all, it's a cxf endpoint deployed in smx4 which can talk directly to outside client. To port smx3 cxf-wsdl-first example to osgi bundle in smx4, what you need do is change the JBI package style(SA+SU) to spring dm enabled osgi bundle package style, Gert already add a wiki[1] to demostrate how to do it with servicemix-bean endpoint, and I'm going to add an example for cxf-wsdl-frist using spring dm osgi bundle package very soon, [2] track this issue

[1]http://cwiki.apache.org/confluence/display/SMX4/Creating+an+OSGi+bundle+for+deploying+JBI+endpoints
[2]https://issues.apache.org/activemq/browse/SMX4-292

Freeman

Matteo Redaelli wrote
Hello

In smx4 I'm tring to convert the JBI example cxf-wsdl-first-jdbc
(http://matteoredaelli.wordpress.com/2009/05/30/connecting-to-a-database-with-a-webservice-cxf-deployed-jbi-in-servicemix/)
with a similar OSGI project.

I created a project using

 mvn archetype:create \
    -DarchetypeGroupId=org.apache.servicemix.tooling \
-DarchetypeArtifactId=servicemix-osgi-cxf-wsdl-first-archetype \
    -DarchetypeVersion=2008.01-SNAPSHOT \
    -DgroupId=com.yourcompany \
    -DartifactId=test-wsdl-first-osgi \
    -Dversion=1.0-SNAPSHOT \

-DremoteRepositories=http://people.apache.org/repo/m2-snapshot-repository/

Than I added osgi wraps for spring-jdnc and mysql with

osgi/install  wrap mvn:org.springframework/spring-jdbc/2.5.6
osgi/install  wrap mvn:mysql/mysql-connector-java/5.0.8

[ 181] [Active     ] [       ] [   60] Spring JDBC (2.5.6)
[ 272] [Active     ] [       ] [   60]
mvn:mysql/mysql-connector-java/5.0.8

MY changes in pom.xml are:

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.0.8</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>2.5.6</version>
        </dependency>
                ...
                 <Import-Package>
                            ...
                            org.springframework.jdbc.datasource,
                            com.mysql.jdbc, *
                  </Import-Package>
                  ...
<DynamicImport-Package>*</DynamicImport-Package>

MY beans.xml
         ...
<bean id="moodleDB" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost:3306/moodle" /> <property name="username" value="root" /> <property name="password" value="" /> </bean> ...


Questions:

1) how can load properly mysql jar in smx?

I have the error

s...@root:/> osgi/start 292
ERROR CommandLineExecutionFailed:
org.apache.geronimo.gshell.command.CommandException:
org.osgi.framework.BundleException: Unresolved constraint in
bundle
292:
package; (package=com.mysql.jdbc)

In a camel tutorial I found

    <feature name="jdbc-driver">
        ...
<bundle>mvn:com.mysql.jdbc/com.springsource.com.mysql.jdbc/5.1.6</bundle>
    </feature>

but osgi/install  wrap
mvn:com.mysql.jdbc/com.springsource.com.mysql.jdbc/5.1.6 doesn't
work


2) the file beans.xml generated by maven archetype is quite
different
from
the one of cxf-wsdl-first. where/how can I add the "property
datasource"
?

I see

    <jaxws:endpoint id="HTTPEndpoint"
implementor="org.apache.servicemix.samples.wsdl_first.PersonImpl"
        address="/PersonService"
        wsdlLocation="wsdl/person.wsdl"
        endpointName="e:soap"
        serviceName="s:PersonService"
        xmlns:e="http://servicemix.apache.org/samples/wsdl-first";
xmlns:s="http://servicemix.apache.org/samples/wsdl-first"/>

Thanks in advance
Matteo
--
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com



--
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com






Reply via email to