Infinispan 9 - Server exception when trying to put an object in cache using Hotrod client and Protobuf - infinispan

I have a problem using Infinispan 9.4.0/9.4.1 with Hot Rod Client and Protobuf protocol in order to be able to use queries.
This is my cache configuration:
<cache-container name="clustered" default-cache="RequestIndexed" statistics="false">
<transport channel="cluster" lock-timeout="1000"/>
<global-state/>
<modules>
<module name="deployment.infinispan-module.jar"/>
</modules>
<replicated-cache name="RequestIndexedIndexLockingCache" remote-timeout="3000" statistics-available="false">
<indexing index="NONE"/>
</replicated-cache>
<replicated-cache name="RequestIndexedIndexDataCache" remote-timeout="3000" statistics-available="false">
<indexing index="NONE"/>
</replicated-cache>
<replicated-cache name="RequestIndexedIndexMetadataCache" remote-timeout="3000" statistics-available="false">
<indexing index="NONE"/>
</replicated-cache>
<distributed-cache name="RequestIndexed" remote-timeout="3000" statistics-available="false">
<memory>
<object size="20" strategy="LRU"/>
</memory>
<compatibility enabled="true"/>
<file-store path="system-store" passivation="true"/>
<indexing index="PRIMARY_OWNER">
<property name="default.indexmanager">
org.infinispan.query.indexmanager.InfinispanIndexManager
</property>
<property name="default.locking_cachename">
RequestIndexedIndexLockingCache
</property>
<property name="default.data_cachename">
RequestIndexedIndexDataCache
</property>
<property name="default.metadata_cachename">
RequestIndexedIndexMetadataCache
</property>
</indexing>
<state-transfer timeout="60000" chunk-size="1024"/>
</distributed-cache>
</cache-container>
My entity
public class EntityDemo implements Serializable {
/** Class serial version UID. */
private static final long serialVersionUID = 1L;
private long id;
private String name;
private String value;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getKey() {
return String.valueOf(id);
}
}
The proto file
package test.infinispan.entity;
option indexed_by_default = false;
message EntityDemo {
/*#Field*/
required int64 id = 1;
/*#Field*/
required string name = 2;
optional string value = 3;
}
The marshaller
public class EntityDemoMarshaller implements Serializable, MessageMarshaller<EntityDemo> {
/** Class serial version UID. */
private static final long serialVersionUID = 1L;
#Override
public Class<? extends EntityDemo> getJavaClass() {
return EntityDemo.class;
}
#Override
public String getTypeName() {
return "test.infinispan.entity.EntityDemo";
}
#Override
public EntityDemo readFrom(ProtoStreamReader reader) throws IOException {
final EntityDemo ed = new EntityDemo();
ed.setId(reader.readLong("id"));
ed.setName(reader.readString("name"));
ed.setValue(reader.readString("value"));
return null;
}
#Override
public void writeTo(ProtoStreamWriter writer, EntityDemo ed) throws IOException {
writer.writeLong("id", ed.getId());
writer.writeString("name", ed.getName());
writer.writeString("value", ed.getValue());
}
}
The cache configuration
<distributed-cache name="core.request" remote-timeout="3000" statistics-available="false">
<memory>
<object size="20" strategy="LRU"/>
</memory>
<file-store path="cache-store" passivation="true"/>
<indexing index="NONE"/>
<state-transfer timeout="60000" chunk-size="1024"/>
<encoding>
<key media-type="application/x-jboss-marshalling"/>
<value media-type="application/x-jboss-marshalling"/>
</encoding>
</distributed-cache>
My connection to Infinispan
ConfigurationBuilder cbi = new ConfigurationBuilder();
cbi.addServers("localhost:11222");
cbi.marshaller(new ProtoStreamMarshaller());
RemoteCacheManager rcmi = new RemoteCacheManager(cbi.build());
SerializationContext sc = ProtoStreamMarshaller.getSerializationContext(rcmi);
FileDescriptorSource fds = new FileDescriptorSource();
fds.addProtoFiles("/proto/EntityDemo.proto");
sc.registerProtoFiles(fds);
sc.registerMarshaller(new EntityDemoMarshaller());
RemoteCache<String, String> metadataCache = rcmi.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
metadataCache.put("/proto/EntityDemo.proto", readProtoFile("/proto/EntityDemo.proto"));
RemoteCache<String, EntityDemo> rci = rcmi.getCache("RequestIndexed");
rci.clear();
EntityDemo ei = new EntityDemo();
ei.setId(1);
ei.setName("DemoIndexed");
ei.setValue("DemoIndexed");
rci.put(ei.getKey(), ei);
QueryFactory qf = Search.getQueryFactory(rci);
Query q = qf.from(EntityDemo.class)
.having("id").gte(1)
.build();
q.list().stream().forEach(v -> System.out.println(v));
I put my entity in a jar file (infinispan-module.jar) and then i deployed that jar in Infinispan.
When i try to put an object in the cache, i get the following exception in the server
[Server:instance-one] 13:48:17,477 ERROR [stderr] (HotRod-ServerHandler-4-10) Exception in thread "HotRod-ServerHandler-4-10" java.lang.IllegalArgumentException: No marshaller registered for test.infinispan.entity.EntityDemo
[Server:instance-one] 13:48:17,478 ERROR [stderr] (HotRod-ServerHandler-4-10) at org.infinispan.protostream.impl.SerializationContextImpl.getMarshallerDelegate(SerializationContextImpl.java:276)
[Server:instance-one] 13:48:17,479 ERROR [stderr] (HotRod-ServerHandler-4-10) at org.infinispan.protostream.WrappedMessage.readMessage(WrappedMessage.java:379)
[Server:instance-one] 13:48:17,479 ERROR [stderr] (HotRod-ServerHandler-4-10) at org.infinispan.protostream.ProtobufUtil.fromWrappedByteArray(ProtobufUtil.java:165)
[Server:instance-one] 13:48:17,480 ERROR [stderr] (HotRod-ServerHandler-4-10) at org.infinispan.protostream.ProtobufUtil.fromWrappedByteArray(ProtobufUtil.java:160)
[Server:instance-one] 13:48:17,480 ERROR [stderr] (HotRod-ServerHandler-4-10) at org.infinispan.query.remote.impl.dataconversion.ProtostreamObjectTranscoder.transcode(ProtostreamObjectTranscoder.java:42)
[Server:instance-one] 13:48:17,481 ERROR [stderr] (HotRod-ServerHandler-4-10) at org.infinispan.encoding.DataConversion.toStorage(DataConversion.java:214)
[Server:instance-one] 13:48:17,481 ERROR [stderr] (HotRod-ServerHandler-4-10) at org.infinispan.cache.impl.EncoderCache.valueToStorage(EncoderCache.java:111)
[Server:instance-one] 13:48:17,482 ERROR [stderr] (HotRod-ServerHandler-4-10) at org.infinispan.cache.impl.EncoderCache.putAsync(EncoderCache.java:460)
[Server:instance-one] 13:48:17,482 ERROR [stderr] (HotRod-ServerHandler-4-10) at org.infinispan.cache.impl.AbstractDelegatingAdvancedCache.putAsync(AbstractDelegatingAdvancedCache.java:386)
[Server:instance-one] 13:48:17,482 ERROR [stderr] (HotRod-ServerHandler-4-10) at org.infinispan.server.hotrod.CacheRequestProcessor.putInternal(CacheRequestProcessor.java:194)
[Server:instance-one] 13:48:17,483 ERROR [stderr] (HotRod-ServerHandler-4-10) at org.infinispan.server.hotrod.CacheRequestProcessor.lambda$put$6(CacheRequestProcessor.java:187)
[Server:instance-one] 13:48:17,484 ERROR [stderr] (HotRod-ServerHandler-4-10) at org.infinispan.server.hotrod.CacheRequestProcessor$$Lambda$745/1582212530.run(Unknown Source)
[Server:instance-one] 13:48:17,484 ERROR [stderr] (HotRod-ServerHandler-4-10) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[Server:instance-one] 13:48:17,484 ERROR [stderr] (HotRod-ServerHandler-4-10) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[Server:instance-one] 13:48:17,484 ERROR [stderr] (HotRod-ServerHandler-4-10) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
[Server:instance-one] 13:48:17,485 ERROR [stderr] (HotRod-ServerHandler-4-10) at java.lang.Thread.run(Thread.java:745)
Can anyone help me with this? I have searching for a solution, but i can't found anything.
UPDATE 2018-11-07
I have a new problem.
I need to use listeners with filters and converters. When i use only filters, everything it's ok, but when i add a converter i get an exception on server side. I just want to receive the objet put in cache on the CREATE custom event.
The filter class
public class RequestEventFilter implements Serializable, CacheEventFilter<String, EntityDemo> {
/** Class serial version UID. */
private static final long serialVersionUID = 1L;
private final long filter;
public RequestEventFilter(Object[] params) {
this.filter = (Long) params[0];
}
#Override
public boolean accept(String key, EntityDemo oldValue, Metadata oldMetadata, EntityDemo newValue, Metadata newMetadata, EventType eventType) {
if (eventType.isCreate()) {
if (newValue.getId() % filter == 0)
return true;
}
return false;
}
}
The filter factory class
#NamedFactory(name="request-event-filter-factory")
public class RequestEventFilterFactory implements CacheEventFilterFactory {
public RequestEventFilterFactory() {
}
#Override
#SuppressWarnings("unchecked")
public CacheEventFilter<String, EntityDemo> getFilter(Object[] params) {
return new RequestEventFilter(params);
}
}
The converter class
public class RequestEventConverter implements Serializable, CacheEventConverter<String, EntityDemo, EntityDemo> {
/** Class serial version UID. */
private static final long serialVersionUID = 1L;
public RequestEventConverter() {
}
#Override
public EntityDemo convert(String key, EntityDemo oldValue, Metadata oldMetadata, EntityDemo newValue, Metadata newMetadata, EventType eventType) {
if (newValue != null)
return newValue;
else
return oldValue;
}
}
The converter factory
#NamedFactory(name="request-event-converter-factory")
public class RequestEventConverterFactory implements CacheEventConverterFactory {
public RequestEventConverterFactory() {
}
#Override
#SuppressWarnings("unchecked")
public CacheEventConverter<String, EntityDemo, EntityDemo> getConverter(Object[] params) {
return new RequestEventConverter();
}
}
My Listener
#ClientListener(filterFactoryName="request-event-filter-factory", converterFactoryName="request-event-converter-factory", includeCurrentState = true, useRawData=false)
private class Listener {
public Listener() {
}
#ClientCacheEntryCreated
public void entryCreated(ClientCacheEntryCustomEvent<EntityDemo> event) {
System.out.println("Entry created!");
System.out.println(event.getEventData());
}
}
I add the listener with this code
this.cache.addClientListener(new Listener(), new Object[] {2L}), new Object[]{});
When i put a new object into infinispan cache, i get the following exception:
[Server:instance-one] 19:08:56,053 ERROR [org.infinispan.interceptors.impl.InvocationContextInterceptor] (HotRod-ServerHandler-4-103) ISPN000136: Error executing command PutKeyValueCommand, writing keys [WrappedByteArray{bytes=[B0x033E023134, hashCode=33250249}]: org.infinispan.commons.CacheListenerException: ISPN000280: Caught exception [java.lang.ClassCastException] while invoking method [public void org.infinispan.server.hotrod.ClientListenerRegistry$BaseClientEventSender.onCacheEvent(org.infinispan.notifications.cachelistener.event.CacheEntryEvent)] on listener instance: org.infinispan.server.hotrod.ClientListenerRegistry$StatefulClientEventSender#72f19221
[Server:instance-one] at org.infinispan.notifications.impl.AbstractListenerImpl$ListenerInvocationImpl.lambda$invoke$1(AbstractListenerImpl.java:387)
[Server:instance-one] at org.infinispan.notifications.impl.AbstractListenerImpl$ListenerInvocationImpl$$Lambda$560/2000982649.run(Unknown Source)
[Server:instance-one] at org.infinispan.util.concurrent.WithinThreadExecutor.execute(WithinThreadExecutor.java:20)
[Server:instance-one] at org.infinispan.notifications.impl.AbstractListenerImpl$ListenerInvocationImpl.invoke(AbstractListenerImpl.java:404)
[Server:instance-one] at org.infinispan.notifications.cachelistener.CacheNotifierImpl$BaseCacheEntryListenerInvocation.doRealInvocation(CacheNotifierImpl.java:1689)
[Server:instance-one] at org.infinispan.notifications.cachelistener.CacheNotifierImpl$ClusteredListenerInvocation.doRealInvocation(CacheNotifierImpl.java:1586)
[Server:instance-one] at org.infinispan.notifications.cachelistener.CacheNotifierImpl$BaseCacheEntryListenerInvocation.invokeNoChecks(CacheNotifierImpl.java:1680)
[Server:instance-one] at org.infinispan.notifications.cachelistener.CacheNotifierImpl$BaseCacheEntryListenerInvocation.invoke(CacheNotifierImpl.java:1654)
[Server:instance-one] at org.infinispan.notifications.cachelistener.CacheNotifierImpl.notifyCacheEntryCreated(CacheNotifierImpl.java:395)
[Server:instance-one] at org.infinispan.notifications.cachelistener.NotifyHelper.entryCommitted(NotifyHelper.java:46)
[Server:instance-one] at org.infinispan.interceptors.locking.ClusteringDependentLogic$DistributionLogic.commitSingleEntry(ClusteringDependentLogic.java:576)
[Server:instance-one] at org.infinispan.interceptors.locking.ClusteringDependentLogic$AbstractClusteringDependentLogic.commitEntry(ClusteringDependentLogic.java:190)
[Server:instance-one] at org.infinispan.interceptors.impl.EntryWrappingInterceptor.commitContextEntry(EntryWrappingInterceptor.java:584)
[Server:instance-one] at org.infinispan.interceptors.impl.EntryWrappingInterceptor.commitEntryIfNeeded(EntryWrappingInterceptor.java:813)
[Server:instance-one] at org.infinispan.interceptors.impl.EntryWrappingInterceptor.commitContextEntries(EntryWrappingInterceptor.java:566)
[Server:instance-one] at org.infinispan.interceptors.impl.EntryWrappingInterceptor.applyChanges(EntryWrappingInterceptor.java:617)
[Server:instance-one] at org.infinispan.interceptors.impl.EntryWrappingInterceptor.applyAndFixVersion(EntryWrappingInterceptor.java:678)
[Server:instance-one] at org.infinispan.interceptors.impl.EntryWrappingInterceptor$$Lambda$532/1400288933.accept(Unknown Source)
[Server:instance-one] at org.infinispan.interceptors.BaseAsyncInterceptor.invokeNextThenAccept(BaseAsyncInterceptor.java:105)
[Server:instance-one] at org.infinispan.interceptors.impl.EntryWrappingInterceptor.setSkipRemoteGetsAndInvokeNextForDataCommand(EntryWrappingInterceptor.java:672)
[Server:instance-one] at org.infinispan.interceptors.impl.EntryWrappingInterceptor.visitPutKeyValueCommand(EntryWrappingInterceptor.java:302)
[Server:instance-one] at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:68)
[Server:instance-one] at org.infinispan.interceptors.BaseAsyncInterceptor.invokeNextAndFinally(BaseAsyncInterceptor.java:150)
[Server:instance-one] at org.infinispan.interceptors.locking.AbstractLockingInterceptor.lambda$nonTxLockAndInvokeNext$1(AbstractLockingInterceptor.java:299)
[Server:instance-one] at org.infinispan.interceptors.locking.AbstractLockingInterceptor$$Lambda$683/1667920547.apply(Unknown Source)
[Server:instance-one] at org.infinispan.interceptors.SyncInvocationStage.addCallback(SyncInvocationStage.java:42)
[Server:instance-one] at org.infinispan.interceptors.InvocationStage.andHandle(InvocationStage.java:65)
[Server:instance-one] at org.infinispan.interceptors.locking.AbstractLockingInterceptor.nonTxLockAndInvokeNext(AbstractLockingInterceptor.java:294)
[Server:instance-one] at org.infinispan.interceptors.locking.AbstractLockingInterceptor.visitNonTxDataWriteCommand(AbstractLockingInterceptor.java:126)
[Server:instance-one] at org.infinispan.interceptors.locking.NonTransactionalLockingInterceptor.visitDataWriteCommand(NonTransactionalLockingInterceptor.java:40)
[Server:instance-one] at org.infinispan.interceptors.locking.AbstractLockingInterceptor.visitPutKeyValueCommand(AbstractLockingInterceptor.java:82)
[Server:instance-one] at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:68)
[Server:instance-one] at org.infinispan.interceptors.BaseAsyncInterceptor.invokeNextAndHandle(BaseAsyncInterceptor.java:183)
[Server:instance-one] at org.infinispan.statetransfer.StateTransferInterceptor.handleNonTxWriteCommand(StateTransferInterceptor.java:309)
[Server:instance-one] at org.infinispan.statetransfer.StateTransferInterceptor.handleWriteCommand(StateTransferInterceptor.java:252)
[Server:instance-one] at org.infinispan.statetransfer.StateTransferInterceptor.visitPutKeyValueCommand(StateTransferInterceptor.java:96)
[Server:instance-one] at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:68)
[Server:instance-one] at org.infinispan.interceptors.BaseAsyncInterceptor.invokeNext(BaseAsyncInterceptor.java:54)
[Server:instance-one] at org.infinispan.interceptors.DDAsyncInterceptor.handleDefault(DDAsyncInterceptor.java:54)
[Server:instance-one] at org.infinispan.interceptors.DDAsyncInterceptor.visitPutKeyValueCommand(DDAsyncInterceptor.java:60)
[Server:instance-one] at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:68)
[Server:instance-one] at org.infinispan.interceptors.BaseAsyncInterceptor.invokeNextAndExceptionally(BaseAsyncInterceptor.java:123)
[Server:instance-one] at org.infinispan.interceptors.impl.InvocationContextInterceptor.visitCommand(InvocationContextInterceptor.java:90)
[Server:instance-one] at org.infinispan.interceptors.BaseAsyncInterceptor.invokeNext(BaseAsyncInterceptor.java:56)
[Server:instance-one] at org.infinispan.interceptors.DDAsyncInterceptor.handleDefault(DDAsyncInterceptor.java:54)
[Server:instance-one] at org.infinispan.interceptors.DDAsyncInterceptor.visitPutKeyValueCommand(DDAsyncInterceptor.java:60)
[Server:instance-one] at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:68)
[Server:instance-one] at org.infinispan.interceptors.DDAsyncInterceptor.visitCommand(DDAsyncInterceptor.java:50)
[Server:instance-one] at org.infinispan.interceptors.impl.AsyncInterceptorChainImpl.invokeAsync(AsyncInterceptorChainImpl.java:234)
[Server:instance-one] at org.infinispan.cache.impl.CacheImpl.executeCommandAndCommitIfNeededAsync(CacheImpl.java:1930)
[Server:instance-one] at org.infinispan.cache.impl.CacheImpl.putAsync(CacheImpl.java:1571)
[Server:instance-one] at org.infinispan.cache.impl.DecoratedCache.putAsync(DecoratedCache.java:690)
[Server:instance-one] at org.infinispan.cache.impl.AbstractDelegatingAdvancedCache.putAsync(AbstractDelegatingAdvancedCache.java:386)
[Server:instance-one] at org.infinispan.cache.impl.EncoderCache.putAsync(EncoderCache.java:460)
[Server:instance-one] at org.infinispan.cache.impl.AbstractDelegatingAdvancedCache.putAsync(AbstractDelegatingAdvancedCache.java:386)
[Server:instance-one] at org.infinispan.server.hotrod.CacheRequestProcessor.putInternal(CacheRequestProcessor.java:194)
[Server:instance-one] at org.infinispan.server.hotrod.CacheRequestProcessor.lambda$put$6(CacheRequestProcessor.java:187)
[Server:instance-one] at org.infinispan.server.hotrod.CacheRequestProcessor$$Lambda$734/240795618.run(Unknown Source)
[Server:instance-one] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[Server:instance-one] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[Server:instance-one] at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
[Server:instance-one] at java.lang.Thread.run(Thread.java:745)
[Server:instance-one] Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to [B
[Server:instance-one] at org.infinispan.server.hotrod.ClientListenerRegistry$BaseClientEventSender.onCacheEvent(ClientListenerRegistry.java:360)
[Server:instance-one] at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
[Server:instance-one] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[Server:instance-one] at java.lang.reflect.Method.invoke(Method.java:497)
[Server:instance-one] at org.infinispan.notifications.impl.AbstractListenerImpl$ListenerInvocationImpl.lambda$invoke$1(AbstractListenerImpl.java:382)
[Server:instance-one] ... 61 more
I have searched on infinispan documentation, but i can't find anything.

To be able to use queries over Hot Rod, you don't need compatibility mode, I can see your cache has <compatibility enabled="true"/>. Query also does not require the deployment of entities in the server.
Regarding compatibility mode, it was deprecated in Infinispan 9.4.0, the alternative being http://infinispan.org/docs/stable/user_guide/user_guide.html#endpoint_interop.
Finally, if you really need to store unmarshalled objects in the cache,you need to deploy entities and marshallers in the server. To deploy extra protobuf marshallers, see:
http://infinispan.org/docs/stable/user_guide/user_guide.html#protostream_deployment
To deploy entities, see:
http://infinispan.org/docs/stable/user_guide/user_guide.html#entities_deploy

you do not need to use compat mode to be to do query, as already mentioned here by another answer. So I would try first without compat mode. Whithout compat mode you also no longer need to deploy entities and marshallers in the server so everything is simplified and there is less potential for mistakes. I already see you have a small issue in EntityDemoMarshaller.readFrom. It just returns null instead of the returning the unmarshalled entity, so that has the potential to ruin the whole thing anyway. Please fix that and update this question with new stacktrace if it still fails or close it if it is no longer an issue.
If your use case absolutely needs compat mode for whatever reason, then please read about transcoding in user guide and use that instead, because compat mode is deprecated and being replaced by transcoding.

Related

java.lang.ClassNotFoundException: org.docx4j.jaxb.suninternal.NamespacePrefixMapper -Docx4j

I updated docx4j from 6.1.2 to 8.0.0 version (https://www.docx4java.org/forums/announces/docx4j-8-0-0-released-t2808.html). I'm using docx4j-JAXB-Internal. When I try to execute, I'm getting the following exception:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Caused by: javax.xml.bind.JAXBException: Can't create internal NamespacePrefixMapper
- with linked exception:
[java.lang.ClassNotFoundException: org.docx4j.jaxb.suninternal.NamespacePrefixMapper]
at org.docx4j.jaxb.NamespacePrefixMapperUtils.getPrefixMapper(NamespacePrefixMapperUtils.java:67)
at org.docx4j.XmlUtils.marshaltoString(XmlUtils.java:850)
... 5 more
Caused by: java.lang.ClassNotFoundException: org.docx4j.jaxb.suninternal.NamespacePrefixMapper
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.docx4j.jaxb.NamespacePrefixMapperUtils.getPrefixMapper(NamespacePrefixMapperUtils.java:63)
... 6 more
Code:
public class VersionTest {
final static Logger logger = Logger.getLogger(VersionTest.class);
public static void main(String args[]) throws Docx4JException {
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new File("/home/ubuntu/Documents/Projects/Java_Workspace/Version_Test/input/test.docx"));
MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
EndnotesPart endnotePart = wordMLPackage.getMainDocumentPart().getEndNotesPart();
FootnotesPart footnotesPart = wordMLPackage.getMainDocumentPart().getFootnotesPart();
CommentsPart comments = wordMLPackage.getMainDocumentPart().getCommentsPart();
logger.info("documentPart Info "+XmlUtils.marshaltoString(documentPart.getJaxbElement(), true, true) );
}}
Help me out to solve the problem. Thanks in advance.

FirebaseMessagingException: Error while calling FCM backend service

I am trying to send the fem notification :
MulticastMessage message = MulticastMessage.builder()
.putData("score", "850")
.putData("time", "2:45")
.addAllTokens(requestDTO.getTokenIds())
.build();
try {
firebaseInstance.sendMulticast(message);
} catch (FirebaseMessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Now this code is working from one server but when same jar i am running on different server, it is showing the exception message :
com.google.firebase.messaging.FirebaseMessagingException: Error while calling FCM backend service
at com.google.firebase.messaging.FirebaseMessagingClientImpl.sendAll(FirebaseMessagingClientImpl.java:141)
at com.google.firebase.messaging.FirebaseMessaging$2.execute(FirebaseMessaging.java:293)
at com.google.firebase.messaging.FirebaseMessaging$2.execute(FirebaseMessaging.java:290)
at com.google.firebase.internal.CallableOperation.call(CallableOperation.java:36)
at com.google.firebase.messaging.FirebaseMessaging.sendAll(FirebaseMessaging.java:183)
at com.google.firebase.messaging.FirebaseMessaging.sendMulticast(FirebaseMessaging.java:252)
at com.google.firebase.messaging.FirebaseMessaging.sendMulticast(FirebaseMessaging.java:227)
at com.demo.notiifcationsender.sender.firebase.FirebaseService.send(FirebaseService.java:89)
at com.demo.notiifcationsender.consumers.KafkaConsumerListeners.listen(KafkaConsumerListeners.java:30)
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.springframework.messaging.handler.invocation.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:181)
at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:114)
at org.springframework.kafka.listener.adapter.HandlerAdapter.invoke(HandlerAdapter.java:48)
at org.springframework.kafka.listener.adapter.MessagingMessageListenerAdapter.invokeHandler(MessagingMessageListenerAdapter.java:248)
at org.springframework.kafka.listener.adapter.RecordMessagingMessageListenerAdapter.onMessage(RecordMessagingMessageListenerAdapter.java:80)
at org.springframework.kafka.listener.adapter.RecordMessagingMessageListenerAdapter.onMessage(RecordMessagingMessageListenerAdapter.java:51)
at org.springframework.kafka.listener.adapter.RecordMessagingMessageListenerAdapter$$FastClassBySpringCGLIB$$cde8c01d.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.cloud.sleuth.instrument.messaging.MessageListenerMethodInterceptor.invoke(TraceMessagingAutoConfiguration.java:256)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
at org.springframework.kafka.listener.adapter.RecordMessagingMessageListenerAdapter$$EnhancerBySpringCGLIB$$3c289c2b.onMessage(<generated>)
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeRecordListener(KafkaMessageListenerContainer.java:1103)
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeWithRecords(KafkaMessageListenerContainer.java:1083)
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeRecordListener(KafkaMessageListenerContainer.java:1025)
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeListener(KafkaMessageListenerContainer.java:893)
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.run(KafkaMessageListenerContainer.java:748)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:210)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
at sun.security.ssl.InputRecord.read(InputRecord.java:503)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:975)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1334)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1309)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:259)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:77)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:981)
at com.google.api.client.googleapis.batch.BatchRequest.execute(BatchRequest.java:241)
at com.google.firebase.messaging.FirebaseMessagingClientImpl.sendBatchRequest(FirebaseMessagingClientImpl.java:168)
at com.google.firebase.messaging.FirebaseMessagingClientImpl.sendAll(FirebaseMessagingClientImpl.java:137)
... 34 more
What i am doing wrong. All the config are with the code while compilation.
Same jar is able to deliver the notification from one server but unable to deliver it from other server(2-3 different server).
Are these server blocked or what? How should I debug those?
Firebase config :
{
"type": "service_account",
"project_id": "my-pro",
"private_key_id": "bbbbbbbbbBbbbbbbbbbbbbbbbbbbbbbbbbbb",
"private_key": "-----BEGIN PRIVATE KEY-----\nPRIVATE JET CINTEBT\n-----END PRIVATE KEY-----\n",
"client_email": "firebase-adminsdk-cg2zu#sabncd.iam.gserviceaccount.com",
"client_id": "12121212121212121212121",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-cg2zu%sabncd.iam.gserviceaccount.com"
}
Firebase Instance Creator
#Configuration
public class FirebaseInstanceCreator {
#Bean
public FirebaseMessaging firebaseMessaging() throws IOException {
ClassPathResource classPathResource = new ClassPathResource("serviceAccount.json");
FirebaseOptions options = new FirebaseOptions .Builder()
.setCredentials(GoogleCredentials.fromStream(classPathResource.getInputStream()))
.build();
FirebaseApp.initializeApp(options);
return FirebaseMessaging.getInstance();
}
}

SASL negotiation failure while connecting to Kerberized hive from java

I am have cloudera vm where I enabled Kerberos and I writing a java application on windows machine to get hive connection . but I am getting following exceptions. I followed many examples and documentation to get connection to hive but I am unable to get connection.
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/lamadipen/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.4.1/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/lamadipen/.m2/repository/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Debug is true storeKey false useTicketCache false useKeyTab true doNotPrompt false ticketCache is null isInitiator true KeyTab is cmf.keytab refreshKrb5Config is false principal is cloudera#CLOUDERA tryFirstPass is false useFirstPass is false storePass is false clearPass is false
principal is cloudera#CLOUDERA
Will use keytab
Commit Succeeded
16:15:35.153 [main] ERROR org.apache.thrift.transport.TSaslTransport - SASL negotiation failure
javax.security.sasl.SaslException: GSS initiate failed
at com.sun.security.sasl.gsskerb.GssKrb5Client.evaluateChallenge(GssKrb5Client.java:211) ~[?:1.8.0_144]
at org.apache.thrift.transport.TSaslClientTransport.handleSaslStartMessage(TSaslClientTransport.java:94) ~[libthrift-0.9.3.jar:0.9.3]
at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:271) [libthrift-0.9.3.jar:0.9.3]
at org.apache.thrift.transport.TSaslClientTransport.open(TSaslClientTransport.java:37) [libthrift-0.9.3.jar:0.9.3]
at org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport$1.run(TUGIAssumingTransport.java:52) [hive-shims-common-2.0.0.jar:2.0.0]
at org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport$1.run(TUGIAssumingTransport.java:49) [hive-shims-common-2.0.0.jar:2.0.0]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_144]
at javax.security.auth.Subject.doAs(Subject.java:422) [?:1.8.0_144]
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1628) [hadoop-common-2.6.0.jar:?]
at org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport.open(TUGIAssumingTransport.java:49) [hive-shims-common-2.0.0.jar:2.0.0]
at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:181) [hive-jdbc-2.0.0.jar:2.0.0]
at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:152) [hive-jdbc-2.0.0.jar:2.0.0]
at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107) [hive-jdbc-2.0.0.jar:2.0.0]
at java.sql.DriverManager.getConnection(DriverManager.java:664) [?:1.8.0_144]
at java.sql.DriverManager.getConnection(DriverManager.java:270) [?:1.8.0_144]
at com.dipen.sch.HiveConnection.run(App.java:146) [classes/:?]
at com.dipen.sch.HiveConnection.run(App.java:1) [classes/:?]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_144]
at javax.security.auth.Subject.doAs(Subject.java:422) [?:1.8.0_144]
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1628) [hadoop-common-2.6.0.jar:?]
at com.dipen.sch.App.authentication(App.java:96) [classes/:?]
at com.dipen.sch.App.main(App.java:50) [classes/:?]
Caused by: org.ietf.jgss.GSSException: No valid credentials provided (Mechanism level: Clock skew too great (37) - PROCESS_TGS)
at sun.security.jgss.krb5.Krb5Context.initSecContext(Krb5Context.java:770) ~[?:1.8.0_144]
at sun.security.jgss.GSSContextImpl.initSecContext(GSSContextImpl.java:248) ~[?:1.8.0_144]
at sun.security.jgss.GSSContextImpl.initSecContext(GSSContextImpl.java:179) ~[?:1.8.0_144]
at com.sun.security.sasl.gsskerb.GssKrb5Client.evaluateChallenge(GssKrb5Client.java:192) ~[?:1.8.0_144]
... 21 more
Caused by: sun.security.krb5.KrbException: Clock skew too great (37) - PROCESS_TGS
at sun.security.krb5.KrbTgsRep.<init>(KrbTgsRep.java:73) ~[?:1.8.0_144]
at sun.security.krb5.KrbTgsReq.getReply(KrbTgsReq.java:251) ~[?:1.8.0_144]
at sun.security.krb5.KrbTgsReq.sendAndGetCreds(KrbTgsReq.java:262) ~[?:1.8.0_144]
at sun.security.krb5.internal.CredentialsUtil.serviceCreds(CredentialsUtil.java:308) ~[?:1.8.0_144]
at sun.security.krb5.internal.CredentialsUtil.acquireServiceCreds(CredentialsUtil.java:126) ~[?:1.8.0_144]
at sun.security.krb5.Credentials.acquireServiceCreds(Credentials.java:458) ~[?:1.8.0_144]
at sun.security.jgss.krb5.Krb5Context.initSecContext(Krb5Context.java:693) ~[?:1.8.0_144]
at sun.security.jgss.GSSContextImpl.initSecContext(GSSContextImpl.java:248) ~[?:1.8.0_144]
at sun.security.jgss.GSSContextImpl.initSecContext(GSSContextImpl.java:179) ~[?:1.8.0_144]
at com.sun.security.sasl.gsskerb.GssKrb5Client.evaluateChallenge(GssKrb5Client.java:192) ~[?:1.8.0_144]
... 21 more
Caused by: sun.security.krb5.Asn1Exception: Identifier doesn't match expected value (906)
at sun.security.krb5.internal.KDCRep.init(KDCRep.java:140) ~[?:1.8.0_144]
at sun.security.krb5.internal.TGSRep.init(TGSRep.java:65) ~[?:1.8.0_144]
at sun.security.krb5.internal.TGSRep.<init>(TGSRep.java:60) ~[?:1.8.0_144]
at sun.security.krb5.KrbTgsRep.<init>(KrbTgsRep.java:55) ~[?:1.8.0_144]
at sun.security.krb5.KrbTgsReq.getReply(KrbTgsReq.java:251) ~[?:1.8.0_144]
at sun.security.krb5.KrbTgsReq.sendAndGetCreds(KrbTgsReq.java:262) ~[?:1.8.0_144]
at sun.security.krb5.internal.CredentialsUtil.serviceCreds(CredentialsUtil.java:308) ~[?:1.8.0_144]
at sun.security.krb5.internal.CredentialsUtil.acquireServiceCreds(CredentialsUtil.java:126) ~[?:1.8.0_144]
at sun.security.krb5.Credentials.acquireServiceCreds(Credentials.java:458) ~[?:1.8.0_144]
at sun.security.jgss.krb5.Krb5Context.initSecContext(Krb5Context.java:693) ~[?:1.8.0_144]
at sun.security.jgss.GSSContextImpl.initSecContext(GSSContextImpl.java:248) ~[?:1.8.0_144]
at sun.security.jgss.GSSContextImpl.initSecContext(GSSContextImpl.java:179) ~[?:1.8.0_144]
at com.sun.security.sasl.gsskerb.GssKrb5Client.evaluateChallenge(GssKrb5Client.java:192) ~[?:1.8.0_144]
... 21 more
Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1643)
at com.dipen.sch.App.authentication(App.java:96)
at com.dipen.sch.App.main(App.java:50)
Caused by: java.sql.SQLException: Could not open client transport with JDBC Uri: jdbc:hive2://quickstart.cloudera:10000/;principal=hive/cloudera#CLOUDERA: GSS initiate failed
at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:207)
at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:152)
at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at com.dipen.sch.HiveConnection.run(App.java:146)
at com.dipen.sch.HiveConnection.run(App.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1628)
... 2 more
Caused by: org.apache.thrift.transport.TTransportException: GSS initiate failed
at org.apache.thrift.transport.TSaslTransport.sendAndThrowMessage(TSaslTransport.java:232)
at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:316)
at org.apache.thrift.transport.TSaslClientTransport.open(TSaslClientTransport.java:37)
at org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport$1.run(TUGIAssumingTransport.java:52)
at org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport$1.run(TUGIAssumingTransport.java:49)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1628)
at org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport.open(TUGIAssumingTransport.java:49)
at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:181)
... 11 more
I am getting Commit Succeeded message on my console does it mean I am authenticated.
public static void authentication() throws LoginException, IOException, InterruptedException, PrivilegedActionException
{
System.setProperty("hadoop.home.dir", "C:\\hadoop-common-2.2.0");
System.setProperty("java.security.auth.login.config", "gss-jaas.conf");
System.setProperty("java.security.krb5.realm","CLOUDERA");
System.setProperty("java.security.krb5.kdc","169.254.56.203");
System.setProperty("java.security.krb5.conf", "krb5.conf");
System.setProperty("javax.security.auth.useSubjectCredOnly","false");
LoginContext loginContext = new LoginContext("com.sun.security.jgss.initiate");
loginContext.login();
Subject subject = loginContext.getSubject();
Configuration conf = new Configuration();
conf.set("hadoop.security.authentication", "Kerberos");
UserGroupInformation.setConfiguration(conf);
UserGroupInformation ugi = UserGroupInformation.getUGIFromSubject(subject);
HiveConnection hc = new HiveConnection();
ugi.doAs(hc);
//Subject.doAs(subject, hc);
System.out.println("Before Getting connection");
Connection con = hc.con;
System.out.println("After Getting connection");
}
I am trying to use UserGroupInformation to call PrivilegedExceptionAction and get the connection and I have tired same with Subject also but I am getting same issue which ever way I go.
class HiveConnection implements PrivilegedExceptionAction<Void>{
private static String driverName = "org.apache.hive.jdbc.HiveDriver";
Connection con=null;
public Void run() throws ClassNotFoundException, SQLException, IOException {
Class.forName(driverName);
con = DriverManager.getConnection("jdbc:hive2://quickstart.cloudera:10000/;principal=hive/cloudera#CLOUDERA");
return null;
}
}
krb5.conf file
[libdefaults]
default_realm = CLOUDERA
dns_lookup_kdc = false
dns_lookup_realm = false
ticket_lifetime = 86400
renew_lifetime = 604800
forwardable = true
default_tgs_enctypes = rc4-hmac
default_tkt_enctypes = rc4-hmac
permitted_enctypes = rc4-hmac
udp_preference_limit = 1
kdc_timeout = 3000
[realms]
CLOUDERA = {
kdc = 169.254.56.203
admin_server = 169.254.56.203
}
[domain_realm]
gss-jaas.conf file
com.sun.security.jgss.initiate {
com.sun.security.auth.module.Krb5LoginModule required
principal="cloudera#CLOUDERA"
useKeyTab= true
keyTab="cmf.keytab"
storeKey=false
doNotPrompt=false
renewTGT=false
useTicketCache=false
debug=true;
};

EntityManager not injected in a #Stateless EJB, when I restart the app

My entry point is a #Singleton scheduled to be run twice a minute.
#Startup
#Singleton
public class MyScheduledProcess {
#Resource
protected TimerService timerService;
#Inject
private OutgoingMessageProvider provider;
// If I inject the em here, it is always well injected.
// #PersistenceContext
// EntityManager em;
/**
* Default startup method that will be called automatically to schedule the task.
*/
#PostConstruct
public void onStartup() {
// To erase all timers which may already exist...
stopAll();
// Schedule
timerService.createCalendarTimer(getScheduledExpression("* * */30"), new TimerConfig());
}
#Timeout
protected void onTimeout(final Timer timer) {
process(timer);
}
/**
* Business logic called when the timer is triggered.
* #param timer
*/
public void process(Timer t) {
logger.info("Start process");
// When em is injected here, there is no problem.
// OutgoingMessage outMsg = em.find(OutgoingMessage.class, 3L);
// logger.info("found:" + outMsg);
logger.info("provider :" + provider);
List<OutgoingMessage> findAll = provider.findByStatus("CREATED");
logger.info("Nb in list : " + findAll.size());
}
public static ScheduleExpression getScheduledExpression(String stringRepresentation) {
ScheduleExpression expression = new ScheduleExpression();
// [....]
return expression;
}
public void stopAll() {
for(Timer timer : timerService.getTimers()) {
logger.debug("Stopping " + timer);
timer.cancel();
}
}
}
In this Singleton, I inject my OutgoingMessageProvider, a Stateless bean.
#Stateless
public class OutgoingMessageProvider {
#PersistenceContext(unitName= "DefaultPU")
protected EntityManager em;
public List<OutgoingMessage> findByStatus(String status) {
logger.debug("Value of em : " + em);
return this.em.createQuery("SELECT m FROM OutgoingMessage m WHERE m.status = :status")
.setParameter("status", status)
.getResultList();
}
public OutgoingMessage findByMessageId(String messageId) {
return ........
}
public void create(OutgoingMessage entity) {
em.persist(entity);
}
....
}
When I upload and deploy my war on a weblogic (12.1.3), at the first start, everything is OK and works fine.
But when I stop my app and start it up again in the Weblogic Admin Console, I have a "NoSuchEJBException: Bean is already undeployed." :
22:22:16.216 [[ACTIVE] ExecuteThread: '15' for queue: 'weblogic.kernel.Default (self-tuning)'] INFO com.poc.schedul.MyScheduledProcess - provider :com.poc.schedul.OutgoingMessageProvider_ek022o_NoIntfViewImpl#6b6bebf1
<11-Sep-2016 22:22:16 o'clock CEST> <Error> <EJB> <BEA-011088> <The following error occurred while invoking the ejbTimeout(javax.ejb.Timer) method of EJB MyScheduledProcess(Application: poc2, EJBComponent: poc.war).
javax.ejb.EJBException: EJB Exception: : com.oracle.pitchfork.interfaces.LifecycleCallbackException: Failure to invoke public java.lang.Object org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(javax.interceptor.InvocationContext) throws java.lang.Exception on bean class class org.jboss.weld.ejb.SessionBeanInterceptor with args: [LifecycleEventCallbackInvocationContext(962794227)]
at com.oracle.pitchfork.inject.Jsr250Metadata.invokeLifecycleMethod(Jsr250Metadata.java:379)
at com.oracle.pitchfork.intercept.LifecycleEventCallbackInvocationContext.proceed(LifecycleEventCallbackInvocationContext.java:115)
at com.oracle.pitchfork.intercept.LifecycleEventCallbackInvocationContext.proceed(LifecycleEventCallbackInvocationContext.java:144)
at com.oracle.pitchfork.intercept.InterceptionMetadata.invokeTimeoutMethod(InterceptionMetadata.java:531)
at weblogic.ejb.container.injection.EjbComponentCreatorImpl.invokeTimer(EjbComponentCreatorImpl.java:71)
at weblogic.ejb.container.injection.InjectionBasedEjbComponentCreator.invokeTimer(InjectionBasedEjbComponentCreator.java:152)
at weblogic.ejb.container.manager.BaseEJBManager.invokeTimeoutMethod(BaseEJBManager.java:176)
at weblogic.ejb.container.timer.TimerImpl.timerExpired(TimerImpl.java:340)
at weblogic.timers.internal.TimerImpl.run(TimerImpl.java:304)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:548)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor927.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.oracle.pitchfork.inject.Jsr250Metadata.invokeLifecycleMethod(Jsr250Metadata.java:377)
... 11 more
Caused by: com.oracle.pitchfork.interfaces.LifecycleCallbackException: Failure to invoke timeout method protected void com.poc.schedul.MyScheduledProcess.onTimeout(javax.ejb.Timer) on bean class class com.poc.schedul.MyScheduledProcess_szpi74_Impl with args: [[EJB Timer] id: 44 pk: 1 info: null isAutoCreated: false timer: 1473625336209.6(0) state: 2 ejb: MyScheduledProcess(Application: poc2, EJBComponent: poc.war) Thread: Thread[[ACTIVE] ExecuteThread: '15' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads]]]
at com.oracle.pitchfork.inject.Jsr250Metadata.invokeTimeoutMethodInternal(Jsr250Metadata.java:364)
at com.oracle.pitchfork.intercept.LifecycleEventCallbackInvocationContext.proceed(LifecycleEventCallbackInvocationContext.java:120)
at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:49)
... 15 more
Caused by: java.lang.reflect.InvocationTargetException
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.oracle.pitchfork.inject.Jsr250Metadata.invokeTimeoutMethodInternal(Jsr250Metadata.java:362)
... 17 more
Caused by: javax.ejb.NoSuchEJBException: Bean is already undeployed.
at weblogic.ejb.container.manager.BaseEJBManager.ensureDeployed(BaseEJBManager.java:131)
at weblogic.ejb.container.manager.BaseEJBManager.preInvoke(BaseEJBManager.java:136)
at weblogic.ejb.container.manager.StatelessManager.preInvoke(StatelessManager.java:138)
at weblogic.ejb.container.internal.BaseLocalObject.getBeanInstance(BaseLocalObject.java:148)
at weblogic.ejb.container.internal.BaseLocalObject.preInvoke(BaseLocalObject.java:105)
at weblogic.ejb.container.internal.BaseLocalObject.__WL_preInvoke(BaseLocalObject.java:70)
at weblogic.ejb.container.internal.SessionLocalMethodInvoker.invoke(SessionLocalMethodInvoker.java:22)
at com.poc.schedul.OutgoingMessageProvider_ek022o_NoIntfViewImpl.findByStatus(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:606)
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.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:115)
at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)
at com.poc.schedul.OutgoingMessageProvider$Proxy$_$$_Weld$Proxy$.findByStatus(OutgoingMessageProvider$Proxy$_$$_Weld$Proxy$.java)
at com.poc.schedul.MyScheduledProcess.process(MyScheduledProcess.java:90)
at com.poc.schedul.MyScheduledProcess.onTimeout(MyScheduledProcess.java:111)
... 22 more
at weblogic.ejb.container.internal.EJBRuntimeUtils.throwEJBException(EJBRuntimeUtils.java:88)
at weblogic.ejb.container.internal.BaseLocalObject.handleSystemException(BaseLocalObject.java:503)
at weblogic.ejb.container.internal.BaseLocalObject.handleSystemException(BaseLocalObject.java:446)
at weblogic.ejb.container.internal.BaseLocalObject.postInvoke1(BaseLocalObject.java:251)
at weblogic.ejb.container.internal.BaseLocalObject.postInvoke(BaseLocalObject.java:431)
Truncated. see log file for complete stacktrace
Caused By: com.oracle.pitchfork.interfaces.LifecycleCallbackException: Failure to invoke public java.lang.Object org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(javax.interceptor.InvocationContext) throws java.lang.Exception on bean class class org.jboss.weld.ejb.SessionBeanInterceptor with args: [LifecycleEventCallbackInvocationContext(962794227)]
at com.oracle.pitchfork.inject.Jsr250Metadata.invokeLifecycleMethod(Jsr250Metadata.java:379)
at com.oracle.pitchfork.intercept.LifecycleEventCallbackInvocationContext.proceed(LifecycleEventCallbackInvocationContext.java:115)
at com.oracle.pitchfork.intercept.LifecycleEventCallbackInvocationContext.proceed(LifecycleEventCallbackInvocationContext.java:144)
at com.oracle.pitchfork.intercept.InterceptionMetadata.invokeTimeoutMethod(InterceptionMetadata.java:531)
at weblogic.ejb.container.injection.EjbComponentCreatorImpl.invokeTimer(EjbComponentCreatorImpl.java:71)
Truncated. see log file for complete stacktrace
Caused By: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor927.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.oracle.pitchfork.inject.Jsr250Metadata.invokeLifecycleMethod(Jsr250Metadata.java:377)
at com.oracle.pitchfork.intercept.LifecycleEventCallbackInvocationContext.proceed(LifecycleEventCallbackInvocationContext.java:115)
Truncated. see log file for complete stacktrace
Caused By: com.oracle.pitchfork.interfaces.LifecycleCallbackException: Failure to invoke timeout method protected void com.poc.schedul.MyScheduledProcess.onTimeout(javax.ejb.Timer) on bean class class com.poc.schedul.MyScheduledProcess_szpi74_Impl with args: [[EJB Timer] id: 44 pk: 1 info: null isAutoCreated: false timer: 1473625336209.6(0) state: 2 ejb: MyScheduledProcess(Application: poc2, EJBComponent: poc.war) Thread: Thread[[ACTIVE] ExecuteThread: '15' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads]]]
at com.oracle.pitchfork.inject.Jsr250Metadata.invokeTimeoutMethodInternal(Jsr250Metadata.java:364)
at com.oracle.pitchfork.intercept.LifecycleEventCallbackInvocationContext.proceed(LifecycleEventCallbackInvocationContext.java:120)
at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:49)
at sun.reflect.GeneratedMethodAccessor927.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Truncated. see log file for complete stacktrace
Caused By: java.lang.reflect.InvocationTargetException
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.oracle.pitchfork.inject.Jsr250Metadata.invokeTimeoutMethodInternal(Jsr250Metadata.java:362)
Truncated. see log file for complete stacktrace
Caused By: javax.ejb.NoSuchEJBException: Bean is already undeployed.
at weblogic.ejb.container.manager.BaseEJBManager.ensureDeployed(BaseEJBManager.java:131)
at weblogic.ejb.container.manager.BaseEJBManager.preInvoke(BaseEJBManager.java:136)
at weblogic.ejb.container.manager.StatelessManager.preInvoke(StatelessManager.java:138)
at weblogic.ejb.container.internal.BaseLocalObject.getBeanInstance(BaseLocalObject.java:148)
at weblogic.ejb.container.internal.BaseLocalObject.preInvoke(BaseLocalObject.java:105)
Truncated. see log file for complete stacktrace
So, can someone explain me why everything works fine when I deploy my app, and goes wrong when I restart ? What happens in the application server when an app starts or stops ?
As we can see in the log, the Singleton knows the provider, so I can only imagine the provider does not know the entity manager... Am I wrong ? But, if I try to inject the EntityManager in the singleton, everything works fine. Then it means that the entityManager are well managed by the app server... So why isn't it injected in the stateless bean ?
I tried to instantiate myself an entitymanager in the provider, by adding a PostConstruct (and removing the #PersistenceContext...) :
#PostConstruct
public void init()
{
EntityManagerFactory emf = Persistence.createEntityManagerFactory("DefaultPU");
em = emf.createEntityManager(); }
logger.info("ENTITY MANAGER HAS BEEN SET : " +em);
}
But this method is called only once, and I have no trace in my log when I restart the app.
Is it normal ?
The problem has been resolved by replacing the #Inject by a #EJB in my singleton :
#Startup
#Singleton
public class MyScheduledProcess {
#Resource
protected TimerService timerService;
#EJB
private OutgoingMessageProvider provider;
...
Yes, it seems logic that it works with #EJB.
But I do not understand the behaviour that I described with #Inject : works fine the first time (after deploy), but injections fail when I stop and start again the war. If someone knows, feel free to share :)

ConstraintViolationException deploying an application to Glassfish in JavaEE

I have the following "Administrator" Entity constructor:
public Administrator(String username, String password, String name, String email) {
super(username, password, name, email, 2);
}
This inherits from the following class with the following constraints:
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
protected int id;
#Column(unique = true)
protected String username;
#NotNull
protected String password;
#NotNull
protected String name;
#NotNull
private int type;
#NotNull
#Column(unique = true)
#Pattern(regexp = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\."
+ "[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*#"
+ "(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?",
message = "{invalid.email}")
protected String email;
public ApplicationUser() {
}
public ApplicationUser(String username, String password, String name, String email, int type) {
this.username = username;
this.password = password;
this.name = name;
this.email = email;
this.type = type;
}
So there's absolutely nothing being violated when I create a new Administrator in my ConfigBean, using this method:
//AdministratorBean
public void createAdministrator(String username, String password, String name, String email) {
Administrator administrator = new Administrator(username, password, name, email);
em.persist(administrator);
}
//ConfigBean
administratorBean.createAdministrator("admin123", "passpass", "Someguy", "some#guy.com");
But when I deploy the application it throws the following exception (and yes, I have tried undeploying, redeploying and rebuilding to no effect):
Warning: A system exception occurred during an invocation on EJB AdministratorBean, method: public void beans.AdministratorBean.createAdministrator(java.lang.String,java.lang.String,java.lang.String,java.lang.String)
Warning: javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean
(...)
«
Caused by: java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManagerFactory.
In some other instances of deployment I get a SQL constraint error. How can I fix this?
[EDIT] - Full stack trace of the error as request:
Warning: A system exception occurred during an invocation on EJB AdministratorBean, method: public void beans.AdministratorBean.createAdministrator(java.lang.String,java.lang.String,java.lang.String,java.lang.String)
Warning: javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean
at com.sun.ejb.containers.EJBContainerTransactionManager.checkExceptionClientTx(EJBContainerTransactionManager.java:662)
at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:507)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4566)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2074)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2044)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
at com.sun.proxy.$Proxy342.createAdministrator(Unknown Source)
at beans.__EJB31_Generated__AdministratorBean__Intf____Bean__.createAdministrator(Unknown Source)
at beans.ConfigBean.postDeploy(ConfigBean.java:35)
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:483)
at com.sun.ejb.containers.interceptors.BeanCallbackInterceptor.intercept(InterceptorManager.java:1035)
at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:205)
at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:55)
at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52)
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:483)
at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:986)
at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:205)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.init(SystemInterceptorProxy.java:125)
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:483)
at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:986)
at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:412)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:375)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:2014)
at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:468)
at com.sun.ejb.containers.AbstractSingletonContainer.access$000(AbstractSingletonContainer.java:74)
at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:647)
at com.sun.ejb.containers.AbstractSingletonContainer.instantiateSingletonInstance(AbstractSingletonContainer.java:389)
at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:219)
at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:180)
at org.glassfish.ejb.startup.SingletonLifeCycleManager.doStartup(SingletonLifeCycleManager.java:158)
at org.glassfish.ejb.startup.EjbApplication.start(EjbApplication.java:166)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:500)
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:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
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.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManagerFactory.
Stopping the glassfish server, deleting the nb-derby folder contents and redeploying the application seemed to work. It's a glassfish bug.