I am using JUnit and embedded glassfish to test some code using CDI. This seems fairly straightforward but I must be missing something. I've created a simple project which demonstrates the problem.
https://github.com/dantwinkler/container-test-embedded-glassfish
This is the stack trace if no parameters are set. If the domain.xml is specified in the embedded container properties the tests still fail but because it says the test can not be found. The next step is to try to get things working without gradle to see if that is the culprit.
Gradle Worker 1 executing tests.
com.foo.service.TestModelServiceTest STANDARD_ERROR
Nov 11, 2012 11:30:35 AM com.sun.enterprise.v3.server.CommonClassLoaderServiceImpl findDerbyClient
INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by default.
Nov 11, 2012 11:30:38 AM org.glassfish.flashlight.impl.provider.FlashlightProbeProviderFactory processXMLProbeProviders
SEVERE: MNTG0301:Cannot process XML ProbeProvider, xml = META-INF/gfprobe-provider.xml
java.lang.IllegalStateException: Provider already mapped glassfish:javamail:smtp-transport
at org.glassfish.flashlight.impl.core.ProbeProviderRegistry.registerProbeProvider(ProbeProviderRegistry.java:100)
at org.glassfish.flashlight.impl.provider.FlashlightProbeProviderFactory.registerProvider(FlashlightProbeProviderFactory.java:561)
at org.glassfish.flashlight.impl.provider.FlashlightProbeProviderFactory.processXMLProbeProviders(FlashlightProbeProviderFactory.java:386)
at org.glassfish.admin.monitor.MonitoringBootstrap.processProbeProviderXML(MonitoringBootstrap.java:484)
at org.glassfish.admin.monitor.MonitoringBootstrap.processManifest(MonitoringBootstrap.java:360)
at org.glassfish.admin.monitor.MonitoringBootstrap.addProvider(MonitoringBootstrap.java:301)
at org.glassfish.admin.monitor.MonitoringBootstrap.verifyModule(MonitoringBootstrap.java:245)
at org.glassfish.admin.monitor.MonitoringBootstrap.discoverProbeProviders(MonitoringBootstrap.java:188)
at org.glassfish.admin.monitor.MonitoringBootstrap.enableMonitoringForProbeProviders(MonitoringBootstrap.java:624)
at org.glassfish.admin.monitor.MonitoringBootstrap.postConstruct(MonitoringBootstrap.java:176)
at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:131)
at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:91)
at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:82)
at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:67)
at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:139)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:78)
at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:229)
at com.sun.enterprise.v3.server.AppServerStartup.doStart(AppServerStartup.java:145)
at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:136)
at com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.start(GlassFishImpl.java:79)
at org.glassfish.ejb.embedded.EJBContainerProviderImpl.createContainer(EJBContainerProviderImpl.java:204)
at org.glassfish.ejb.embedded.EJBContainerProviderImpl.createEJBContainer(EJBContainerProviderImpl.java:129)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:127)
at com.foo.service.TestModelServiceTest.setup(TestModelServiceTest.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:55)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:42)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:75)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at $Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.remote.internal.TypeCastDispatch.dispatch(TypeCastDispatch.java:30)
at org.gradle.messaging.remote.internal.WorkerProtocol.handleIncoming(WorkerProtocol.java:53)
at org.gradle.messaging.remote.internal.WorkerProtocol.handleIncoming(WorkerProtocol.java:31)
at org.gradle.messaging.remote.internal.ProtocolStack$ProtocolStage.handleIncoming(ProtocolStack.java:167)
at org.gradle.messaging.remote.internal.ProtocolStack$BottomStage.handleIncoming(ProtocolStack.java:277)
at org.gradle.messaging.remote.internal.ProtocolStack$BottomConnection$1.run(ProtocolStack.java:299)
at org.gradle.messaging.remote.internal.ProtocolStack$ExecuteRunnable.dispatch(ProtocolStack.java:120)
at org.gradle.messaging.remote.internal.ProtocolStack$ExecuteRunnable.dispatch(ProtocolStack.java:116)
at org.gradle.messaging.dispatch.AsyncDispatch.dispatchMessages(AsyncDispatch.java:132)
at org.gradle.messaging.dispatch.AsyncDispatch.access$000(AsyncDispatch.java:33)
at org.gradle.messaging.dispatch.AsyncDispatch$1.run(AsyncDispatch.java:72)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Nov 11, 2012 11:30:38 AM org.glassfish.flashlight.impl.provider.FlashlightProbeProviderFactory processXMLProbeProviders
SEVERE: MNTG0301:Cannot process XML ProbeProvider, xml = jersey-gf-server-probe-provider.xml
java.lang.IllegalStateException: Provider already mapped glassfish:jersey:server-hidden
at org.glassfish.flashlight.impl.core.ProbeProviderRegistry.registerProbeProvider(ProbeProviderRegistry.java:100)
at org.glassfish.flashlight.impl.provider.FlashlightProbeProviderFactory.registerProvider(FlashlightProbeProviderFactory.java:561)
at org.glassfish.flashlight.impl.provider.FlashlightProbeProviderFactory.processXMLProbeProviders(FlashlightProbeProviderFactory.java:386)
at org.glassfish.admin.monitor.MonitoringBootstrap.processProbeProviderXML(MonitoringBootstrap.java:484)
at org.glassfish.admin.monitor.MonitoringBootstrap.processManifest(MonitoringBootstrap.java:360)
at org.glassfish.admin.monitor.MonitoringBootstrap.addProvider(MonitoringBootstrap.java:301)
at org.glassfish.admin.monitor.MonitoringBootstrap.verifyModule(MonitoringBootstrap.java:245)
at org.glassfish.admin.monitor.MonitoringBootstrap.discoverProbeProviders(MonitoringBootstrap.java:188)
at org.glassfish.admin.monitor.MonitoringBootstrap.enableMonitoringForProbeProviders(MonitoringBootstrap.java:624)
at org.glassfish.admin.monitor.MonitoringBootstrap.postConstruct(MonitoringBootstrap.java:176)
at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:131)
at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:91)
at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:82)
at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:67)
at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:139)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:78)
at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:229)
at com.sun.enterprise.v3.server.AppServerStartup.doStart(AppServerStartup.java:145)
at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:136)
at com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.start(GlassFishImpl.java:79)
at org.glassfish.ejb.embedded.EJBContainerProviderImpl.createContainer(EJBContainerProviderImpl.java:204)
at org.glassfish.ejb.embedded.EJBContainerProviderImpl.createEJBContainer(EJBContainerProviderImpl.java:129)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:127)
at com.foo.service.TestModelServiceTest.setup(TestModelServiceTest.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:55)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:42)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:75)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at $Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.remote.internal.TypeCastDispatch.dispatch(TypeCastDispatch.java:30)
at org.gradle.messaging.remote.internal.WorkerProtocol.handleIncoming(WorkerProtocol.java:53)
at org.gradle.messaging.remote.internal.WorkerProtocol.handleIncoming(WorkerProtocol.java:31)
at org.gradle.messaging.remote.internal.ProtocolStack$ProtocolStage.handleIncoming(ProtocolStack.java:167)
at org.gradle.messaging.remote.internal.ProtocolStack$BottomStage.handleIncoming(ProtocolStack.java:277)
at org.gradle.messaging.remote.internal.ProtocolStack$BottomConnection$1.run(ProtocolStack.java:299)
at org.gradle.messaging.remote.internal.ProtocolStack$ExecuteRunnable.dispatch(ProtocolStack.java:120)
at org.gradle.messaging.remote.internal.ProtocolStack$ExecuteRunnable.dispatch(ProtocolStack.java:116)
at org.gradle.messaging.dispatch.AsyncDispatch.dispatchMessages(AsyncDispatch.java:132)
at org.gradle.messaging.dispatch.AsyncDispatch.access$000(AsyncDispatch.java:33)
at org.gradle.messaging.dispatch.AsyncDispatch$1.run(AsyncDispatch.java:72)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Nov 11, 2012 11:30:39 AM org.glassfish.flashlight.impl.provider.FlashlightProbeProviderFactory processXMLProbeProviders
SEVERE: MNTG0301:Cannot process XML ProbeProvider, xml = jersey-gf-statsprovider-probe-provider.xml
java.lang.IllegalStateException: Provider already mapped glassfish:jersey:server
at org.glassfish.flashlight.impl.core.ProbeProviderRegistry.registerProbeProvider(ProbeProviderRegistry.java:100)
at org.glassfish.flashlight.impl.provider.FlashlightProbeProviderFactory.registerProvider(FlashlightProbeProviderFactory.java:561)
at org.glassfish.flashlight.impl.provider.FlashlightProbeProviderFactory.processXMLProbeProviders(FlashlightProbeProviderFactory.java:386)
at org.glassfish.admin.monitor.MonitoringBootstrap.processProbeProviderXML(MonitoringBootstrap.java:484)
at org.glassfish.admin.monitor.MonitoringBootstrap.processManifest(MonitoringBootstrap.java:360)
at org.glassfish.admin.monitor.MonitoringBootstrap.addProvider(MonitoringBootstrap.java:301)
at org.glassfish.admin.monitor.MonitoringBootstrap.verifyModule(MonitoringBootstrap.java:245)
at org.glassfish.admin.monitor.MonitoringBootstrap.discoverProbeProviders(MonitoringBootstrap.java:188)
at org.glassfish.admin.monitor.MonitoringBootstrap.enableMonitoringForProbeProviders(MonitoringBootstrap.java:624)
at org.glassfish.admin.monitor.MonitoringBootstrap.postConstruct(MonitoringBootstrap.java:176)
at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:131)
at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:91)
at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:82)
at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:67)
at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:139)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:78)
at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:229)
at com.sun.enterprise.v3.server.AppServerStartup.doStart(AppServerStartup.java:145)
at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:136)
at com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.start(GlassFishImpl.java:79)
at org.glassfish.ejb.embedded.EJBContainerProviderImpl.createContainer(EJBContainerProviderImpl.java:204)
at org.glassfish.ejb.embedded.EJBContainerProviderImpl.createEJBContainer(EJBContainerProviderImpl.java:129)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:127)
at com.foo.service.TestModelServiceTest.setup(TestModelServiceTest.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:55)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:42)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:75)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at $Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.remote.internal.TypeCastDispatch.dispatch(TypeCastDispatch.java:30)
at org.gradle.messaging.remote.internal.WorkerProtocol.handleIncoming(WorkerProtocol.java:53)
at org.gradle.messaging.remote.internal.WorkerProtocol.handleIncoming(WorkerProtocol.java:31)
at org.gradle.messaging.remote.internal.ProtocolStack$ProtocolStage.handleIncoming(ProtocolStack.java:167)
at org.gradle.messaging.remote.internal.ProtocolStack$BottomStage.handleIncoming(ProtocolStack.java:277)
at org.gradle.messaging.remote.internal.ProtocolStack$BottomConnection$1.run(ProtocolStack.java:299)
at org.gradle.messaging.remote.internal.ProtocolStack$ExecuteRunnable.dispatch(ProtocolStack.java:120)
at org.gradle.messaging.remote.internal.ProtocolStack$ExecuteRunnable.dispatch(ProtocolStack.java:116)
at org.gradle.messaging.dispatch.AsyncDispatch.dispatchMessages(AsyncDispatch.java:132)
at org.gradle.messaging.dispatch.AsyncDispatch.access$000(AsyncDispatch.java:33)
at org.gradle.messaging.dispatch.AsyncDispatch$1.run(AsyncDispatch.java:72)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Nov 11, 2012 11:30:39 AM org.hibernate.validator.internal.util.Version <clinit>
INFO: HV000001: Hibernate Validator 4.3.0.Final
Nov 11, 2012 11:30:43 AM org.glassfish.ha.store.spi.BackingStoreFactoryRegistry register
INFO: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry
Nov 11, 2012 11:30:43 AM com.sun.enterprise.v3.server.AppServerStartup run
SEVERE: Startup service failed to start : com.sun.enterprise.naming.GlassFishNamingBuilder
Nov 11, 2012 11:30:43 AM com.sun.enterprise.v3.admin.StopServer doExecute
INFO: Server shutdown initiated
Process 'Gradle Worker 1' finished with exit value 0 (state: SUCCEEDED)
The Model
package com.foo.model;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table
public class TestModel implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private Long id;
private String test;
public TestModel() {
}
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
#Column(name = "id", insertable = false, updatable = false, nullable = false)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
#Column
public String getTest() {
return test;
}
public void setTest(String test) {
this.test = test;
}
}
The Service
package com.foo.service;
import javax.ejb.Stateless;
import javax.inject.Named;
import javax.persistence.EntityManager;
import com.foo.model.TestModel;
import javax.persistence.PersistenceContext;
#Named
#Stateless
public class TestModelService {
#PersistenceContext(unitName="TestPersistenceUnit")
private EntityManager em;
public void addTest(TestModel test) {
em.persist(test);
}
public void deleteTest(Long testId) {
TestModel test = em.find(TestModel.class, testId);
if(test != null) {
em.remove(test);
}
}
}
The Service Test
package com.foo.service;
import com.foo.model.TestModel;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.io.File;
import javax.xml.bind.JAXBException;
import org.junit.AfterClass;
import static org.junit.Assert.*;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ejb.embeddable.EJBContainer;
public class TestModelServiceTest {
Logger logger = LoggerFactory.getLogger(TestModelServiceTest.class);
static private TestModelService testService = null;
private static EJBContainer container;
public TestModelServiceTest() throws Exception {
}
#BeforeClass
static public void setup()
throws IOException, JAXBException
{
// domain.xml from http://embedded-glassfish.java.net/domain.xml
try {
Map<String, Object> props = new HashMap<String, Object>();
props.put(EJBContainer.MODULES, new File("target/classes"));
props.put(EJBContainer.APP_NAME, "test");
// Code never gets past this line!
container = EJBContainer.createEJBContainer(props);
// Never get to this
fail();
// Get a handle to the service through the context
testService = (TestModelService)container.getContext().lookup("java:global/classes/TestModelService");
} catch(Exception e) {
fail(e.toString());
}
}
#AfterClass
static public void teardown()
throws IOException
{
if(container != null) {
container.close();
}
}
#Test
public void testValidUser() throws Exception {
// TestModel a valid basic user
{
try {
TestModel test = new TestModel();
test.setTest("foo");
testService.addTest(test);
} catch(Exception e) {
fail(e.toString());
}
}
}
}
persistence.xml
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="TestPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.foo.Account</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.connection.url" value="jdbc:derby:memory:myDB;create=true"/>
<property name="hibernate.connection.driver_class" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.show_sql" value="true" />
</properties>
</persistence-unit>
</persistence>
build.gradle
// Create Eclipse Project
// Usage: from cmd line in project folder: gradle eclipse
apply plugin: 'java'
// Specify all projects (modules) should use maven central for repositories
allprojects {
repositories {
mavenCentral()
}
}
jar {
manifest.attributes['Implementation-Title'] = "test"
}
// Setup all dependencies
// Reference: http://gradle.org/docs/current/dsl/org.gradle.api.artifacts.dsl.DependencyHandler.html
dependencies {
compile 'org.hibernate:hibernate-entitymanager:4.1.4.Final'
compile 'org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final'
compile 'org.hibernate:hibernate-jpamodelgen:1.2.0.Final'
compile fileTree(dir: getGlassfishHomeDir() + File.separator + "glassfish" + File.separator + "modules", include: '*.jar')
testCompile 'junit:junit:4.10'
testCompile 'org.apache.derby:derby:10.9.1.0'
testRuntime 'org.glassfish.main.extras:glassfish-embedded-all:3.1.2'
testRuntime files(getGlassfishHomeDir() + File.separator + "glassfish"+ File.separator + "lib" + File.separator + "embedded" + File.separator + "glassfish-embedded-static-shell.jar")
}
def getGlassfishHomeDir() {
def glassfishHome = System.getenv('GLASSFISH_HOME')
if (glassfishHome == null || glassfishHome.length() <= 0)
{
msg = "No GLASSFISH_HOME in environment variable. Please set GLASSFISH_HOME to glassfish installation directory"
println msg
throw new RuntimeException(msg)
}
return glassfishHome
}
First
A major misconception to fix in your code is to assume that a JUnit test can have CDI beans injected.... No, JUnit tests can NOT have CDI beans injected EXCEPT via http://arquillian.org/invasion/ which I am not familiar with.
Second
The typical way to use CDI within GlassFish-Weld is within a servlet as explained in this documentation of Weld. Please refer to this presentation along with its slides for a perfect explanation. And please refer to this presentation for an example.
After watching presentations you can get the Managed Beans specifications JSR-316 as well as the famous CDI specifications JSR-299
Third
Yet your JUnit test the way it is now can be a legitimate test for your TestModelService stateless EJB using JNDI lookup by following these steps:
Make sure you added the jar file "glassfish-embedded-static-shell.jar" as an external library while it is at its original place "...glassfish\lib\embedded", thus don't copy it into your project. Doing this step - implicitly - makes the EJBContainer points to your locally installed glassfish domain.xml in your folder ...\glassfish\domains\domain1\config\domain.xml without you copying it into your project resources.
Make sure you are using the persistence.xml file you have on github not the one you have on this post. The one on github has a JTA transaction type pointing to your local Derby DB which is the right transaction type to access a container managed Entity Bean "TestModel". Also you can change the property: hibernate.hbm2ddl.auto" value="create" to become "create-drop".
In the persistence.xml file (on github) change the property exclude-unlisted-classes>true into exclude-unlisted-classes>false
Delete this line in your JUnit test:
props.put("org.glassfish.ejb.embedded.glassfish.web.http.port","");
Delete this line in your JUnit test as well
ctx = container.getContext();
Right before this line in your JUnit test
testService.addTest(test);
insert this this line:
TestModelService testService = (TestModelService)container.getContext().lookup("java:global/classes/TestModelService");
Run test.
Related
I have randomly this problem when I try to initialize ehcache:
Caused by: org.jboss.weld.exceptions.WeldException: WELD-000049 Unable to invoke [method] #PostConstruct private cerebro84.util.cache.CacheManagerServiceBean.initialize() on cerebro84.util.cache.CacheManagerServiceBean#3ee90439
at org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:405)
at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.postConstruct(ManagedBean.java:178)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:298)
at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:103)
at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:90)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79)
at cerebro84.util.cache.CacheManagerServiceBean$Proxy$_$$_WeldClientProxy.getFromCache(CacheManagerServiceBean$Proxy$_$$_WeldClientProxy.java)
at cerebro84.util.cache.CacheMethodInterceptor.getResultFromCache(CacheMethodInterceptor.java:29)
...
Caused by: java.lang.reflect.InvocationTargetException
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:498)
at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)
at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)
at org.jboss.weld.introspector.jlr.WeldMethodImpl.invoke(WeldMethodImpl.java:168)
at org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:403)
... 210 more
Caused by: java.lang.NoClassDefFoundError: net/sf/saxon/trans/XPathException
at net.sf.saxon.IdentityTransformerHandler.startDocument(IdentityTransformerHandler.java:110)
at com.sun.xml.bind.v2.runtime.unmarshaller.DomLoader$State.<init>(DomLoader.java:83)
at com.sun.xml.bind.v2.runtime.unmarshaller.DomLoader.startElement(DomLoader.java:118)
at com.sun.xml.bind.v2.runtime.unmarshaller.ProxyLoader.startElement(ProxyLoader.java:60)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:528)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:507)
at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:75)
at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:178)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:244)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:281)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:250)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:281)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:250)
at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:127)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:369)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:348)
at org.ehcache.xml.ConfigurationParser.<init>(ConfigurationParser.java:177)
at org.ehcache.xml.XmlConfiguration.parseConfiguration(XmlConfiguration.java:178)
at org.ehcache.xml.XmlConfiguration.<init>(XmlConfiguration.java:166)
at org.ehcache.xml.XmlConfiguration.<init>(XmlConfiguration.java:134)
at org.ehcache.jsr107.EhcacheCachingProvider$ConfigSupplier.getConfiguration(EhcacheCachingProvider.java:327)
at org.ehcache.jsr107.EhcacheCachingProvider.getCacheManager(EhcacheCachingProvider.java:127)
at org.ehcache.jsr107.EhcacheCachingProvider.getCacheManager(EhcacheCachingProvider.java:78)
at org.ehcache.jsr107.EhcacheCachingProvider.getCacheManager(EhcacheCachingProvider.java:186)
at cerebro84.util.cache.CacheManagerServiceBean.initialize(CacheManagerServiceBean.java:38)
... 220 more
The weird behavior is that if I restarted the container (weblogic), it works fine. This is the class I use to initialize the cache, trimming down to the bare essential:
import javax.annotation.PostConstruct;
import javax.cache.CacheManager;
import javax.cache.Caching;
import javax.enterprise.context.ApplicationScoped;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
#Slf4j
#ApplicationScoped
public class CacheManagerServiceBean {
private static final String EHCACHE_CONFIG_FILE_PATH = "/ehcache.xml";
#Getter
private CacheManager cacheManager = null;
#Getter
private boolean cacheEnabled = false;
#PostConstruct
private void initialize() {
logger.info("Instantiating cache manager");
try {
this.cacheManager = Caching.getCachingProvider().getCacheManager(
getClass().getResource(EHCACHE_CONFIG_FILE_PATH).toURI(),
getClass().getClassLoader());
cacheEnabled = true;
} catch (Exception|NoClassDefFoundError e) {
logger.error("Unable to enable cache", e);
}
}
}
I tried to add the following line
<wls:package-name>net.sf.saxon.*</wls:package-name>
to /META-INF/weblogic-application.xml, but this did't help. Saxon is a direct dependancy of the module:
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
<version>9.5.1-8</version>
</dependency>
The module is packaged as jar in a ear multimodule application.
Does anybody have any idea on how to make sure that the class XPathException is always found by saxon? Thank you in advance.
Problems like this are usually caused by having several different versions of Saxon on the classpath at the same time.
I'm working on a project for school. Part of the prompt for the application specifies that I'm supposed to add localization to the log in page to translate the text in to two other languages. I don't have any experience with localization and Internationalization so I looked up a tutorial on YouTube that you can find here.
The tutorial is slightly simpler than what I'm trying to do, but I thought that I extrapolated the information effectively. What I'm about to post is just a test to see if I could get the log-in prompt text to change language, based on a radio button selection by the user. Here is my log in controller class:
import java.net.URL;
import java.util.Locale;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
public class LogInController implements Initializable {
#FXML
private Label logInPrompt;
#FXML
private TextField userNameField;
#FXML
private TextField passwordTextField;
#FXML
private RadioButton english;
#FXML
private RadioButton spanish;
#FXML
private RadioButton french;
#FXML
public void Login(ActionEvent event) throws Exception {
if (userNameField.getText().equals("user") && passwordTextField.getText().equals("password")) {
logInPrompt.setText("Log in successful!");
Stage primaryStage = new Stage();
Parent root = FXMLLoader.load(getClass().getResource("MainMenu.fxml"));
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
} else {
logInPrompt.setText("Log in Failed");
}
}
public String enLang = "en";
public String spLang = "sp";
public String frLang = "fr";
public String unitedStates = "US";
public String mexico = "MX";
public String france = "FR";
Locale us = new Locale(enLang, unitedStates);
ResourceBundle rbEn = ResourceBundle.getBundle("C195/MessageBundle_en_US", us);
Locale mx = new Locale(spLang, mexico);
ResourceBundle rbSp = ResourceBundle.getBundle("C195/MessageBundle_es_MX", mx);
Locale fr = new Locale(frLang, france);
ResourceBundle rbFr = ResourceBundle.getBundle("C195/MessageBundle_fr_FR", fr);
public String enLogIn = rbEn.getString("logInPromptEN");
public String spLogIn = rbSp.getString("logInPromptSP");
public String frLogIn = rbFr.getString("logInPromptFR");
public void langSelect(){
if (english.isSelected()){
logInPrompt.setText(enLogIn);
}else if (spanish.isSelected()){
logInPrompt.setText(spLogIn);
}else if (french.isSelected()){
logInPrompt.setText(frLogIn);
}
}
#Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
}
Here is an example of one of my properties files, the other two are the same except they are for the other two languages:
logInPromptSP = Ingrese su nombre de usuario y contraseña:
The application runs if I comment out the localization code, but if I run it without the comment I get a list of exceptions and errors a mile long, very few of which I'm familiar with.
To try to figure this problem out, I went back and read through the Localization and Internationalization portion in my OCP study guide, and I searched through StackOverflow using search terms similar to the title of my question.
Any help anyone could offer me on this issue would be greatly appreciated. Also just a quick note: This is the first question I've ever posted on StackOverflow and I read the guidelines but I'm a complete noob at both programming and at using StackOverflow. So please kindly let me know if the way that I formatted my question or the problem I asked about is in any way inappropriate.
Here is the full stack trace:
ant -f C:\\Users\\Forbes\\Documents\\NetBeansProjects\\C195 jfxsa-run
init:
Deleting: C:\Users\Forbes\Documents\NetBeansProjects\C195\build\built- jar.properties
deps-jar:
Updating property file: C:\Users\Forbes\Documents\NetBeansProjects\C195\build\built-jar.properties
compile:
Deleting directory C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\lib
Copying 1 file to C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\lib
Detected JavaFX Ant API version 1.3
jfx-deployment:
jar:
Copying 13 files to C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\run302791547
jfx-project-run:
Executing C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\run302791547\C195.jar using platform C:\Program Files\Java\jdk1.8.0_51\jre/bin/java
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav a:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.j ava:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav a:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917 )
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$152(LauncherImp l.java:182)
at com.sun.javafx.application.LauncherImpl$$Lambda$51/1343441044.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: javafx.fxml.LoadException:
file:/C:/Users/Forbes/Documents/NetBeansProjects/C195/dist/run302791547/C195.jar!/c195/LoginXML.fxml:10
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2605)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2583)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2445)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3218)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3179)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3152)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3128)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3108)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3101)
at c195.C195.start(C195.java:13)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherIm pl.java:863)
at com.sun.javafx.application.LauncherImpl$$Lambda$54/1038706898.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java: 326)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/355629945.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
at com.sun.javafx.application.PlatformImpl$$Lambda$49/722855603.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:29 4)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/1915503092.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$145(WinApplication.java:101)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/1963387170.run(Unknown Source)
... 1 more
Caused by: java.util.MissingResourceException: Can't find bundle for base name C195/MessageBundle_en_US, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:845)
at c195.LogInController.<init>(LogInController.java:69)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorI mpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorA ccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at java.lang.Class.newInstance(Class.java:442)
at sun.reflect.misc.ReflectUtil.newInstance(ReflectUtil.java:51)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:923)
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.ja va:967)
at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:216)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2711)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2531)
... 22 more
Exception running application c195.C195
Java Result: -1073741819
Deleting directory C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\run302791547
jfxsa-run:
BUILD SUCCESSFUL (total time: 5 seconds)
Here is the updated stack trace after following your advice.
ant -f C:\\Users\\Forbes\\Documents\\NetBeansProjects\\C195 jfxsa-run
init:
Deleting: C:\Users\Forbes\Documents\NetBeansProjects\C195\build\built- jar.properties
deps-jar:
Updating property file: C:\Users\Forbes\Documents\NetBeansProjects\C195\build\built-jar.properties
compile:
Deleting directory C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\lib
Copying 1 file to C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\lib
Detected JavaFX Ant API version 1.3
jfx-deployment:
jar:
Copying 13 files to C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\run1318536498
jfx-project-run:
Executing C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\run1318536498\C195.jar using platform C:\Program Files\Java\jdk1.8.0_51\jre/bin/java
Exception in Application start method
java.lang.reflect.InvocationTargetException
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 com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.j ava:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav a:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917 )
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$152(LauncherImp l.java:182)
at com.sun.javafx.application.LauncherImpl$$Lambda$51/1343441044.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: javafx.fxml.LoadException:
file:/C:/Users/Forbes/Documents/NetBeansProjects/C195/dist/run1318536498/C195.ja r!/c195/LoginXML.fxml:10
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2605)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2583)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2445)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3218)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3179)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3152)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3128)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3108)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3101)
at c195.C195.start(C195.java:13)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherIm pl.java:863)
at com.sun.javafx.application.LauncherImpl$$Lambda$54/1361720784.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java: 326)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/355629945.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
at com.sun.javafx.application.PlatformImpl$$Lambda$49/722855603.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:29 4)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/1915503092.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$145(WinApplication.java:101)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/1963387170.run(Unknown Source)
... 1 more
Caused by: java.util.MissingResourceException: Can't find bundle for base name MessageBundle_en_US, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:845)
at c195.LogInController.<init>(LogInController.java:70)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorI mpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorA ccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at java.lang.Class.newInstance(Class.java:442)
at sun.reflect.misc.ReflectUtil.newInstance(ReflectUtil.java:51)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:923)
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.ja va:967)
at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:216)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2711)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2531)
... 22 more
Exception running application c195.C195
Java Result: -1073741819
Deleting directory C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\run1318536498
jfxsa-run:
BUILD SUCCESSFUL (total time: 5 seconds)
I'm using jaxb inside a jboss 5.0.1GA container, and seeing a strange exception at startup. It appears once only.
From the stacktrace you can see that it is during the class initialisation of FrameworkUtil class.
FrameworkUtil line 119 looks like this:
JAXBContext j = JAXBContext.newInstance(Validate.class, Response.class ....<more classes>);
Validate.java has this in it:
#XmlRootElement(name="validate")
public class Validate {
List<String> userGroups;
#XmlElementWrapper(name="userGroups")
#XmlElement(name="item")
public String[] getUserGroups() {
if (userGroups != null) {
return userGroups.toArray(new String[userGroups.size()]);
}
else return null;
}
public void setUserGroups(String[] userGrps) {
userGroups = new ArrayList<String>();
if (userGrps != null) {
for (String userGrp : userGrps) {
userGroups.add(new String(userGrp));
}
}
}
}
In the stack trace is a reference to Validate. But sometimes the stacktrace is different, and refers to the same field (userGroups) in Response.class instead.
Here's the stack trace:
Mar 19, 2015 11:20:50 AM com.sun.xml.bind.v2.runtime.reflect.opt.Injector inject
WARNING: duplicate class definition bug occured? Please report this : com/mycompany/ecommerce/message/beans/Validate$JaxbAccessorM_getUserGroups_setUserGroups_[Ljava_lang_String;
java.lang.ClassFormatError: Illegal class name "com/mycompany/ecommerce/message/beans/Validate$JaxbAccessorM_getUserGroups_setUserGroups_[Ljava_lang_String;" in class file com/mycompany/ecommerce/messa
ge/beans/Validate$JaxbAccessorM_getUserGroups_setUserGroups_[Ljava_lang_String;
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
at sun.reflect.GeneratedMethodAccessor209.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.xml.bind.v2.runtime.reflect.opt.Injector.inject(Injector.java:205)
at com.sun.xml.bind.v2.runtime.reflect.opt.Injector.inject(Injector.java:85)
at com.sun.xml.bind.v2.runtime.reflect.opt.AccessorInjector.prepare(AccessorInjector.java:89)
at com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.get(OptimizedAccessorFactory.java:114)
at com.sun.xml.bind.v2.runtime.reflect.Accessor$GetterSetterReflection.optimize(Accessor.java:369)
at com.sun.xml.bind.v2.runtime.property.ArrayProperty.<init>(ArrayProperty.java:65)
at com.sun.xml.bind.v2.runtime.property.ArrayERProperty.<init>(ArrayERProperty.java:84)
at com.sun.xml.bind.v2.runtime.property.ArrayElementProperty.<init>(ArrayElementProperty.java:96)
at com.sun.xml.bind.v2.runtime.property.ArrayElementLeafProperty.<init>(ArrayElementLeafProperty.java:66)
at sun.reflect.GeneratedConstructorAccessor172.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.sun.xml.bind.v2.runtime.property.PropertyFactory.create(PropertyFactory.java:124)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.<init>(ClassBeanInfoImpl.java:179)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getOrCreate(JAXBContextImpl.java:515)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:330)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121)
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:606)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:248)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:235)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:432)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:637)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
at com.mycompany.global.er.util.FrameworkUtil.<clinit>(FrameworkUtil.java:119)
Did you check this bug out ?
Seems to be fixed in version 2.2.11 of jaxb implementation.
Maybe you could try and replace jaxb JAR files, they're probably in you server's lib, unless your webapp overwrites them in it's own lib folder.
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
Just a shot in the dark, but do I need a local interface to call a remote stateless EJB?
when I try call the bean remotely through Netbeans:
Netbeans doesn't allow a remote call, or any call, on this bean. Why not?
Trying to do it manually, as below:
What is the jndi global remote name for the Remote EJB which is deployed on glassfish?
INFO: visiting unvisited references
INFO: visiting unvisited references
INFO: EJB5181:Portable JNDI names for EJB MyRemoteSessionClass: [java:global/RemoteSalutation-ejb/MyRemoteSessionClass!net.bounceme.dur.glassfish.MyRemoteSession, java:global/RemoteSalutation-ejb/MyRemoteSessionClass]
INFO: RemoteSalutation-ejb was successfully deployed in 941 milliseconds.
If possible, I would rather specify the class in the properties file rather than hard-coded. In any event, different variations result in a lookup failure. Here's the stack-trace:
run-deploy:
Copying 1 file to /home/thufir/NetBeansProjects/RemoteLookup/dist
Copying 2 files to /home/thufir/NetBeansProjects/RemoteLookup/dist/RemoteLookupClient
Warning: /home/thufir/NetBeansProjects/RemoteLookup/dist/gfdeploy/RemoteLookup does not exist.
Sep 13, 2014 1:35:41 AM net.bounceme.dur.remote.RemoteLookup run
INFO: java.naming.factory.initial com.sun.enterprise.naming.impl.SerialInitContextFactory
Sep 13, 2014 1:35:41 AM net.bounceme.dur.remote.RemoteLookup run
INFO: java.naming.factory.url.pkgs com.sun.enterprise.naming
Sep 13, 2014 1:35:41 AM net.bounceme.dur.remote.RemoteLookup run
INFO: java.naming.factory.state com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl
Sep 13, 2014 1:35:46 AM net.bounceme.dur.remote.RemoteLookup main
SEVERE: Lookup failed for ' java:comp/env//RemoteSalutation-ejb/MyRemoteSessionClass!net/bounceme/dur/glassfish/MyRemoteSession' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, remote=net.bounceme.ix.Foo, org.omg.CORBA.ORBInitialHost=localhost, java.naming.security.principal=user, org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.provider.url=server.local:1199, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.security.credentials=password}
javax.naming.NamingException: Lookup failed for ' java:comp/env//RemoteSalutation-ejb/MyRemoteSessionClass!net/bounceme/dur/glassfish/MyRemoteSession' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, remote=net.bounceme.ix.Foo, org.omg.CORBA.ORBInitialHost=localhost, java.naming.security.principal=user, org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.provider.url=server.local:1199, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.security.credentials=password} [Root exception is javax.naming.NameNotFoundException: java:comp]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at net.bounceme.dur.remote.RemoteLookup.run(RemoteLookup.java:34)
at net.bounceme.dur.remote.RemoteLookup.main(RemoteLookup.java:18)
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:606)
at org.glassfish.appclient.client.acc.AppClientContainer.launch(AppClientContainer.java:446)
at org.glassfish.appclient.client.AppClientFacade.main(AppClientFacade.java:166)
Caused by: javax.naming.NameNotFoundException: java:comp
at com.sun.enterprise.naming.impl.TransientContext.resolveContext(TransientContext.java:299)
at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:207)
at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:66)
at com.sun.enterprise.naming.impl.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.java:109)
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:606)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie.dispatchToMethod(ReflectiveTie.java:143)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:173)
at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatchToServant(ServerRequestDispatcherImpl.java:528)
at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatch(ServerRequestDispatcherImpl.java:199)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequestRequest(MessageMediatorImpl.java:1549)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:1425)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleInput(MessageMediatorImpl.java:930)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:213)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:694)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.dispatch(MessageMediatorImpl.java:496)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.doWork(MessageMediatorImpl.java:2222)
at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
run:
BUILD SUCCESSFUL (total time: 17 seconds)
client code:
package net.bounceme.dur.remote;
import java.util.Enumeration;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class RemoteLookup {
private static final Logger log = Logger.getLogger(RemoteLookup.class.getName());
private final MyProps p = new MyProps();
public static void main(String... args) {
try {
new RemoteLookup().run();
} catch (NamingException ex) {
Logger.getLogger(RemoteLookup.class.getName()).log(Level.SEVERE, ex.getExplanation(), ex);
}
}
private void run() throws NamingException {
Properties jndi = p.getJNDI();
Enumeration e = jndi.propertyNames();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
String val = jndi.getProperty(key);
log.info(key + "\t" + val);
}
Context ic = new InitialContext();
// Object o = ic.lookup(" java:comp/env/RemoteSalutation-ejb/MyRemoteSessionClass");
Object o = ic.lookup(" java:comp/env//RemoteSalutation-ejb/MyRemoteSessionClass!net/bounceme/dur/glassfish/MyRemoteSession");
}
}
the remote EJB:
package net.bounceme.dur.glassfish;
import javax.ejb.Stateless;
//#LocalBean
#Stateless(mappedName = "salutationBean")
public class MyRemoteSessionClass implements MyRemoteSession {
#Override
public String SayHello() {
return "hello from glassfish..";
}
#Override
public String SayBye() {
return "goodbye..";
}
}
note that the interface is remote, ie: it's literally a Java class library. Correct? This makes the EJB remote.
referencing:
https://netbeans.org/kb/docs/javaee/entappclient.html
although I changed the names a bit..otherwise should be exactly as the tutorial.
Try Object o = ic.lookup("salutationBean");
Note that mappedName specifies the name to use in JNDI for a remote access.
I have run into a very strange error that I can´t wrap my head around. I´m running Seam 2.2.1.CR2 and JBoss 4.3.0.GA. My application consist of 3 modules:
application.xml
<display-name>CoolWebApp</display-name>
<module id="EJB3">
<ejb>EJB3.jar</ejb>
</module>
<module id="WEB">
<web>
<web-uri>WEB.war</web-uri>
<context-root>/</context-root>
</web>
</module>
<module>
<ejb>jboss-seam-2.2.1.CR2.jar</ejb>
</module>
The following bean is scheduled and should run asynchronously. It resides in my EJB3 module:
package com.coolwebapp.indexing;
import org.apache.commons.lang.time.DateUtils;
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Startup;
import org.jboss.seam.annotations.Transactional;
import org.jboss.seam.annotations.async.Asynchronous;
import org.jboss.seam.annotations.async.Expiration;
import org.jboss.seam.annotations.async.IntervalDuration;
import org.jboss.seam.core.Events;
import org.jboss.seam.log.Log;
import com.coolwebapp.events.CompanyTouched;
import com.coolwebapp.model.Company;
import com.coolwebapp.model.CompanyInNeedOfIndexing;
import javax.persistence.EntityManager;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
*/
#Name("indexBean")
#AutoCreate
public class IndexBean {
#Logger
private static Log log;
/**
* #return Will fetch an applicationBean
*/
private EntityManager entityManager() {
return (EntityManager) Component.getInstance("entityManager", true);
}
#SuppressWarnings({"unchecked"})
#Transactional
#Asynchronous
public void investigatePendingIndexings(#Expiration Date when, #IntervalDuration Long interval) {
log.info("IndexBean.investigatePendingIndexings()");
final EntityManager em = entityManager();
List<CompanyInNeedOfIndexing> indexingTasks =
em.createQuery(
"from CompanyInNeedOfIndexing C where C.hasBeenIndexedOnNode not like :nodeName")
.setParameter("nodeName", getNodeName())
.getResultList();
Map<Long, Company> idToCompanyToIndexMap = new HashMap<Long, Company>();
for (CompanyInNeedOfIndexing indexingTask : indexingTasks) {
final Company company = indexingTask.getCompany();
final long id = company.getId();
if (!idToCompanyToIndexMap.containsKey(id))
idToCompanyToIndexMap.put(id, company);
}
for (Company company : idToCompanyToIndexMap.values()) {
log.info("Indexing " + company.getName());
Events.instance().raiseEvent(CompanyTouched.EVENT_NAME, company, em);
em.persist(new CompanyInNeedOfIndexing(company, getNodeName()));
}
}
private String getNodeName() {
return "N0"; // TODO get from -D param
}
#Startup(depends = {"applicationBean", "entityManager"})
#Scope(ScopeType.APPLICATION)
#Name("indexBeanKicker")
public static class Kicker {
private final long INTERVAL = 15;
#In
private IndexBean indexBean;
#Create
public void initBean() {
log.info("Will check for indexing every " + INTERVAL + " minutes.");
final Date firstRunIn30sec = new Date(30 * DateUtils.MILLIS_PER_SECOND + System.currentTimeMillis());
indexBean.investigatePendingIndexings(
firstRunIn30sec,
INTERVAL * DateUtils.MILLIS_PER_MINUTE);
}
}
}
When the event is raised following bean picks it up(also in EJB3 module):
package com.coolwebpp.search.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lucene.document.Document;
import org.hibernate.annotations.common.reflection.java.JavaReflectionManager;
import org.hibernate.search.engine.DocumentBuilder;
import org.hibernate.search.jpa.FullTextEntityManager;
import org.hibernate.search.jpa.Search;
import org.hibernate.search.store.NotShardedStrategy;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Observer;
import org.jboss.seam.annotations.Scope;
import com.coolwebapp.events.CompanyTouched;
import com.coolwebapp.model.Company;
import javax.persistence.EntityManager;
import java.io.Serializable;
#Name("indexUtils")
#AutoCreate
#Scope(ScopeType.SESSION)
public class IndexUtils implements ArticleSaved, ReviewsUpdated, CompanyPublished, CompanyRemoved, SearchWordsUpdated, CompanyTouched, Serializable {
public final static Log log = LogFactory.getLog(IndexUtils.class);
public IndexUtils() {
}
public static FullTextEntityManager getFullTextEntityManager(EntityManager entityManager) {
if (entityManager instanceof FullTextEntityManager)
return (FullTextEntityManager) entityManager;
else
return Search.createFullTextEntityManager(entityManager);
}
private void reindexWithoutModifyingLastUpdated(Company company, EntityManager entityManager) {
log.warn("--------------->>> Reindexing without updating lastModified: " + company.getName());
getFullTextEntityManager(entityManager).index(company);
}
#Observer(CompanyTouched.EVENT_NAME)
public void handleCompanyTouched(Company owningCompany, EntityManager entityManager) {
reindexWithoutModifyingLastUpdated(owningCompany, entityManager);
}
}
components.xml
<persistence:managed-persistence-context name="entityManager"
auto-create="true"
entity-manager-factory="#{entityManagerFactory}"/>
<persistence:entity-manager-factory name="entityManagerFactory"
persistence-unit-name="theDatabase"/>
When I start the application and the kicker kicks in everything works well until
getFullTextEntityManager(entityManager).index(company);
Then following exception is thrown:
11:10:34,681 ERROR [AsynchronousExceptionHandler] Exception thrown whilst executing asynchronous call
java.lang.IllegalArgumentException: interface org.jboss.seam.persistence.EntityManagerProxy is not visible from class loader
at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
at org.jboss.seam.persistence.PersistenceProvider.proxyEntityManager(PersistenceProvider.java:220)
at org.jboss.seam.persistence.HibernatePersistenceProvider.proxyEntityManager(HibernatePersistenceProvider.java:314)
at org.jboss.seam.persistence.ManagedPersistenceContext.initEntityManager(ManagedPersistenceContext.java:81)
at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManager(ManagedPersistenceContext.java:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
at org.jboss.seam.Component.callComponentMethod(Component.java:2275)
at org.jboss.seam.Component.unwrap(Component.java:2301)
at org.jboss.seam.Component.getInstance(Component.java:2044)
at org.jboss.seam.Component.getInstance(Component.java:1986)
at org.jboss.seam.Component.getInstance(Component.java:1980)
at com.coolwebapp.indexing.IndexBean.entityManager(IndexBean.java:43)
at com.coolwebapp.indexing.IndexBean.investigatePendingIndexings(IndexBean.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:97)
at org.jboss.seam.util.Work.workInTransaction(Work.java:61)
at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:52)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
at com.coolwebapp.indexing.IndexBean_$$_javassist_seam_2.investigatePendingIndexings(IndexBean_$$_javassist_seam_2.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
at org.jboss.seam.async.AsynchronousInvocation$1.process(AsynchronousInvocation.java:62)
at org.jboss.seam.async.Asynchronous$ContextualAsynchronousRequest.run(Asynchronous.java:80)
at org.jboss.seam.async.AsynchronousInvocation.execute(AsynchronousInvocation.java:44)
at org.jboss.seam.async.QuartzDispatcher$QuartzJob.execute(QuartzDispatcher.java:243)
at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
if I add scope to my managed-persistance-context:
<persistence:managed-persistence-context name="entityManager"
auto-create="true" scope="APPLICATION"
entity-manager-factory="#{entityManagerFactory}"/>
<persistence:entity-manager-factory name="entityManagerFactory"
persistence-unit-name="theDatabase"/>
I get the following error:
10:49:46,689 WARN [HibernatePersistenceProvider] Unable to wrap into a FullTextSessionProxy, regular SessionProxy returned
java.lang.IllegalArgumentException: interface org.jboss.seam.persistence.FullTextHibernateSessionProxy is not visible from class loader
at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
at org.jboss.seam.persistence.HibernatePersistenceProvider.proxySession(HibernatePersistenceProvider.java:119)
at org.jboss.seam.persistence.HibernatePersistenceProvider.proxyDelegate(HibernatePersistenceProvider.java:142)
at org.jboss.seam.persistence.EntityManagerInvocationHandler.handleGetDelegate(EntityManagerInvocationHandler.java:81)
at org.jboss.seam.persistence.EntityManagerInvocationHandler.invoke(EntityManagerInvocationHandler.java:40)
at $Proxy229.getDelegate(Unknown Source)
at org.hibernate.search.jpa.impl.FullTextEntityManagerImpl.getFullTextSession(FullTextEntityManagerImpl.java:32)
at org.hibernate.search.jpa.impl.FullTextEntityManagerImpl.index(FullTextEntityManagerImpl.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.persistence.EntityManagerInvocationHandler.invoke(EntityManagerInvocationHandler.java:46)
at $Proxy230.index(Unknown Source)
at com.coolwebapp.search.util.IndexUtils.reindexWithoutModifyingLastUpdated(IndexUtils.java:85)
at com.coolwebapp.search.util.IndexUtils.handleCompanyTouched(IndexUtils.java:115)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
at com.coolwebapp.search.util.IndexUtils_$$_javassist_seam_21.handleCompanyTouched(IndexUtils_$$_javassist_seam_21.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
at org.jboss.seam.Component.callComponentMethod(Component.java:2279)
at org.jboss.seam.core.Events.raiseEvent(Events.java:85)
at com.coolwebapp.indexing.IndexBean.investigatePendingIndexings(IndexBean.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:97)
at org.jboss.seam.util.Work.workInTransaction(Work.java:61)
at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:52)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
at com.coolwebapp.indexing.IndexBean_$$_javassist_seam_2.investigatePendingIndexings(IndexBean_$$_javassist_seam_2.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
at org.jboss.seam.async.AsynchronousInvocation$1.process(AsynchronousInvocation.java:62)
at org.jboss.seam.async.Asynchronous$ContextualAsynchronousRequest.run(Asynchronous.java:80)
at org.jboss.seam.async.AsynchronousInvocation.execute(AsynchronousInvocation.java:44)
at org.jboss.seam.async.QuartzDispatcher$QuartzJob.execute(QuartzDispatcher.java:243)
at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
10:49:46,702 ERROR [AsynchronousExceptionHandler] Exception thrown whilst executing asynchronous call
java.lang.RuntimeException: could not proxy delegate
at org.jboss.seam.persistence.HibernatePersistenceProvider.proxyDelegate(HibernatePersistenceProvider.java:150)
at org.jboss.seam.persistence.EntityManagerInvocationHandler.handleGetDelegate(EntityManagerInvocationHandler.java:81)
at org.jboss.seam.persistence.EntityManagerInvocationHandler.invoke(EntityManagerInvocationHandler.java:40)
at $Proxy229.getDelegate(Unknown Source)
at org.hibernate.search.jpa.impl.FullTextEntityManagerImpl.getFullTextSession(FullTextEntityManagerImpl.java:32)
at org.hibernate.search.jpa.impl.FullTextEntityManagerImpl.index(FullTextEntityManagerImpl.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.persistence.EntityManagerInvocationHandler.invoke(EntityManagerInvocationHandler.java:46)
at $Proxy230.index(Unknown Source)
at com.coolwebapp.search.util.IndexUtils.reindexWithoutModifyingLastUpdated(IndexUtils.java:85)
at com.coolwebapp.search.util.IndexUtils.handleCompanyTouched(IndexUtils.java:115)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
at com.coolwebapp.search.util.IndexUtils_$$_javassist_seam_21.handleCompanyTouched(IndexUtils_$$_javassist_seam_21.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
at org.jboss.seam.Component.callComponentMethod(Component.java:2279)
at org.jboss.seam.core.Events.raiseEvent(Events.java:85)
at com.coolwebapp.indexing.IndexBean.investigatePendingIndexings(IndexBean.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:97)
at org.jboss.seam.util.Work.workInTransaction(Work.java:61)
at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:52)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
at com.coolwebapp.indexing.IndexBean_$$_javassist_seam_2.investigatePendingIndexings(IndexBean_$$_javassist_seam_2.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
at org.jboss.seam.async.AsynchronousInvocation$1.process(AsynchronousInvocation.java:62)
at org.jboss.seam.async.Asynchronous$ContextualAsynchronousRequest.run(Asynchronous.java:80)
at org.jboss.seam.async.AsynchronousInvocation.execute(AsynchronousInvocation.java:44)
at org.jboss.seam.async.QuartzDispatcher$QuartzJob.execute(QuartzDispatcher.java:243)
at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
Caused by: java.lang.IllegalArgumentException: interface org.jboss.seam.persistence.HibernateSessionProxy is not visible from class loader
at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
at org.jboss.seam.persistence.HibernatePersistenceProvider.proxySession(HibernatePersistenceProvider.java:125)
at org.jboss.seam.persistence.HibernatePersistenceProvider.proxyDelegate(HibernatePersistenceProvider.java:142)
... 74 more
The fulltextentitymanager comes from hibernatesearch-3.0.1.GA.
If I remove the line calling .index saving the entity works( em.persist(new CompanyInNeedOfIndexing(company, getNodeName())); ), but only if I have the scope set to APPLICATION.
Do you have any ideas why this doesn't work? Do you any tips or do you need more information?
Short answer:
Check if hibernatesearch.jar and quartz.jar are in the same library directory, that is both in default/lib (or <yourserver>/lib).
You may have quartz.jar coming from quartz-ra.rar, that should also works. However, if you don't need the quart-ra.rar facilities I suggest you to remove it and put quartz.jar in default/lib.
Long answer:
When you configure the Quartz dispatcher to manage asynchronous jobs in Seam, that jobs run in the quartz threads pool that is created at startup time. There is much logic in Java EE that depends on Thread.currentThread().getContextClassLoader() so it's critical for the threads in the pool to be associated to the correct classloader.
What you should avoid is reusing the thread pool that is commonly created by the quartz-ra.rar module installed by default in JBoss.
You have two options here. Either you remove quartz-ra.rar module (if not needed) and put quartz.jar in server/lib, or you configure a custom quartz configuration for your application creating a seam.quartz.properties file in the root of the application classpath.
In the custom seam.quartz.properties you define an instance name different by the default one, so that your application keeps using her private threads pool:
org.quartz.scheduler.instanceName = MyApplicationQuartzInstance
org.quartz.scheduler.instanceId = 1
org.quartz.scheduler.rmi.export = false
org.quartz.scheduler.rmi.proxy = false
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 5
Creating a seam.quartz.properties is a good idea anyway, because you can tune some other quartz parameters like threadCount.