Get the ClassNotFound exception when use corba within osgi - osgi

I want to encapsulate corba service in to osgi bundle. I am using karaf as osgi container, openorb as orb implementation and blueprint to register osgi service. But when I install my corba feature to karaf, always get ClassNotFound exception. the exception stack like this:
org.omg.CORBA.INITIALIZE: can't instantiate ORB implementation org.openorb.CORBA.ORB
at org.omg.CORBA.ORB.init_orb(Unknown Source)[:1.6.0_32]
at org.omg.CORBA.ORB.init(Unknown Source)[:1.6.0_32]
....
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_32]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)[:1.6.0_32]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_32]
at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_32]
at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:226)[10:org.apache.aries.blueprint:0.3.1]
at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:824)[10:org.apache.aries.blueprint:0.3.1]
at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:636)[10:org.apache.aries.blueprint:0.3.1]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:724)[10:org.apache.aries.blueprint:0.3.1]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:64)[10:org.apache.aries.blueprint:0.3.1]
at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:219)[10:org.apache.aries.blueprint:0.3.1]
at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:147)[10:org.apache.aries.blueprint:0.3.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:640)[10:org.apache.aries.blueprint:0.3.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:331)[10:org.apache.aries.blueprint:0.3.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:227)[10:org.apache.aries.blueprint:0.3.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)[:1.6.0_32]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)[:1.6.0_32]
at java.util.concurrent.FutureTask.run(FutureTask.java:138)[:1.6.0_32]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)[:1.6.0_32]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)[:1.6.0_32]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_32]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_32]
at java.lang.Thread.run(Thread.java:662)[:1.6.0_32]
Caused by: java.lang.ClassNotFoundException: org.openorb.CORBA.ORB
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)[:1.6.0_32]
at java.security.AccessController.doPrivileged(Native Method)[:1.6.0_32]
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)[:1.6.0_32]
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)[:1.6.0_32]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)[:1.6.0_32]
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_32]

Fixed this problem by myself, use the following way:
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
/*
* Start threads, or establish connections, here, now
*/
} finally {
Thread.currentThread().setContextClassLoader(tccl);
}
Better handling of Thread Context ClassLoader in OSGi

I think it just misses the openorb dependency. Do you import the org.openorb package?
Normally you'd get compile time errors if you forget that, but this seems to be a Class.forname, so it fails only at runtime.

Related

Upgrading from WebLogic 12.1.3 to 12.2.1.4 breaks our application using Spring Framework 3.0.2

Our company is having us upgrade from Oracle WebLogic 12.1.3 to 12.2.1.4 since 12.1.3 is out of support/going out of support.
We have a major application that is using Spring Framework v3.0.2. When we deploy the EAR to 12.2.1.4 and attempt to consume any of the web services, we get this error stack trace. I've removed names that specify our company with generic names but you should be able to get the gist of what is happening:
2021-06-02 15:21:50.019/27.406 Oracle Coherence GE 12.2.1.4.0 (thread=[STANDBY] ExecuteThread: '10' for queue: 'weblogic.kernel.Default (self-tuning)', member=n/a): Configured versioned, multi-cluster Management over ReST
02.06.2021 15:22:11 - error trying to getBean("DefaultJBL"): Error creating bean with name 'DefaultJBL' defined in URL [zip:C:/javadev/server/appserver.12.2.1.4/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/lasor/2wlg44/lib/Lasor_core-1.0.jar!/com/foo/app/corebuslogic/common/jbl/DefaultJBL.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.RuntimeException: java.lang.ClassNotFoundException: com.foo.app.corebuslogic.common.exceptions.LoggedException
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'DefaultJBL' defined in URL [zip:C:/javadev/server/appserver.12.2.1.4/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/app/2wlg44/lib/App_core-1.0.jar!/com/foo/app/corebuslogic/common/jbl/DefaultJBL.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.RuntimeException: java.lang.ClassNotFoundException: com.aep.lasor.corebuslogic.common.exceptions.LoggedException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1045)
at com.foo.util.FOOApplicationContext.fetchBean(FOOApplicationContext.java:203)
at com.foo.app.buslogic.common.generic.GenericSessionBean.getBL(GenericSessionBean.java:293)
at com.foo.app.buslogic.common.generic.GenericSessionBean.query(GenericSessionBean.java:97)
I also believe the API is SOAP in 12.1.3 but I see REST specified in the 12.2.1.4 logs. Could this be the issue or am I reading that incorrectly?
Also, the classes is says it cannot find I've verified are there in the deployment area of WebLogic so I'm not sure why it can't find them.
Here is where the code throws an exception no matter what bean name I pass in but they've all been defined. The class is our FOOApplicationContext that implements org.springframework.context.ApplicationContextAware and has a fetchBean function that does the following:
public static Object fetchBean(final String beanName) throws FOOException {
Object object = null;
if (beanName == null) {
throw new FOOException("beanName is null");
}
try {
object = currentSpringContext().getBean(beanName);
} catch (Exception e) {
final String message = "error trying to getBean('"" + beanName + "\"): " + e.getMessage();
throw new FOOException(message, e);
}
return object;
}
When getBean() is called under WebLogic 12.1.3, it works. But it throws the AOP Exception error listed above when this exact same function is called under WebLogic 12.4.1.2. No code changes, etc. Not sure why this is.
We haven't created an actual server yet to deploy to, but instead I've installed it locally on my development machine. I've set up the database connections, etc the same way as do when locally installing 12.1.3. Is there something that has changed in regards to Spring Framework? The code was written over 8+ years ago and I inteherited the support for it and now I have to get us moved to WebLogic 12.2.1.4 before the end of this year and this is a major part of a very important application. The WebLogic application houses all the business logic and database access in it so without it, the front-end app is dead in the water.
Also, none of our registered beans will instantiate at all under WebLogic 12.2.1.4 but it works under 12.1.3. I've even recompiled the EAR file and again, it works under 12.1.3 but not 12.2.1.4.
I've found what appears to be a possibly circular reference between 2 objects that are not registered as beans, but the beans do depend on. So those 2 objects are not registered as beans. Not sure why it was done that way, but in any case, this doesn't seem to create a problem in 12.1.3. But one of the objects (FOOException) shows up in the error thrown when trying to create the DefaultJBL bean within the FOOApplicationContext object.
I'm not sure what else I can provide. Searching around the internet has not found a solution to my issue. I've found some that appeared as if they would fix it, but they turn out to not apply. I cannot seem to find anyone else with this issue, but Google and Duck Duck Go all find various "solutions" that don't apply to my situation.
Thanks!
ClassNotFound Exception, You may need to update the Dependencies pertaining to Spring Framework

How to use Jersey in Sling?

I've got Sling 8. I then include Jersey and this Jersey connector in my build: https://github.com/hstaudacher/osgi-jax-rs-connector
My next step should be simply write a Jersey Service and test it, but I'm getting this Exception immediately:
27.01.2017 10:54:16.696 *ERROR* [FelixDispatchQueue] com.eclipsesource.jaxrs.publisher FrameworkEvent ERROR (org.osgi.framework.ServiceException: Service factory returned null.)org.osgi.framework.ServiceException: Service factory returned null.
and
[FelixDispatchQueue] com.eclipsesource.jaxrs.publisher FrameworkEvent ERROR (org.osgi.framework.ServiceException: Service factory exception: org/apache/felix/shell/Command)
org.osgi.framework.ServiceException: Service factory exception: org/apache/felix/shell/Command
and
Caused by: java.lang.NoClassDefFoundError: org/apache/felix/shell/Command
So I look at my bundles list in Felix, and I don't see any bundle that appears to provide this... So I find it online and install it myself. Now I get this exception:
Service factory exception: org/apache/sling/extensions/threaddump/internal/ThreadDumpCommand
and
Caused by: java.lang.NoClassDefFoundError: org/apache/sling/extensions/threaddump/internal/ThreadDumpCommand
and
Caused by: java.lang.NoClassDefFoundError: org/apache/felix/webconsole/plugins/memoryusage/internal/MemoryUsageCommand
Now, I DO have a bundle installed with this class (it's "Apache Felix Web Console Memory Usage Plugin"). So now I really don't understand what the heck is going on.
I have a feeling that I'm not supposed to be providing my own "felix shell" bundle and that the OSGI in Sling is failing to provide it...
Is anybody successfully using Sling 8 and Jersey?
Maybe you should try with just a vanilla OSGi environment for starters. Once you have Jersey working then you can try integrating with Sling.
I have had success with jaxrs in OSGi, specifically using the Amdatu REST bundles.
https://amdatu.org/application/tutorial/step1/
With this I was able to use JAX-RS annotations to serve HTTP services:
https://github.com/figurate/figurate-core/blob/master/modules/figurate-osgi/src/main/groovy/org/figurate/osgi/http/ServiceInfo.groovy
You can see the bundles I used here:
https://github.com/figurate/figurate-core/blob/master/modules/figurate-osgi/src/test/resources/config/HttpVersionSpec.config

How to use Java-8 default-interface-implementation in a OSGi-Service

I would like to use Java 8 features on the latest Apache-Karaf release (3.0.2) which is supposed to support Java 8.
I have a service-interface within my domain-layer (repository) which has a default-method for identity-generation
public interface MyRepository{
...
default MyId nextIdentity() {
return new MyId(UUID.randomUUID().toString().toUpperCase());
}
}
Then I have a Implementation of that interface which is exposed as a OSGi-Service using Blueprint (Apache-Aries).
When I run my application the bundles get installed successfully, the services get registered, but when the application-layer is calling the method nextIdentity I get a Exception.
IncompatibleClassChangeError: Found interface MyRepository, but class was expected
The application-layer is straight forward: Interface-Attribute which gets its class (in this case OSGi-Service-Reference) injected via Blueprint.
I did check the compilation: all modules are compiled with Java 8 compliance level in Eclipse. I am guessing the problem is related to a aries-proxy which is not Java 8, but since karaf supports it....
EDIT: added Stacktrace
org.apache.wicket.WicketRuntimeException: Can't instantiate page using constructor 'public bikeshop.http.wicket.page.GaragePage()'. Might be it doesn't exist, may be it is not visible (public).
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:193)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:66)[92:org.apache.wicket.core:6.7.0]
at org.ops4j.pax.wicket.internal.PaxWicketPageFactory.newPage(PaxWicketPageFactory.java:76)[100:org.ops4j.pax.wicket.service:3.0.2]
at org.apache.wicket.DefaultMapperContext.newPageInstance(DefaultMapperContext.java:133)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.core.request.handler.PageProvider.resolvePageInstance(PageProvider.java:268)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.core.request.handler.PageProvider.getPageInstance(PageProvider.java:166)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.request.handler.render.PageRenderer.getPage(PageRenderer.java:78)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:244)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:165)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:854)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)[91:org.apache.wicket.request:6.7.0]
at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:254)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:211)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:282)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.protocol.http.WicketFilter$$EnhancerByCGLIB$$91ca4a1b.CGLIB$processRequestCycle$4(<generated>)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.protocol.http.WicketFilter$$EnhancerByCGLIB$$91ca4a1b$$FastClassByCGLIB$$36c566fa.invoke(<generated>)[92:org.apache.wicket.core:6.7.0]
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)[99:org.apache.servicemix.bundles.cglib:2.2.2.1]
at org.ops4j.pax.wicket.internal.servlet.PAXWicketServlet$WicketFilterCallback.intercept(PAXWicketServlet.java:150)[100:org.ops4j.pax.wicket.service:3.0.2]
at org.apache.wicket.protocol.http.WicketFilter$$EnhancerByCGLIB$$91ca4a1b.processRequestCycle(<generated>)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.protocol.http.WicketFilter$$EnhancerByCGLIB$$91ca4a1b.CGLIB$processRequest$12(<generated>)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.protocol.http.WicketFilter$$EnhancerByCGLIB$$91ca4a1b$$FastClassByCGLIB$$36c566fa.invoke(<generated>)[92:org.apache.wicket.core:6.7.0]
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)[99:org.apache.servicemix.bundles.cglib:2.2.2.1]
at org.ops4j.pax.wicket.internal.servlet.PAXWicketServlet$WicketFilterCallback.intercept(PAXWicketServlet.java:150)[100:org.ops4j.pax.wicket.service:3.0.2]
at org.apache.wicket.protocol.http.WicketFilter$$EnhancerByCGLIB$$91ca4a1b.processRequest(<generated>)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.protocol.http.WicketFilter$$EnhancerByCGLIB$$91ca4a1b.CGLIB$doFilter$10(<generated>)[92:org.apache.wicket.core:6.7.0]
at org.apache.wicket.protocol.http.WicketFilter$$EnhancerByCGLIB$$91ca4a1b$$FastClassByCGLIB$$36c566fa.invoke(<generated>)[92:org.apache.wicket.core:6.7.0]
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)[99:org.apache.servicemix.bundles.cglib:2.2.2.1]
at org.ops4j.pax.wicket.internal.servlet.PAXWicketServlet$WicketFilterCallback.intercept(PAXWicketServlet.java:150)[100:org.ops4j.pax.wicket.service:3.0.2]
at org.apache.wicket.protocol.http.WicketFilter$$EnhancerByCGLIB$$91ca4a1b.doFilter(<generated>)[92:org.apache.wicket.core:6.7.0]
at org.ops4j.pax.wicket.internal.servlet.PAXWicketServlet.service(PAXWicketServlet.java:98)[100:org.ops4j.pax.wicket.service:3.0.2]
at org.ops4j.pax.wicket.internal.filter.PAXWicketFilterChain.doFilter(PAXWicketFilterChain.java:61)[100:org.ops4j.pax.wicket.service:3.0.2]
at org.ops4j.pax.wicket.internal.filter.FilterDelegator.doFilter(FilterDelegator.java:82)[100:org.ops4j.pax.wicket.service:3.0.2]
at org.ops4j.pax.wicket.internal.servlet.ServletCallInterceptor.service(ServletCallInterceptor.java:168)[100:org.ops4j.pax.wicket.service:3.0.2]
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:69)[80:org.ops4j.pax.web.pax-web-jetty:3.1.2]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:240)[80:org.ops4j.pax.web.pax-web-jetty:3.1.2]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:77)[80:org.ops4j.pax.web.pax-web-jetty:3.1.2]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.eclipse.jetty.server.Server.handle(Server.java:370)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)[71:org.eclipse.jetty.aggregate.jetty-all-server:8.1.15.v20140411]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_20]
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.8.0_20]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)[:1.8.0_20]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.8.0_20]
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)[:1.8.0_20]
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:174)[92:org.apache.wicket.core:6.7.0]
... 61 more
Caused by: java.lang.IncompatibleClassChangeError: Found interface bikeshop.domain.repository.BikeRepository, but class was expected
at Proxy04d92f46_988d_4726_9355_6b6381790fde.nextIdentity(Unknown Source)
at bikeshop.application.service.BikeApplicationService.loadGarage(BikeApplicationService.java:22)
at Proxyc25af47a_a344_4a1b_8d0e_429a76d453c6.loadGarage(Unknown Source)
at Proxy163e0a74_12bc_4124_827b_2119133222e8.loadGarage(Unknown Source)
at bikeshop.presentation.internal.GaragePresentationService.init(GaragePresentationService.java:21)
at Proxy5a3bd46a_6830_438c_b5eb_0ca9ec091479.init(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_20]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_20]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_20]
at java.lang.reflect.Method.invoke(Method.java:483)[:1.8.0_20]
at org.ops4j.pax.wicket.util.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitProxyFactory.java:253)
at org.ops4j.pax.wicket.util.proxy.$Proxy22.init(Unknown Source)
at bikeshop.http.wicket.page.GaragePage.<init>(GaragePage.java:30)
The culprit here is probably Blueprint, which generates a proxy class for every imported service, rather than giving you the service object directly. I don't believe that Aries Blueprint has been updated for Java 8 compatibility.
The solution would be to avoid Blueprint and use something like Declarative Services (DS), which is much closer to "real" OSGi Services and gives your consumer the actual service instance. DS definitely works with Java 8 interfaces having default methods.
Update:
This issue seems to be fixed in the proxy-impl 1.1.4 of Aries / Karaf 4.2.3
KARAF-6087
ARIES-1849

Class Loading Issue with HornetMQ and JBoss 7.0.2

I am working on a JBoss 7.0.2 instance. Our app is a war and messages are dropped into the queue. This works fine. But when we read it via a listener, the system throws an exception. It is looking for a class which is present in the WEB-INF/classes.
I understand that the module classloader (if I am right it is HornetMQ) is not able to see this application class and throwing up. I dont want my application class to be part of the server lib. That class living within the war is the best place.
The exception is :
javax.jms.JMSException: com.yyy.TransportMessage from [Module "org.hornetq:main" from local module loader #238b8914
(roots: /Users/xxx/jboss/multi/jboss-as-7.0.2.Final/modules)]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:603)
at org.hornetq.utils.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:71)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1574)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at org.hornetq.jms.client.HornetQObjectMessage.getObject(HornetQObjectMessage.java:158)
at com.xxx.MessageReceiver.handleObjectMessage(NSMessageReceiver.java:72)
at com.xxx.jms.JMSListener.onMessage(JMSListener.java:1540)
at org.hornetq.jms.client.JMSMessageListenerWrapper.onMessage(JMSMessageListenerWrapper.java:91)
What should I do to make this work?
Regards.
ashok

XSLT ClassCastException in WebSphere when Spring tries to create an AnnotationMethodHandlerAdapter

When starting WebSphere, I get this exception:
Could not instantiate bean class [org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter]:
Constructor threw exception; nested exception is java.lang.ClassCastException:
com.ibm.xtq.xslt.jaxp.compiler.TransformerFactoryImpl incompatible with
javax.xml.transform.TransformerFactory
Caused by: java.lang.ClassCastException: com.ibm.xtq.xslt.jaxp.compiler.TransformerFactoryImpl
incompatible with javax.xml.transform.TransformerFactory
at javax.xml.transform.TransformerFactory.newInstance(Unknown Source)
at org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter.<init>(AbstractXmlHttpMessageConverter.java:47)
at org.springframework.http.converter.xml.SourceHttpMessageConverter.<init>(SourceHttpMessageConverter.java:45)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.<init>(AnnotationMethodHandlerAdapter.java:197)
This doesn't seem have any impact on any beans in my applicationContext.xml but it's still odd. For me, this looks as if IBM classes are leaking into my application.
How can I fix this? I already set the option "Access to internal server classes" to "Restrict".
It was indeed a class-loading issue, however this cannot be solved by changing class-loader settings.
The problem was that the xml-apis and javax.xml jars were being imported over some maven dependencies.
Since we already set the class loader policies for the application to PARENT_LAST, the javax.xml.transform.TransformerFactory was being loaded from the WebApp-Class loader from our jar files.
However its implementation 'com.ibm.xtq.xslt.jaxp.compiler.TransformerFactoryImpl' was coming from the server class loader, this one was linked to the javax.xml.transform.TransformerFactory provided by the JDK/JRE.
Since the classes were loaded from different sources a ClassCastException was thrown.
Removing all dependencies to xml-apis / xerces / javax.xml jars solved the problem.
Since these APIs are now part of the JDK they no longer need to be imported.
... and if you wonder why I know so much about this issue: I work together with Aaron. ;)
I can't speak for Restrict as I have no personal experience with it,But I think the problem is more to do with IBM Class Loader. The class you are referring to is part of IBM Java implementation of TransformerFactory, I think you can try one of the following to solve this issue on hand
Either change the server class loader policy to PARENT_LAST (This way class loader will find the class from application's local class path, before going to up the chain all the way to java run time)
The other option would be look at the jaxp.properties file, I think it is located in (was_root\java\jre\lib), I only read about this option never actually used it
Why do you say IBM classes are leaking into your application?
The TransformerFactory is asked to create a newInstance. It follows a sequence of steps to determine which TransformerFactory to use. If none of the config is specified, it simply chooses to use the default factory.
Here is the javadoc for TransformerFactory:
http://download.oracle.com/javase/1.5.0/docs/api/javax/xml/transform/TransformerFactory.html#newInstance()
What is the OS ? Is that AIX?
http://www.ibm.com/developerworks/java/jdk/aix/j664/sdkguide.aix64.html
Looking at this doc (link above) for AIX it tells me that this is the default Impl:
javax.xml.transform.TransformerFactory
Selects the XSLT processor. Possible values are:
com.ibm.xtq.xslt.jaxp.compiler.TransformerFactoryImpl
Use the XL TXE-J compiler. This value is the default.
Post back additional information so that we can try and troubleshoot this.
HTH
Manglu

Resources