I am writing a CDI custom scope that is added via an extension:
public class SliceScopeExtension
implements Extension, Serializable {
public void addScope(#Observes final BeforeBeanDiscovery event) {
event.addScope(SliceScoped.class, true, true);
}
public void registerContext(#Observes final AfterBeanDiscovery event) {
event.addContext(new SliceScopeContext());
}
}
The corresponding context class uses a custom bean store implementation that is derived from org.jboss.weld.context.beanstore.AttributeBeanStore:
public class SliceScopeContext implements Context, Serializable {
private static final Logger log = Logger.getLogger(SliceScopeContext.class.getName());
private final ThreadLocal<HttpServletRequest> request;
private final ThreadLocal<SliceScopeBeanStore> beanStore;
public SliceScopeContext() {
this.request = new ThreadLocal<>();
this.beanStore = new ThreadLocal<>();
}
...
}
If I now deploy this web application glassfish/weld are throwing a org.jboss.weld.resources.spi.ResourceLoadingException with a nested NoClassDefFoundError saying that the class org/jboss/weld/context/beanstore/AttributeBeanStore could not be found. If I use the NamingScheme interface or SimpleNamingScheme the error is thrown for these class names:
org.jboss.weld.resources.spi.ResourceLoadingException: Error loading class my.package.SliceScopeContext
at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:179)
at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:188)
at org.jboss.weld.bootstrap.BeanDeployer.loadAnnotatedType(BeanDeployer.java:122)
at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:100)
at org.jboss.weld.bootstrap.BeanDeployer.addClasses(BeanDeployer.java:159)
at org.jboss.weld.bootstrap.BeanDeployment.createClasses(BeanDeployment.java:214)
at org.jboss.weld.bootstrap.WeldBootstrap.startInitialization(WeldBootstrap.java:470)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:211)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:328)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:493)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
at org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.java:297)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:246)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NoClassDefFoundError: org/jboss/weld/context/beanstore/AttributeBeanStore
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.glassfish.web.loader.WebappClassLoader.findClass(WebappClassLoader.java:1183)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1728)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1611)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:266)
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
at sun.reflect.generics.repository.FieldRepository.getGenericType(FieldRepository.java:85)
at java.lang.reflect.Field.getGenericType(Field.java:236)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedField.of(BackedAnnotatedField.java:28)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedFields.computeValue(BackedAnnotatedType.java:178)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedFields.computeValue(BackedAnnotatedType.java:171)
at org.jboss.weld.util.LazyValueHolder.get(LazyValueHolder.java:35)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$EagerlyInitializedLazyValueHolder.<init>(BackedAnnotatedType.java:154)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedFields.<init>(BackedAnnotatedType.java:171)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedFields.<init>(BackedAnnotatedType.java:171)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.<init>(BackedAnnotatedType.java:65)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.of(BackedAnnotatedType.java:47)
at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.apply(ClassTransformer.java:85)
at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.apply(ClassTransformer.java:82)
at com.google.common.collect.ComputingConcurrentHashMap$ComputingValueReference.compute(ComputingConcurrentHashMap.java:358)
at com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.compute(ComputingConcurrentHashMap.java:184)
at com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.getOrCompute(ComputingConcurrentHashMap.java:153)
at com.google.common.collect.ComputingConcurrentHashMap.getOrCompute(ComputingConcurrentHashMap.java:69)
at com.google.common.collect.ComputingConcurrentHashMap$ComputingMapAdapter.get(ComputingConcurrentHashMap.java:396)
at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:174)
... 43 more
Caused by: java.lang.ClassNotFoundException: org.jboss.weld.context.beanstore.AttributeBeanStore
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1761)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1611)
... 76 more
I verified if these classes are present in the weld-osgi-bundle.jar inside the glassfish modules directory and they are. This SO post I have checked and my project does not include any library that already contains these WELD classes.
What's going or what am I doing wrong here?
Opening weld-osgi-bundle.jar you can see that in META-INF/MANIFEST.MF file, the Export-Package section doesn't mention org.jboss.weld.context.beanstore; package, so it is private to weld.
You probably have to create your own context by copying this weld code or by using Apache Deltaspike and the tools in org.apache.deltaspike.core.util.context to create a portable context across Weld and OpenWebBeans.
The last (dirty) solution would be to modify the MANIFEST.MF file in weld-osgi-bundle.jar
Related
I want to create a plugin for Intellij Idea which provides additional inspections for Kotlin language. Following the example from official documentation for creating inspections for Java, I ended up with following code, which is not working.
Here is the link to a repository with this project: https://bitbucket.org/magycbytes/kotlin-inspections/src/master/
Links to example I followed:
docummentation page: https://www.jetbrains.org/intellij/sdk/docs/tutorials/code_inspections.html
example project: https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/comparing_references_inspection
This is the provider for inspections.
package com.magicbytes.kotlin.inspections;
import com.intellij.codeInspection.InspectionToolProvider;
import com.magicbytes.kotlin.inspections.ExampleInspection;
import org.jetbrains.annotations.NotNull;
public class ExampleProvider implements InspectionToolProvider {
#NotNull
#Override
public Class[] getInspectionClasses() {
return new Class[]{ExampleInspection.class};
}
}
This is the actual inspection subclass. For the sake of shortness it's doing nothing, but should be loaded. Note: I changed the superclass to AbstractKotlinInspection
package com.magicbytes.kotlin.inspections;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.idea.inspections.AbstractKotlinInspection;
public class ExampleInspection extends AbstractKotlinInspection {
#Nls
#NotNull
#Override
public String getDisplayName() {
return "Kotlin Test";
}
}
My buid.gradle file looks like this:
plugins {
id 'java'
id 'org.jetbrains.intellij' version '0.3.2'
}
group 'com.magicbytes'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
intellij {
version '2018.1.4'
plugins 'kotlin'
}
Mine plugin.xml looks like this:
<idea-plugin>
<id>com.magicbytes.kotlin.inspections</id>
<name>Plugin display name here</name>
<description></description>
<depends>org.jetbrains.kotlin</depends>
<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
<inspectionToolProvider implementation="com.magicbytes.kotlin.inspections.ExampleProvider"/>
</extensions>
<actions>
</actions>
</idea-plugin>
I did all the linking with plugin.xml file. But when I'm running I'm getting exception in testing IDE. Appreciate any insight. NOTE: I'm using runIde to debug the plugin.
Exception which I'm getting..
java.lang.ClassNotFoundException: ExampleProvider PluginClassLoader[com.magicbytes.kotlin.inspections, 1.0-SNAPSHOT] com.intellij.ide.plugins.cl.PluginClassLoader#6f989177
com.intellij.openapi.extensions.impl.PicoPluginExtensionInitializationException: java.lang.ClassNotFoundException: ExampleProvider PluginClassLoader[com.magicbytes.kotlin.inspections, 1.0-SNAPSHOT] com.intellij.ide.plugins.cl.PluginClassLoader#6f989177
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getComponentInstance(ExtensionComponentAdapter.java:96)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getExtension(ExtensionComponentAdapter.java:119)
at com.intellij.openapi.extensions.impl.ExtensionPointImpl.processAdapters(ExtensionPointImpl.java:246)
at com.intellij.openapi.extensions.impl.ExtensionPointImpl.getExtensions(ExtensionPointImpl.java:191)
at com.intellij.openapi.extensions.Extensions.getExtensions(Extensions.java:102)
at com.intellij.openapi.extensions.Extensions.getExtensions(Extensions.java:89)
at com.intellij.openapi.extensions.ExtensionPointName.getExtensions(ExtensionPointName.java:50)
at com.intellij.codeInspection.ex.InspectionToolRegistrar.ensureInitialized(InspectionToolRegistrar.java:54)
at com.intellij.codeInspection.ex.InspectionToolRegistrar.createTools(InspectionToolRegistrar.java:127)
at com.intellij.codeInspection.ex.InspectionSearchableOptionContributor.processOptions(InspectionSearchableOptionContributor.java:34)
at com.intellij.ide.ui.search.SearchableOptionPreloader.preload(SearchableOptionPreloader.java:49)
at com.intellij.openapi.application.Preloader.lambda$null$0(Preloader.java:74)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:543)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:488)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:94)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
at com.intellij.openapi.application.Preloader.lambda$initComponent$1(Preloader.java:72)
at com.intellij.util.concurrency.BoundedTaskExecutor$2.run(BoundedTaskExecutor.java:212)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: ExampleProvider PluginClassLoader[com.magicbytes.kotlin.inspections, 1.0-SNAPSHOT] com.intellij.ide.plugins.cl.PluginClassLoader#6f989177
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.loadImplementationClass(ExtensionComponentAdapter.java:161)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getComponentImplementation(ExtensionComponentAdapter.java:66)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getComponentInstance(ExtensionComponentAdapter.java:73)
... 21 more
Caused by: java.lang.ClassNotFoundException: ExampleProvider PluginClassLoader[com.magicbytes.kotlin.inspections, 1.0-SNAPSHOT] com.intellij.ide.plugins.cl.PluginClassLoader#6f989177
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:63)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.loadImplementationClass(ExtensionComponentAdapter.java:158)
... 23 more
Caused by:
java.lang.RuntimeException: java.lang.ClassNotFoundException: ExampleProvider PluginClassLoader[com.magicbytes.kotlin.inspections, 1.0-SNAPSHOT] com.intellij.ide.plugins.cl.PluginClassLoader#6f989177
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.loadImplementationClass(ExtensionComponentAdapter.java:161)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getComponentImplementation(ExtensionComponentAdapter.java:66)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getComponentInstance(ExtensionComponentAdapter.java:73)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getExtension(ExtensionComponentAdapter.java:119)
at com.intellij.openapi.extensions.impl.ExtensionPointImpl.processAdapters(ExtensionPointImpl.java:246)
at com.intellij.openapi.extensions.impl.ExtensionPointImpl.getExtensions(ExtensionPointImpl.java:191)
at com.intellij.openapi.extensions.Extensions.getExtensions(Extensions.java:102)
at com.intellij.openapi.extensions.Extensions.getExtensions(Extensions.java:89)
at com.intellij.openapi.extensions.ExtensionPointName.getExtensions(ExtensionPointName.java:50)
at com.intellij.codeInspection.ex.InspectionToolRegistrar.ensureInitialized(InspectionToolRegistrar.java:54)
at com.intellij.codeInspection.ex.InspectionToolRegistrar.createTools(InspectionToolRegistrar.java:127)
at com.intellij.codeInspection.ex.InspectionSearchableOptionContributor.processOptions(InspectionSearchableOptionContributor.java:34)
at com.intellij.ide.ui.search.SearchableOptionPreloader.preload(SearchableOptionPreloader.java:49)
at com.intellij.openapi.application.Preloader.lambda$null$0(Preloader.java:74)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:543)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:488)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:94)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
at com.intellij.openapi.application.Preloader.lambda$initComponent$1(Preloader.java:72)
at com.intellij.util.concurrency.BoundedTaskExecutor$2.run(BoundedTaskExecutor.java:212)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: ExampleProvider PluginClassLoader[com.magicbytes.kotlin.inspections, 1.0-SNAPSHOT] com.intellij.ide.plugins.cl.PluginClassLoader#6f989177
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:63)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.loadImplementationClass(ExtensionComponentAdapter.java:158)
... 23 more
After I've imported your GitHub repo and built it locally I've found out that ./build/libs/kotlin.inspections-1.0-SNAPSHOT.jar includes META-INF only, but no classes. I suspect it's because your source code is located under ./src/main/src, not ./src/main/java as it's typical for Gradle projects, so it simply assumes you have no code at all.
After renaming that inner src directory into java the error changed to
class com.magicbytes.kotlin.inspections.ExampleInspection: group display name should be overridden or configured via XML class com.magicbytes.kotlin.inspections.ExampleInspection
java.lang.Throwable: class com.magicbytes.kotlin.inspections.ExampleInspection: group display name should be overridden or configured via XML class com.magicbytes.kotlin.inspections.ExampleInspection
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:123)
at com.intellij.codeInspection.InspectionProfileEntry.getGroupDisplayName(InspectionProfileEntry.java:230)
at com.intellij.codeInspection.InspectionProfileEntry.getGroupPath(InspectionProfileEntry.java:239)
at com.intellij.codeInspection.ex.InspectionToolWrapper.getGroupPath(InspectionToolWrapper.java:161)
at com.intellij.codeInspection.ex.InspectionSearchableOptionContributor.processOptions(InspectionSearchableOptionContributor.java:40)
at com.intellij.ide.ui.search.SearchableOptionPreloader.preload(SearchableOptionPreloader.java:49)
at com.intellij.openapi.application.Preloader.lambda$null$0(Preloader.java:74)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:580)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:525)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:85)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
at com.intellij.openapi.application.Preloader.lambda$initComponent$1(Preloader.java:72)
at com.intellij.util.concurrency.BoundedTaskExecutor$2.run(BoundedTaskExecutor.java:212)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
which is much better and looks like a separate problem with your code violating some contract.
I have a cluster with 2 nodes. Then I tried to run the CacheJdbcStoreExample in apache-ignite-fabric-2.1.0-bin/examples.But I got following exception:
visor> [06:51:41,113][SEVERE][tcp-disco-msg-worker-#13%null%][TcpDiscoverySpi] Failed to unmarshal discovery custom message.
class org.apache.ignite.IgniteCheckedException: Failed to find class with given class loader for unmarshalling (make sure same versions of all classes are available on all nodes or enable pee
r-class-loading) [clsLdr=sun.misc.Launcher$AppClassLoader#4aa4ceeb, cls=org.apache.ignite.examples.datagrid.store.jdbc.CacheJdbcStoreExample$1] at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal0(JdkMarshaller.java:124)
at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.unmarshal(AbstractNodeNameAwareMarshaller.java:94)
at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal0(JdkMarshaller.java:143)
at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.unmarshal(AbstractNodeNameAwareMarshaller.java:82)
at org.apache.ignite.internal.util.IgniteUtils.unmarshal(IgniteUtils.java:9733)
at org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCustomEventMessage.message(TcpDiscoveryCustomEventMessage.java:81)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.notifyDiscoveryListener(ServerImpl.java:5436)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processCustomMessage(ServerImpl.java:5321)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processMessage(ServerImpl.java:2629)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processMessage(ServerImpl.java:2420)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$MessageWorkerAdapter.body(ServerImpl.java:6576)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.body(ServerImpl.java:2506)
at org.apache.ignite.spi.IgniteSpiThread.run(IgniteSpiThread.java:62)
Caused by: java.lang.ClassNotFoundException: org.apache.ignite.examples.datagrid.store.jdbc.CacheJdbcStoreExample$1
at java.net.URLClassLoader$1.run(URLClassLoader.java:359)
at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:278)
at org.apache.ignite.internal.util.IgniteUtils.forName(IgniteUtils.java:8465)
at org.apache.ignite.marshaller.jdk.JdkMarshallerObjectInputStream.resolveClass(JdkMarshallerObjectInputStream.java:54)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1817)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1711)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1982)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1533)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1917)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1527)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2227)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2151)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2009)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1533)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2227)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2151)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2009)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1533)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:420)
at java.util.ArrayList.readObject(ArrayList.java:771)
at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1058)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2118)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2009)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1533)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2227)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2151)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2009)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1533)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2227)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2151)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2009)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1533)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:420)
at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal0(JdkMarshaller.java:121)
... 12 more
I decompiled CacheJdbcStoreExample$1.class and got following code:
CacheJdbcStoreExample$1
package org.apache.ignite.examples.datagrid.store.jdbc;
import javax.cache.configuration.Factory;
import org.apache.ignite.cache.store.CacheStoreSessionListener;
import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener;
import org.h2.jdbcx.JdbcConnectionPool;
class CacheJdbcStoreExample$1
implements Factory<CacheStoreSessionListener>
{
public CacheStoreSessionListener create()
{
CacheJdbcStoreSessionListener lsnr = new CacheJdbcStoreSessionListener();
lsnr.setDataSource(JdbcConnectionPool.create("jdbc:h2:tcp://localhost/mem:ExampleDb", "sa", ""));
return lsnr;
}
}
SO I think there is something wrong at row 90 in CacheJdbcStoreExample source code:
// Configure JDBC session listener.
cacheCfg.setCacheStoreSessionListenerFactories(new Factory<CacheStoreSessionListener>() {
#Override public CacheStoreSessionListener create() {
CacheJdbcStoreSessionListener lsnr = new CacheJdbcStoreSessionListener();
lsnr.setDataSource(JdbcConnectionPool.create("jdbc:h2:tcp://localhost/mem:ExampleDb", "sa", ""));
return lsnr;
}
});
If I run the example on only one node not a cluster, it's OK.
What should I do to fix it?
The problem is that you configured a cache with a factory of CacheStoreSessionListener-s, but this factory is not visible from other nodes as they don't have it in their classpath.
You should start additional remote nodes with org.apache.ignite.examples.ExampleNodeStartup class from examples module or add examples module to the classpath of other nodes.
I've created EJB with remote and local interfaces.
#Stateless
public class VendorBean implements VendorBeanLocal, VendorBeanRemote {
...
}
#Local
public interface VendorBeanLocal {
...
}
#Remote
public interface VendorBeanRemote {
...
}
There are some methods instead of dots (it doesn't matter in this case).
Then deploy it to glassfish 3.1. It's accessible from my client web application (deployed as war on the same server) and works fine. But I can't access it from my integration tests.
I wrote integration test which is supposed to be run by maven 2. I looked JNDI name of this bean in the glassfish server.log:
java:global/<my business module name>/VendorBean!<package>.VendorBeanRemote
and wrote the test. But I always get exception on lookup:
javax.naming.NameNotFoundException [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
at com.sun.jndi.cosnaming.ExceptionMapper.mapException(ExceptionMapper.java:61)
at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:501)
at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:540)
at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:518)
at javax.naming.InitialContext.lookup(InitialContext.java:409)
at com.widewebtech.mercury.core.test.ejb.VendorBeanIntegrationTest.manageVendor(VendorBeanIntegrationTest.java:126)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
Caused by: org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:72)
at org.omg.CosNaming._NamingContextExtStub.resolve(_NamingContextExtStub.java:406)
at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:487)
... 33 more
The code of test:
Properties p = new Properties();
p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
p.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
p.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
Context context = new InitialContext(p);
Object o = context.lookup("java:global/<my business module name>/VendorBean!<package>.VendorBeanRemote");
I'm confused. I've read a lot of articles, tried a lot suggestions but nothing works.
I've also tried to list a context within the test:
NamingEnumeration<NameClassPair> list = context.list("");
while (list.hasMore()) {
NameClassPair ncPair = (NameClassPair) list.next();
System.out.print(ncPair.getName() + " (type ");
System.out.println(ncPair.getClassName() + ")");
}
Result:
<package>.VendorBeanRemote__3_x_Internal_RemoteBusinessHome__ (type com.sun.corba.se.impl.corba.CORBAObjectImpl)
SerialContextProvider (type com.sun.corba.se.impl.corba.CORBAObjectImpl)
java:global (type com.sun.jndi.cosnaming.CNCtx)
INITIAL_GIS (type com.sun.corba.se.impl.corba.CORBAObjectImpl)
So, looks like bean in the context.
What I do wrong? Please help!
Eventually I've managed to solve this issue. So, the code is:
Properties p = new Properties();
p.setProperty(Context.PROVIDER_URL, "corbaname:iiop:localhost:3700");
context = new InitialContext(p);
VendorBeanRemote vendorBean = (VendorBeanRemote) context.lookup("java:global/<my business module name>/VendorBean!<package>.VendorBeanRemote");
Important thing, gf-client.jar must be in the classpath. It can be taken from the
glassfish lib directory.
If somebody is strugling with remote EJB calls between 2 different hosts on glassfish, with the exception stated above:
Set your orb-listener-1 network adress to your IP. (ORB / IIOP listeners section in config)
Glassfish 3.1.1 (build 12)
Application deployed as a WAR using JAX-RS, EJB3, JPA
There are no deployment errors in the logs. This is a very clean glassfish 3.1.1 install, with only this application deployed. This application works in Glassfish 3.0.1 I am getting the following exception when web service method is invoked.
EJB5070: Exception creating stateless session bean : [VehicleManagementService]|#]
Here is some info from the logs during deployment regarding the creation of the EJBs:
[#|2011-08-26T11:03:26.928-0500|INFO|glassfish3.1.1|javax.enterprise.system.container.ejb.com.sun.ejb.containers|_ThreadID=23;_ThreadName=Thread-2;|Portable JNDI names for EJB VehicleAliases : [java:global/vehicle/VehicleAliases!com.realcomp.vehicle.ejb.VehicleAliases, java:global/vehicle/VehicleAliases]|#]
[#|2011-08-26T11:03:26.937-0500|INFO|glassfish3.1.1|javax.enterprise.system.container.ejb.com.sun.ejb.containers|_ThreadID=23;_ThreadName=Thread-2;|Portable JNDI names for EJB VehicleManagementService : [java:global/vehicle/VehicleManagementService!com.realcomp.vehicle.web.service.VehicleManagementService, java:global/vehicle/VehicleManagementService]|#]
[#|2011-08-26T11:03:27.002-0500|INFO|glassfish3.1.1|javax.enterprise.system.container.ejb.com.sun.ejb.containers|_ThreadID=23;_ThreadName=Thread-2;|Portable JNDI names for EJB VehicleManagementBean : [java:global/vehicle/VehicleManagementBean!com.realcomp.vehicle.ejb.VehicleManagementBean, java:global/vehicle/VehicleManagementBean!com.realcomp.vehicle.ejb.VehicleManagement]|#]
[#|2011-08-26T11:03:27.003-0500|INFO|glassfish3.1.1|javax.enterprise.system.container.ejb.com.sun.ejb.containers|_ThreadID=23;_ThreadName=Thread-2;|Glassfish-specific (Non-portable) JNDI names for EJB VehicleManagementBean : [com.realcomp.vehicle.ejb.VehicleManagement, com.realcomp.vehicle.ejb.VehicleManagement#com.realcomp.vehicle.ejb.VehicleManagement]|#]
[#|2011-08-26T11:03:27.218-0500|INFO|glassfish3.1.1|org.hibernate.validator.engine.resolver.DefaultTraversableResolver|_ThreadID=23;_ThreadName=Thread-2;|Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.|#]
[#|2011-08-26T11:03:27.602-0500|INFO|glassfish3.1.1|javax.enterprise.resource.webcontainer.jsf.config|_ThreadID=23;_ThreadName=Thread-2;|Initializing Mojarra 2.1.3 (FCS b02) for context '/vehicle'|#]
[#|2011-08-26T11:03:27.660-0500|INFO|glassfish3.1.1|org.hibernate.validator.engine.resolver.DefaultTraversableResolver|_ThreadID=23;_ThreadName=Thread-2;|Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.|#]
[#|2011-08-26T11:03:27.771-0500|INFO|glassfish3.1.1|com.sun.jersey.api.core.WebAppResourceConfig|_ThreadID=23;_ThreadName=Thread-2;|Scanning for root resource and provider classes in the Web app resource paths:
/WEB-INF/lib
/WEB-INF/classes|#]
[#|2011-08-26T11:03:28.072-0500|INFO|glassfish3.1.1|com.sun.jersey.api.core.ScanningResourceConfig|_ThreadID=23;_ThreadName=Thread-2;|Root resource classes found:
class com.realcomp.vehicle.web.service.VehicleManagementService|#]
[#|2011-08-26T11:03:28.073-0500|INFO|glassfish3.1.1|com.sun.jersey.api.core.ScanningResourceConfig|_ThreadID=23;_ThreadName=Thread-2;|Provider classes found:
class org.codehaus.jackson.jaxrs.JsonMappingExceptionMapper
class com.realcomp.vehicle.web.service.NoResultMapper
class com.realcomp.vehicle.web.service.EntityNotFoundMapper
class org.codehaus.jackson.jaxrs.JacksonJsonProvider
class com.realcomp.vehicle.web.service.NonUniqueResultMapper
class org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider
class org.codehaus.jackson.jaxrs.JsonParseExceptionMapper|#]
[#|2011-08-26T11:03:28.078-0500|INFO|glassfish3.1.1|com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer|_ThreadID=23;_ThreadName=Thread-2;|CDI support is enabled|#]
[#|2011-08-26T11:03:28.079-0500|INFO|glassfish3.1.1|com.sun.jersey.server.impl.application.WebApplicationImpl|_ThreadID=23;_ThreadName=Thread-2;|Initiating Jersey application, version 'Jersey: 1.8 06/24/2011 12:17 PM'|#]
[#|2011-08-26T11:03:28.172-0500|INFO|glassfish3.1.1|com.sun.jersey.server.impl.ejb.EJBComponentProviderFactory|_ThreadID=23;_ThreadName=Thread-2;|Binding the EJB class com.realcomp.vehicle.web.service.VehicleManagementService to EJBManagedComponentProvider|#]
Here is some of the VehicleManagementService:
#Stateless
#LocalBean
#Path("/")
#DeclareRoles({"production"})
public class VehicleManagementService implements Serializable{
private static final Logger logger = Logger.getLogger(VehicleManagementService.class.getName());
#Context
private UriInfo uriInfo;
#EJB
private VehicleManagementBean vehicles;
#EJB
private VehicleAliases aliases;
...
Here is full stack trace:
[#|2011-08-26T11:03:33.537-0500|SEVERE|glassfish3.1.1|javax.enterprise.system.container.ejb.com.sun.ejb.containers|_ThreadID=27;_ThreadName=Thread-2;|EJB5070: Exception creating stateless session bean : [VehicleManagementService]|#]
[#|2011-08-26T11:03:33.538-0500|WARNING|glassfish3.1.1|javax.enterprise.system.container.ejb.com.sun.ejb.containers|_ThreadID=27;_ThreadName=Thread-2;|A system exception occurred during an invocation on EJB VehicleManagementService method public javax.ws.rs.core.Response com.realcomp.vehicle.web.service.VehicleManagementService.getVehicle(java.lang.String)
javax.ejb.EJBException: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:454)
at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:2528)
at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1895)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
at $Proxy307.getVehicle(Unknown Source)
at com.realcomp.vehicle.web.service.__EJB31_Generated__VehicleManagementService__Intf____Bean__.getVehicle(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:327)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:679)
Caused by: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:726)
at com.sun.ejb.containers.util.pool.NonBlockingPool.getObject(NonBlockingPool.java:247)
at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:449)
... 53 more
Caused by: javax.ejb.CreateException: Could not create stateless EJB
at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:534)
at com.sun.ejb.containers.StatelessSessionContainer.access$000(StatelessSessionContainer.java:95)
at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:724)
... 55 more
Caused by: java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:796)
at org.jboss.weld.manager.BeanManagerImpl.getBean(BeanManagerImpl.java:1209)
at org.jboss.weld.manager.BeanManagerImpl.getBean(BeanManagerImpl.java:144)
at org.glassfish.weld.services.JCDIServiceImpl._createJCDIInjectionContext(JCDIServiceImpl.java:169)
at org.glassfish.weld.services.JCDIServiceImpl.createJCDIInjectionContext(JCDIServiceImpl.java:146)
at com.sun.ejb.containers.BaseContainer.createEjbInstanceAndContext(BaseContainer.java:1636)
at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:475)
... 57 more
And here is getVehicle()
#GET
#Path("vin/{vin}")
#Produces(MediaType.APPLICATION_JSON)
#RolesAllowed("production")
public Response getVehicle(#PathParam("vin") String vin) {
Vehicle vehicle = vehicles.find(vin);
Response response = null;
if (vehicle == null)
response = Response.status(Status.NOT_FOUND).build();
else
response = Response.ok(vehicle).build();
return response;
}
The following changes fixed my problem. Unfortunately, I have changed too many things trying to fix this to be able to point to any one item.
I repackaged the application from WAR to EAR.
I changed the configuration of jersey from using the com.sun.jersey.spi.container.servlet.ServletContainer configuration in web.xml to a proper class that extends Application.
#ApplicationPath("/")
public class VehicleService extends Application {
#Override
public Set<Class<?>> getClasses() {
Set<Class<?>> retVal = new HashSet<Class<?>>();
retVal.add(VehicleResource.class);
retVal.add(EntityNotFoundMapper.class);
retVal.add(NoResultMapper.class);
retVal.add(NonUniqueResultMapper.class);
return retVal;
}
#Override
public Set<Object> getSingletons() {
Set<Object> singletons = new HashSet<Object>();
singletons.add(new org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider());
return singletons;
}
Thanks to JamesBoyZ for the link to EJB 3.1 in war package in WEB-INF/classes - javax.ejb.CreateException: Could not create stateless EJB that got me going in the right direction.
In the 2nd line of the stack trace, I saw:
A system exception occurred during an invocation on EJB VehicleManagementService getVehicle(java.lang.String)
It seems there is a problem with your getVehicle method?
Double-check that there's a(n empty) beans.xml in your bundled project.
So I'm trying to write my first gwt test. I got this part figured out that I need to add gwt-dev.jar to maven pom file, but now when I run my test I get this error:
testSimple(com.karq.tvkava.client.TelekanalServiceImplTest) Time elapsed: 3.809 sec <<< ERROR!
com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
at com.google.gwt.dev.cfg.ModuleDef.checkForSeedTypes(ModuleDef.java:518)
at com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:327)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1342)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1309)
at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:650)
at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:441)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:296)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
And here's my test file
public class TelekanalServiceImplTest extends GWTTestCase {
#Override
public String getModuleName() {
return "com.karq.tvkava.tvkavaJUnit";
}
public void testSimple(){
boolean isSaved = true;
assertTrue(isSaved);
}
}
did you include
<inherits name="com.google.gwt.junit.JUnit" />
in your *.gwt.xml file?
If this doesn't fix your error you might want to take a look at Unit Testing GWT Applications with JUnit.