I' m trying to access an OSGI Bundle from my main application. But if a class in the bundle is accessed that uses javax.xml.* package. A NoClassDefFoundError is thrown.
java.lang.NoClassDefFoundError: javax/xml/transform/Source
at de.foo.bar.test.Builder.<init>(Builder.java:46) ~[test-bundle-1.4.0.jar:1.4.0]
at de.foo.bar.test.request.Factory.createRequest(Factory.java:99) ~[?:?]
at de.foo.bar.test.request.Request.prepareRequest(Request.java:93) ~[?:?]
at de.foo.bar.test.request.Request.process(Request.java:60) ~[?:?]
at de.foo.bar.test.TestClass.execute(TestClass.java:74) ~[?:?]
at de.foo.bar.test.TestClass.execute(TestClass.java:1) ~[?:?]
at de.foo.bar.service.system.OsgiTransactionHandler.handleTransaction(OsgiTransactionHandler.java:71) ~[bin/:?]
at de.foo.bar.service.system.TransactionRequestService.processTransaction(TransactionRequestService.java:110) ~[bin/:?]
at de.foo.bar.service.system.TransactionRequestService.runService(TransactionRequestService.java:72) ~[bin/:?]
at de.foo.bar.service.model.InfiniteService.run(InfiniteService.java:57) ~[bin/:?]
at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:60) [guava-16.0.1.jar:?]
at com.google.common.util.concurrent.Callables$3.run(Callables.java:93) [guava-16.0.1.jar:?]
at java.lang.Thread.run(Thread.java:662) [?:1.6.0_43]
Caused by: java.lang.ClassNotFoundException: javax.xml.transform.Source not found by test-bundle [1]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532) ~[org.apache.felix.framework-4.2.1.jar:?]
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75) ~[org.apache.felix.framework-4.2.1.jar:?]
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955) ~[org.apache.felix.framework-4.2.1.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ~[?:1.6.0_43]
... 13 more
I've checked the imported packages in the MANIFEST.MF and can see, that the package javax.xml.transform is stated (I've shortend it a bit):
Import-Package: com.fasterxml.jackson.core;resolution:=optional,com.fast
...
500;resolution:=optional,javax.servlet;resolution:=optional,javax.sql;r
esolution:=optional,javax.swing;resolution:=optional,javax.xml.bind;res
olution:=optional,javax.xml.bind.annotation;resolution:=optional,javax.
xml.bind.annotation.adapters;resolution:=optional,javax.xml.parsers;res
olution:=optional,javax.xml.transform;resolution:=optional,javax.xml.tr
ansform.stream;resolution:=optional,javax.xml.validation;resolution:=op
tional,org.bson;resolution:=optional,org.lightcouch;resolution:=optiona
l,org.osgi.framework;resolution:=optional;version="[1.5,2)",org.osgi.fr
amework.wiring;resolution:=optional,org.w3c.dom;resolution:=optional,or
g.xml.sax;resolution:=optional,sun.misc;resolution:=optional
I'm using apache felix in version 4.2.1 as an embedded framework and the maven-bundle-plugin is configured as follows:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Name>Test Bundle</Bundle-Name>
<Bundle-Activator>de.foo.bar.test.activator.TestActivator</Bundle-Activator>
<Service-Component>OSGI-INF/component.xml</Service-Component>
<Export-Package>de.foo.bar.test</Export-Package>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Import-Package>*;resolution:=optional</Import-Package>
<Embed-Transitive>true</Embed-Transitive>
<Embed-Dependency>*;scope=compile|runtime;inline=false;artifactId=!org.osgi.core</Embed-Dependency>
<_failok>true</_failok>
<_nouses>true</_nouses>
<_nodefaultversion>true</_nodefaultversion>
<_snapshot>${osgi-version-qualifier}</_snapshot>
</instructions>
</configuration>
</plugin>
I tried to export the missing packages by using FRAMEWORK_SYSTEMPACKAGES_EXTRA property. But that seems to result in exporting all Java packages. I've stopped it on the 7th package.
Is there a way to provide these java standard packages without exporting them explicitly?
The cause of this problem was located in the framework configuration. Based on an online tutorial I had added following parameter to my config:
config.put(Constants.FRAMEWORK_SYSTEMPACKAGES, "org.osgi.framework; version=1.5.0");
This caused that the default system packages have been replaced and only org.osgi.framework has been available besides the extra packages I exported.
After I'd removed this line the default packages where available again and so javax.xml.transform.
Related
I am using Jersey-2.25.1 with Spring framework 4.3.5 in Jetty-9.3.3 environment. My OS is Centos 7 and JDK 8. During deployment time, I am receiving the following error:
Note: The following error occurred, only when jersey-spring3 dependency is added in the pom.xml.
Failed startup of context o.e.j.w.WebAppContext#5d37aa0f{/test-service,file:///.../test-service/,STARTING}
java.lang.RuntimeException: Error scanning entry module-info.class from jar file:///.../test-service/WEB-INF/lib/asm-all-repackaged-2.5.0-b32.jar
at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.java:925)
at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:842)
at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:163)
at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:545)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
at java.lang.Thread.run(Thread.java:745)
Caused by:
java.lang.IllegalArgumentException
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.eclipse.jetty.annotations.AnnotationParser.scanClass(AnnotationParser.java:988)
at org.eclipse.jetty.annotations.AnnotationParser.parseJarEntry(AnnotationParser.java:970)
at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.java:921)
at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:842)
at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:163)
at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:545)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
at java.lang.Thread.run(Thread.java:745)
Is it problem with Jetty's /lib/annotations/asm-5.0.1.jar and asm-commons-5.0.1.jar or jersey-spring3.jar?
I looked into module-info.class file
$ javap -v ./module-info.class
...
class org.glassfish.hk2.external.org.objectweb.asm.all.debug.module-info
minor version: 0
major version: 53
So, it is compiled with java 9, and it is a part new module system in java 9.
Anyway, there is no use in scanning this file (especially with java 8).
I fixed the issue by excluding asm-all-repackaged.jar from jetty annotation scanning:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.0.v20161208</version>
<configuration>
<webApp>
...
<webInfIncludeJarPattern>.*/^(asm-all-repackaged)[^/]*\.jar$</webInfIncludeJarPattern>
</webApp>
</configuration>
</plugin>
Here is documentation about webInfIncludeJarPattern
I need some features from Infinispan 8+. Therefore I have updated my company app pom.xml with the newest Infinispan pom.
It was quite straightforward, but the app uses jgroups (or its default config in default-configs/default-jgroups-udp.xml - this location is different from previous versions of infinispan). The default versions have some parameters (and the XSD from Jgroups version 3.6) - so I also bumped jgroups to 3.6.8.Final as it looks like it is the intended version (and the version that does not complain about unknown parameters in default config in infinispan 8.2)
so the pom is the following:
<dependency>
<groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
<version>3.6.8.Final</version>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core</artifactId>
<version>8.2.0.Final</version>
</dependency>
Anyway - this application starts with no problems using spring-boot with Jetty. I am pretty sure it would start on any application server.
But then I have no choice but to run it on JBoss 6.4.
There I got an exception involving some jboss.as classes (this is kind of unexpected) during the deployment:
Caused by: org.infinispan.commons.CacheException: Unable to invoke method public void org.infinispan.remoting.transport.jgroups.JGroupsTransport.start() on object of type JGroupsTransport
at org.infinispan.commons.util.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:172)
at org.infinispan.factories.AbstractComponentRegistry$PrioritizedMethod.invoke(AbstractComponentRegistry.java:859)
at org.infinispan.factories.AbstractComponentRegistry.invokeStartMethods(AbstractComponentRegistry.java:628)
at org.infinispan.factories.AbstractComponentRegistry.internalStart(AbstractComponentRegistry.java:617)
at org.infinispan.factories.AbstractComponentRegistry.start(AbstractComponentRegistry.java:542)
at org.infinispan.factories.GlobalComponentRegistry.start(GlobalComponentRegistry.java:234)
... 141 more
Caused by: java.lang.ExceptionInInitializerError
at org.jgroups.conf.XmlConfigurator.<clinit>(XmlConfigurator.java:35)
at org.jgroups.conf.ConfiguratorFactory.getStackConfigurator(ConfiguratorFactory.java:62)
at org.jgroups.JChannel.<init>(JChannel.java:129)
at org.infinispan.remoting.transport.jgroups.JGroupsTransport.buildChannel(JGroupsTransport.java:419)
at org.infinispan.remoting.transport.jgroups.JGroupsTransport.initChannel(JGroupsTransport.java:320)
at org.infinispan.remoting.transport.jgroups.JGroupsTransport.initChannelAndRPCDispatcher(JGroupsTransport.java:366)
at org.infinispan.remoting.transport.jgroups.JGroupsTransport.start(JGroupsTransport.java:190)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.infinispan.commons.util.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:168)
... 146 more
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.jboss.as.clustering.jgroups.LogFactory from [Module "deployment.mymodule-5.0.0.0-SNAPSHOT.ear.appName.war:main" from Service Module Loader]
at org.jgroups.logging.LogFactory.<clinit>(LogFactory.java:31)
... 158 more
Caused by: java.lang.ClassNotFoundException: org.jboss.as.clustering.jgroups.LogFactory from [Module "deployment.mymodule-5.0.0.0-SNAPSHOT.ear.appName.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.jgroups.logging.LogFactory.<clinit>(LogFactory.java:28)
... 158 more
My guess is that org.jgroups.logging.LogFactory somehow discovers that is is running on a Jboss and tries to use org.jboss.as.clustering.jgroups.LogFactory but this version of Jboss does not have one. (the server directory EAP-6.4.0\modules\system\layers\base\org\jgroups\main contains jgroups version 3.2.X).
Is there any walkaround to use this jgroups version (and so Infinispan 8.2) in Jboss 6.4?
This is (the application) an ear file so I can manipulate jboss-deployment-structure.xml file, but so far I only came with excluding Jboss original jgroups, and this did not help.
<exclusions>
<module name="org.jgroups"/>
</exclusions>
This is currently bug with Infinispan 8 + EAP 6.4 combination. The reason is exactly as #Flavius says in comments. Currently there is discussion where to fix it, but it'll mostly likely be fixed in EAP 6.4. I'm sure it will be done soon.
I can only offer you a working workarounds.
Use WildFly - the issue is not present there anymore
Little nasty workaround, but it works:
Call System.clearProperty("jgroups.logging.log_factory_class"); in the deployment
Include JBoss Logging of version specified in infinispan-bom in your deployment (e.g. add jboss-logging Maven dependency in your pom.xml)
Provide jboss-deployment-structure.xml to your deployment, which excludes the server's JBoss logging, see below:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.jboss.logging" />
</exclusions>
</deployment>
</jboss-deployment-structure>
Another possibility if none of the above workarounds work (for instance the app uses other log mechanisms) is to implement an own
http://www.jgroups.org/javadoc/org/jgroups/logging/CustomLogFactory.html
The log factory must return a log instance, implementing it for any other logger is straightforward with methods trace/error/debug etc.
Then this logger class can be set with System.setProperty("jgroups.logging.log_factory_class","my.company.logging.MyJgroupsLog");
I have an OSGi bundle, which has an activator class. I embedded Equinox in my webapp, and installed my bundle in it. The installation goes well, but when I try to start the bundle, the following error comes:
org.osgi.framework.BundleException: The activator com.rr.fr.base.barcode.activator.Activator for bundle fr-base-barcode is invalid
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:171)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:679)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:299)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:291)
at com.rr.fr.base.osgi.BundleStarter.launch(BundleStarter.java:43)
at com.rr.fr.base.osgi.OsgiInitServletContextListener.contextInitialized(OsgiInitServletContextListener.java:41)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:759)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.ClassNotFoundException: com.rr.fr.base.barcode.activator.Activator
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:345)
at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:229)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:164)
... 21 more
I can see that my activator class was not found. I searched for a solution and find some interesting thing here in SO, but none of them helped me.
Here is my manifest:
Manifest-Version: 1.0
Bnd-LastModified: 1431100911346
Build-Jdk: 1.6.0_45
Bundle-Activator: com.rr.fr.base.barcode.activator.Activator
Bundle-ManifestVersion: 2
Bundle-SymbolicName: fr-base-barcode;singleton:=true
Bundle-Version: 0.1.2.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Import-Package: com.rr.fr.base.barcode.qrcode.interfaces,com.rr.fr.base.
exception,com.rr.fr.base.messages,com.rr.fr.base.system,com.rr.fr.base.
types,com.rr.fr.interfaces,com.rr.fr.interfaces.eb.rms,com.rr.fr.ui.htt
p,hu.posta.rsaqrgen,javax.servlet,javax.servlet.http,org.apache.avalon.
framework.configuration,org.apache.commons.logging,or
g.krysalis.barcode4j,org.krysalis.barcode4j.output,org.krysalis.barcode
4j.output.bitmap,org.krysalis.barcode4j.output.eps,org.osgi.framework,org.osgi.service.http,org.osgi.util.
tracker
I can include my Activator, but I don't think it would help since it isn't even found so I don't think its source has anything to do with the error.
My bundle's library structure inside the JAR is the following:
META-INF
/MANIFEST.MF
target
/classes
/com
/rr
/fr
/base
/barcode
...
fr-base-barcode.jar
plugin.xml
I create my bundle with Eclipse PDE: Export.../Deployable Plug-ins and fragments
My build.properties includes the META-INF and target libraries, a JAR and plugin.xml as it can be seen in the bundle structure.
Any help would be appreciated.
I'm going to restate bkail's suggestion as the answer. When your packages are included in the "target/classes" folder, they are essentially in that package:
target.classes.com.rr.fr.base.barcode.*
The root of your package structure (com) should be a peer of META-INF and/or OSGI-INF, etc.
From : https://netbeans.org/kb/docs/javaee/maven-osgiservice-cdi.html#Exercise_3
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifestEntries>
<Bundle-ClassPath>WEB-INF/classes/</Bundle-ClassPath>
</manifestEntries>
</archive>
</configuration>
</plugin>
I'm trying to implement Apache CXF in CQ. I've generated proxy classes from WSDL using cxf-codegen-plugin. Now my CxfServiceImpl.java looks like below -
import net.webservicex.ConvertTemperatureSoap;
import net.webservicex.TemperatureUnit;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
#Component(label = "CXF Service", immediate = true, metatype = true)
#Service(CxfService.class)
public class CxfServiceImpl implements CxfService {
private ConvertTemperatureSoap convertTemperatureSoap;
#Override
public double convertCelsiusToFahrenheit(double valueToConvert) {
return convertTemperatureSoap.convertTemp(
valueToConvert,
TemperatureUnit.DEGREE_CELSIUS,
TemperatureUnit.DEGREE_FAHRENHEIT);
}
#Activate
protected final void activate(final ComponentContext context) {
convertTemperatureSoap =
JaxWsClientFactory.create(
ConvertTemperatureSoap.class,
"http://www.w3schools.com/webservices/tempconvert.asmx");
}
}
JaxWsClientFactory.java looks like -
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.BusFactory;
public class JaxWsClientFactory {
public static <T> T create(Class<T> clazz, String portUrl) {
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(BusFactory.class.getClassLoader());
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(clazz);
factory.setAddress(portUrl);
return (T) factory.create();
} finally {
Thread.currentThread().setContextClassLoader(oldClassLoader);
}
}
}
I am able to create OSGI bundle and uploaded in Felix console. But when I try to activate bundle then I get error as below and bundle status is showing as Active.
24.02.2014 20:38:41.104 *ERROR* [127.0.0.1 [1393254521079] POST /system/console/bundles/300 HTTP/1.1] com.adobe.cq.customer-bundle [com.adobe.cq.CxfServiceImpl] The activate method has thrown an exception (java.lang.NoClassDefFoundError: javax/xml/ws/BindingProvider) java.lang.NoClassDefFoundError: javax/xml/ws/BindingProvider
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.findClass(BundleWiringImpl.java:2167)
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1471)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1882)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.adobe.cq.JaxWsClientFactory.create(JaxWsClientFactory.java:12)
at com.adobe.cq.CxfServiceImpl.activate(CxfServiceImpl.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:236)
at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:37)
at org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMethod.java:613)
at org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:496)
at org.apache.felix.scr.impl.helper.ActivateMethod.invoke(ActivateMethod.java:149)
at org.apache.felix.scr.impl.manager.ImmediateComponentManager.createImplementationObject(ImmediateComponentManager.java:251)
at org.apache.felix.scr.impl.manager.ImmediateComponentManager.createComponent(ImmediateComponentManager.java:119)
at org.apache.felix.scr.impl.manager.AbstractComponentManager$Unsatisfied.activate(AbstractComponentManager.java:1518)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:550)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:261)
at org.apache.felix.scr.impl.config.ImmediateComponentHolder.enableComponents(ImmediateComponentHolder.java:328)
at org.apache.felix.scr.impl.BundleComponentActivator.initialize(BundleComponentActivator.java:158)
at org.apache.felix.scr.impl.BundleComponentActivator.<init>(BundleComponentActivator.java:113)
at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:261)
at org.apache.felix.scr.impl.Activator.bundleChanged(Activator.java:179)
at org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:868)
at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:789)
at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:514)
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4319)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1993)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:947)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:934)
at org.apache.felix.webconsole.internal.core.BundlesServlet.doPost(BundlesServlet.java:339)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.felix.webconsole.internal.servlet.OsgiManager.service(OsgiManager.java:493)
at org.apache.felix.webconsole.internal.servlet.OsgiManager.service(OsgiManager.java:418)
at org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
at org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
at org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
at org.apache.sling.i18n.impl.I18NFilter.doFilter(I18NFilter.java:127)
at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
at com.adobe.granite.license.impl.LicenseCheckFilter.doFilter(LicenseCheckFilter.java:179)
at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
at org.apache.felix.http.sslfilter.internal.SslFilter.doFilter(SslFilter.java:55)
at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
at org.apache.sling.security.impl.ReferrerFilter.doFilter(ReferrerFilter.java:259)
at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
at org.apache.sling.engine.impl.log.RequestLoggerFilter.doFilter(RequestLoggerFilter.java:75)
at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
Caused by: java.lang.ClassNotFoundException: javax.xml.ws.BindingProvider not found by com.adobe.cq.customer-bundle [300]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1499)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1882)
at java.lang.ClassLoader.loadClass(Unknown Source)
pom.xml-
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>com.adobe.cq.customer-bundle</Bundle-SymbolicName>
<Export-Package>
com.adobe.cq.*;version=${project.version}
javax.xml.ws*;version=2.1;-split-package:=merge-first;-noimport:=true
</Export-Package>
<Private-Package>
javax.jws,
javax.jws.*,
javax.wsdl,
org.xml.*,
org.apache.cxf,
org.apache.cxf.*,
javax.xml,
org.apache.servicemix.specs.locator;-split-package:=merge-first
javax.xml.transform.stax,
javax.net.ssl,
org.w3c.dom,
org.apache.ws.commons.schema.resolver.*,
org.apache.ws.commons.schema.extensions.*,
org.apache.ws.commons.schema.*,
net.webservicex
</Private-Package>
<Include-Resource>{maven-resources}</Include-Resource>
<Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Import-Package>
org.osgi.framework,
org.osgi.service.component.*,
com.sun.msv.*;resolution:=optional,
com.sun.xml.bind.marshaller.*;resolution:=optional,
com.sun.xml.fastinfoset.stax.*;resolution:=optional,
net.sf.cglib.*;resolution:=optional,
org.apache.aries.*;resolution:=optional,
org.apache.axiom.*;resolution:=optional,
org.apache.mina.*;resolution:=optional,
org.apache.log4j.spi.*;resolution:=optional,
org.apache.velocity.*;resolution:=optional,
org.osgi.service.blueprint.*;resolution:=optional,
org.junit.*;resolution:=optional,
org.relaxng.*;resolution:=optional,
org.slf4j.spi.*;resolution:=optional,
org.springframework.*;resolution:=optional,
javax.resource.*;resolution:=optional,
javax.mail.*;resolution:=optional,
javax.xml.ws.spi.http.*;resolution:=optional,
junit.framework.*;resolution:=optional,
com.sun.*;resolution:=optional,
sun.*;resolution:=optional,
org.apache.*;resolution:=optional,
org.jvnet.*;resolution:=optional,
javax.net.*,
javax.xml.transform.stax,
!*
</Import-Package>
</instructions>
</configuration>
</plugin>
In my case I needed to roll back to Java 8 from Java 11 on this project.
I know this is not a long term solution, but it might be helpful for someone.
The more general solution would be to use:
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.1</version>
</dependency>
This error happens when CXF delegates to the JDK for the proxy generation. The problem there is that for all interfaces the proxy has to implement you can only set one classloader. Typically users do not have the BindpProvider in their classpath. SO cxf uses the bus classpath which looks in the bundle classpath first and then in the cxf classpath.
Which CXF version do you use? In older CXF versions this error was misleading sometimes. It was not only issues when the BindingProvider class was not found. It also happened when BindingProvider was loaded by cxf and the user bundle but from different classloaders.
The best way to avoid this problem is to import javax.xml.ws. So you have the highest chance you find the same interface as cxf. If the error then still happens you might have two bundles exporting the package.
In any case your bundle plugin instruction should not look as complicated as in your question. This only leads to problem. Just try.
<instructions>
<Bundle-SymbolicName>com.adobe.cq.customer-bundle</Bundle-SymbolicName>
<Include-Resource>{maven-resources}</Include-Resource>
<Import-Package>
javax.xml.ws,
*
</Import-Package>
</instructions>
Is there any special reason why you embed all your dependencies? CXF typically does work to well when used like this. Instead you can use the bundles from the CXF DOSGi multi bundle distro to install CXF into CQ.
add javax/xml/ws/BindingProvider class to your classpath
If you are using maven, here a quick link to the possible artifacts
I'd say check your MANIFEST.MF first. It is complaining it's missing javax.xml.ws packages, so check if it is there in the Import-Package header.
If it isn't: Thats your problem, I guess you need to add it to your pom.xml.
If it is there, it's a bit more subtle.
In case you have installed the JDK 1.6 (Java SE 6) I suggest you read the document Using JAX-WS 2.x / Metro 1.x/2.0 with Java SE 6
I solved a similar problem just by reading the attached document.
I have created a maven project. After I type: mvn clean package everything works fine and I see my jar file inside target. But if I click the file I get the follwing error message:
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/c
ontext/ApplicationContext
Caused by: java.lang.ClassNotFoundException: org.springframework.context.Applica
tionContext
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: comt.test.Test. Program will exit
I can run the project under Eclipse and works ok, but the jar file doesnt work.
This is the content of Manifest:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Build-Jdk: 1.6.0_23
Main-Class: com.stlpo.App
Class-Path: commons-httpclient-3.1.jar commons-codec-1.2.jar h2-1.2.138.jar
commons-lang-2.5.jar spring-core-3.0.3.RELEASE.jar spring-asm-3.0.3.RELEASE.jar co
mmons-logging-1.1.1.jar spring-context-3.0.3.RELEASE.jar spring-beans
-3.0.3.RELEASE.jar spring-expression-3.0.3.RELEASE.jar spring-orm-3.0
.3.RELEASE.jar spring-tx-3.0.3.RELEASE.jar spring-aop-3.0.3.RELEASE.j
ar aopalliance-1.0.jar spring-jdbc-3.0.3.RELEASE.jar spring-test-3.0.
3.RELEASE.jar cglib-nodep-2.2.jar logback-core-0.9.24.jar logback-cla
ssic-0.9.24.jar slf4j-api-1.6.0.jar hibernate-annotations-3.5.4-Final
.jar hibernate-core-3.5.4-Final.jar antlr-2.7.6.jar commons-collectio
ns-3.1.jar jta-1.1.jar hibernate-commons-annotations-3.2.0.Final.jar
hibernate-jpa-2.0-api-1.0.0.Final.jar hibernate-entitymanager-3.5.4-F
inal.jar cglib-2.2.jar asm-3.1.jar javassist-3.9.0.GA.jar opencsv-2.1
.jar jfreechart-1.0.13.jar jcommon-1.0.16.jar commons-beanutils-1.8.3
.jar beansbinding-1.2.1.jar poi-3.6.jar log4j-1.2.13.jar
poi-ooxml-3.6.jar poi-ooxml-schemas-3.6.jar xmlbeans-2.3.0.jar stax-
api-1.0.1.jar geronimo-stax-api_1.0_spec-1.0.jar dom4j-1.6.1.jar xml-
apis-1.0.b2.jar commons-dbcp-1.4.jar commons-pool-1.5.4.jar TableLayo
ut-20050920.jar
Thanks in advance for your help.
When you build a JAR, it only has your classes in it. It doesn't contain all the other libraries that your project depends on. (Doing that is possible, but it's not common and mostly inadvisable.) To run a class in your JAR that depends on Spring, you have to be sure Spring is on the classpath, either by passing a classpath to the java executable (doesn't work if using the -jar argument) or by putting a "Class-Path" attribute in the JAR's manifest file. Of course, it's not just Spring. You'll have to include a classpath entry for every jar your project depends on.
see another post regarding the same problem
you need to create a classPath (the eclipse is dong it automatically for you, and this is why you have no problem ruining the project from the eclipse) for the dependencies (in your case the spring)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3</version>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
<addClasspath>true</addClasspath>
<!-- use class path prefix if your dependencies are out side the jar)
<classpathPrefix>lib/</classpathPrefix> -->
</manifest>
<manifestEntries>
<Class-Path>conf/</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>