Failed to marshal EJB parameters --- IllegalArgumentException: Can not set org.apache.commons.collections.FastHashMap field - jboss7.x

I'm getting the below error while trying to save a search results using the Remote interface for SearchFacade.java
"Failed to marshal EJB parameters"
Can not set org.apache.commons.collections.FastHashMap field
org.apache.commons.validator.Field.hMsgs to
org.apache.commons.collections.FastHashMap at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
at
I'm Using struts 1.1, EJB 2.1 using xdoclet 1.2.3 jars for generating the dependency files.(which is inevitable to use), Where my Local,Home interfaces are being generated using Xdoclet..
I'm also using Java 6, Jboss EAP 6.1 Alpha in my project.
Note: The same code works fine when running in Jboss 4.0
So wonder is my remote calling is correct.
Any help is welcome.
Error Logs
java.lang.RuntimeException: JBAS014154: Failed to marshal EJB parameters at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:270) at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:259) at org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:170) at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) at org.jboss.ejb.client.EJBHomeCreateInterceptor.handleInvocation(EJBHomeCreateInterceptor.java:79) at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) at org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:42) at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:125) at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:177) at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:161) at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:124) at $Proxy25.saveSearch(Unknown Source) at com.web.history.SearchFormDelegate.saveSearch(SearchFormDelegate.java:177) at com.history.SaveSearchAction.createNewSavedSearch(SaveSearchAction.java:109) at com.history.SaveSearchAction.executeSynchronized(SaveSearchAction.java:296) at com.dispatch.SynchronizedAction.execute(SynchronizedAction.java:206) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) at com.security.AuthenticationFilter.doFilter(AuthenticationFilter.java:672) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) at com.planetj.servlet.filter.compression.CompressingFilter.doFilter(CompressingFilter.java:270) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920) at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.IllegalArgumentException: Can not set org.apache.commons.collections.FastHashMap field org.apache.commons.validator.Field.hMsgs to org.apache.commons.collections.FastHashMap at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146) at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150) at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63) at java.lang.reflect.Field.set(Field.java:657) at org.jboss.marshalling.cloner.SerializingCloner.storeFields(SerializingCloner.java:368) at org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:313) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:253) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134) at org.jboss.marshalling.cloner.SerializingCloner.cloneFields(SerializingCloner.java:348) at org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:309) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:253) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134) at org.jboss.marshalling.cloner.SerializingCloner$StepObjectInput.doReadObject(SerializingCloner.java:836) at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37) at org.jboss.marshalling.MarshallerObjectInputStream.readObjectOverride(MarshallerObjectInputStream.java:57) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:344) at java.util.HashMap.readObject(HashMap.java:1030) at sun.reflect.GeneratedMethodAccessor119.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:218) at org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:302) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:253) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134) at org.jboss.marshalling.cloner.SerializingCloner.cloneFields(SerializingCloner.java:348) at org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:309) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:253) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134) at org.jboss.marshalling.cloner.SerializingCloner.cloneFields(SerializingCloner.java:348) at org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:309) at org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:285) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:253) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134) at org.jboss.marshalling.cloner.SerializingCloner.cloneFields(SerializingCloner.java:348) at org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:309) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:253) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134) at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:268) ... 42 more
Code:
saveAction.java
protected void newSavedSearch(final SrchFrmDelegate sfd,
final String userId, final HttpServletRequest request,
final SaveSearchForm form) throws RemoteException,
UsrNotFoundException {
BseSrchValue srchValue = SrchResultsAction.retrieveSrchCriteria(request);
FrmLayout frmLayout = (FrmLayout) request.getSession().getAttribute(
FrmBuilderAction.FRM_LAYOUT_KEY);
Integer resultCount = null;
SrchResultValue srchResult = SearchResultsAction.retrieveSearchResults(request);
if (srchResult != null) {
resultCount = new Integer(srchResult.getTotal());
}
sfd.saveSearch(userGuid,
form.getTitle(),
form.getDesc(),
form.getNewTtle(),
srchValue,
frmLayout,
resultCount,
form.getSearches());
}
SrchFrmDelegate.java
/**
* Reference to the remote interface.
*/
private SrhFrmFacadeRemote srhFacadeRemote;
public String saveSearch(final String userId, final String srchTtle,
final String srchDesc, final Boolean newTtle,
final BsSearchValue srchValue, final FrmLay frmLay,
final Integer resultCount, final List alerts)
throws UsrNotFoundException,
RemoteException {
return srhFacadeRemote.saveSearch(userId, srchTtle,
srchDesc, newTtle, srchValue, frmLay,
resultCount, alerts);
}
SrchFrmFacadeRemote.java
/**
* Remote interface for SrchFrmFacade.
*/
public java.lang.String saveSearch( java.lang.String userId,java.lang.String srchTtle,java.lang.String srchDesc,java.lang.Boolean newTtle,com.common.search.BsSearchValue srchValue,com.common.search.advanced.FrmLay frmLay,java.lang.Integer resultCount,java.util.List alerts ) throws com.common.admin.UserNotFoundException, java.rmi.RemoteException;

Objects that passed as parameters or as response on remote calls must be Serializable.
example:-
public class APIGetVerificationProofs implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private String fileName;
private String mimeType;
private String itemId;
private String type;
.
.
.
.
}

After adding the below jars in Jboss 7 modules & altering the standalone.xml file accordingly, Issue is fixed.
jboss-eap-6.1.0.Alpha\modules\system\layers\base\org\apache\commons\validator
commons-validator-1.1.0.jar
jboss-eap-6.1.0.Alpha\modules\system\layers\base\org\apache\commons\collections commons-collections-3.2.1.jar
In Standalone.xml
<subsystem xmlns="urn:jboss:domain:ee:1.1">
<spec-descriptor-property-replacement>false</spec-descriptor-property-replacement>
<jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>
<global-modules>
<module name="org.apache.commons.collections" slot="main"/>
<module name="org.apache.commons.validator" slot="main"/>
</global-modules>
</subsystem>

In EJB3 this error can also occur when invoking an EJB Session Bean across a #Remote view of the EJB. Depending on the design and usage scenario, you may be able to invoke the EJB over a #Local interface. Using the #Local interface will eliminate the requirement for the parameters to be Serializable but this can markedly change your design. If using the #Local view is an option for you, you can simply add the #Local to the EJB without removing the #Remote.
public class MySessionBeanImpl implements MySessionBean {
...
}
#Local
#Remote
public interface MySessionBean {
...
}
The JEE App Server will make the right decision to use the local view if the client of the invocation is in-container. According to the API docs, the Local annotation can appear on either the class or the interface. If on the class, the value attribute must be specified.

remember to add serialVersionUID to let class to be serialized and restored (generate it as getter or setter)

For this problem first, you have to implement Serializable interface in your POJO class (java beans) as:
package com.test;
import java.io.Serializable;
public class Employee implements Serializable {
private static final long serialVersionUID = 1L;
private int empID;
private String empName;
private int empSalary;
public int getEmpID() {
return empID;
}
//alt_shift_s_r-getter and setter method
//alt_shift_s_s override toString()
public void setEmpID(int empID) {
this.empID = empID;
}
public String getEmpName() {
return empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
public int getEmpSalary() {
return empSalary;
}
public void setEmpSalary(int empSalary) {
this.empSalary = empSalary;
}
#Override
public String toString() {
return "Employee [empID=" + empID + ", empName=" + empName + ", empSalary=" + empSalary + "]";
}
}
Note: if you are adding some external jars into your project then follow the below procedure to add jars.
Right Click on your EJB project and go to properties.
Then Select Deployment assembly then clicks on add.
From the appears option select appropriate source (As Archive from File System) then go to next.
Now Add jars from your desired location and finish the procedure.
enter code here

Related

#Cacheable annotation cannot work as expected when deserialize beans with LocalDateTime type property

I found that the annotation #Cacheable cannot work when the method returns a Java Bean type, this is the complete description:
I annotated #Cacheable on a method to use spring cache:
#Cacheable(cacheNames="userCache", key="#userId")
public User getUser(long userId){
return userRepository.getUserById(userId);
}
And the User class like this:
public class User{
Long userId;
String username;
#JsonSerialize(using = LocalDateTimeSerializer.class)
#JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime birthDateTime;
}
As you can see, I annotated the relating Jackson annotations to make Jackson deserialization for LocalDateTime types work, and this is the related dependency in pom.xml:
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.12.5</version>
</dependency>
After that, I call the #Cacheable method getUser like this:
User user = userCache.getUser(1L);
and there throws an exception:
org.redisson.client.RedisException: Unexpected exception while processing command
at org.redisson.command.CommandAsyncService.convertException(CommandAsyncService.java:326)
at org.redisson.command.CommandAsyncService.get(CommandAsyncService.java:123)
at org.redisson.RedissonObject.get(RedissonObject.java:82)
...blabla
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type java.time.LocalDateTime not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling at [Source: (io.netty.buffer.ByteBufInputStream); line: 1, column: 101] (through reference chain: com.stackoverflow.domain.User["birthDateTime"]) at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67)
at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1764)
at com.fasterxml.jackson.databind.deser.impl.UnsupportedTypeDeserializer.deserialize(UnsupportedTypeDeserializer.java:36)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
3.Before I use the #Cacheable, there is no problem if I get the User from database straightly. But when I begin to use #Cacheable, it always throws the exception above, no matter if I configured those Jackson deserialization for LocalDateTime. Is #Cacheable cannot work well with Java Bean with LocalDateTime property, or just my configuration of Jackson is wrong?
I had the same problem. Spring Cache doesn't use the implicit ObjectMapper used by other Spring components.
Include the module, you already did that.
Create a configuration which will override the default Spring Cache Configuration:
#Configuration
#EnableCaching
public class CacheConfiguration {
#Bean
public RedisSerializationContext.SerializationPair<Object> serializationPair() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule())
.activateDefaultTyping(
objectMapper.getPolymorphicTypeValidator(),
ObjectMapper.DefaultTyping.EVERYTHING,
JsonTypeInfo.As.PROPERTY
);
return RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer(objectMapper));
}
#Bean
public RedisCacheConfiguration redisCacheConfiguration(
#Value("${cache.default-ttl-in-seconds}") Integer ttl,
RedisSerializationContext.SerializationPair<Object> serializationPair
) {
return RedisCacheConfiguration.defaultCacheConfig()
.disableCachingNullValues()
.entryTtl(Duration.ofSeconds(ttl))
.serializeValuesWith(serializationPair);
}
}

Using own jackson versions in Flink causes VerifyError

I'm using Apache Flink (v1.11) with Scala and added an own DeserializationSchema for Kafka connector. Therefore i would like to use my own packages and versions of jackson (v2.12.0).
But i got the following error:
Exception in thread "main" java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at com.fasterxml.jackson.dataformat.csv.CsvMapper.<init>(CsvMapper.java:108)
at de.integration_factory.datastream.types.CovidEventSchema.<init>(CovidEventSchema.scala:14)
at de.integration_factory.datastream.Aggregate_Datastream$.main(Aggregate_Datastream.scala:34)
at de.integration_factory.datastream.Aggregate_Datastream.main(Aggregate_Datastream.scala)
This is my EventSchema:
import com.fasterxml.jackson.dataformat.csv.CsvMapper
import com.fasterxml.jackson.datatype.joda.JodaModule
import org.apache.flink.api.common.serialization.{DeserializationSchema, SerializationSchema}
import org.apache.flink.api.common.typeinfo.TypeInformation
#SerialVersionUID(6154188370181669758L)
class CovidEventSchema extends DeserializationSchema[CovidEvent] with SerializationSchema[CovidEvent] {
private val mapper = new CsvMapper
mapper.registerModule(new JodaModule)
val csvSchema = mapper
.schemaFor(classOf[CovidEvent])
.withLineSeparator(",")
.withoutHeader()
val reader = mapper.readerWithSchemaFor(classOf[CovidEvent])
def serialize(event: CovidEvent): Array[Byte] = mapper.writer(csvSchema).writeValueAsBytes()
#throws[IOException]
def deserialize(message: Array[Byte]): CovidEvent = reader.readValue[CovidEvent](message)
def isEndOfStream(nextElement: CovidEvent) = false
def getProducedType: TypeInformation[CovidEvent] = TypeInformation.of(classOf[CovidEvent])
}
This is my PoJo for schema:
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.joda.time.DateTime;
#Data
#NoArgsConstructor
#AllArgsConstructor
public class CovidEvent {
private long objectId;
private int bundeslandId;
private String bundesland;
private String landkreis;
private String altersgruppe;
private String geschlecht;
private int anzahlFall;
private int anzahlTodesfall;
#JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "UTC")
private DateTime meldedatum;
private int landkreisId;
private String datenstand;
private int neuerFall;
private int neuerTodesfall;
private String refDatum;
private int neuGenesen;
private int anzahlGenesen;
#JsonFormat(shape = JsonFormat.Shape.NUMBER)
private boolean istErkrankungsbeginn;
private String altersGruppe2;
public long getEventtime() {
return meldedatum.getMillis();
}
}
After some research I found out that the error is probably caused by different Jackson versions in the classpath.
I thought it would be possible to use own version of Jackson, because Flink shaded the own versions.
What am I doing wrong?
UPDATE: If i import the jackson classes from shaded flink package it is working
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.dataformat.csv.CsvMapper
But so i am dependent on the flink shaded jackson version.
UPDATE: So a better implementation by using open is something like this ?
class CovidEventSchema extends DeserializationSchema[CovidEvent] with SerializationSchema[CovidEvent] {
private var reader: ObjectReader = null
private var writer: ObjectWriter = null
override def open(context: SerializationSchema.InitializationContext): Unit = {
val mapper = new CsvMapper()
val csvSchema = mapper
.schemaFor(classOf[CovidEvent])
.withLineSeparator(",")
.withoutHeader()
this.reader = mapper.readerFor(classOf[CovidEvent]).`with`(csvSchema)
this.writer = mapper.writer(csvSchema)
super.open(context)
}
}
It would work if the classloader of Flink are used. However, the way your setup works, you are just loading your user code in the system classloader while the whole DataStream application is created. I'm not going to much into more details (unless requested in a follow-up) and go for the solution:
Your DeserializationSchema should never initialize heavy resources during creation (this happens on client or job manager side), but only in open (which happens on task manager). So please move
private val mapper = new CsvMapper
mapper.registerModule(new JodaModule)
into open.
It only works with the bundled version because - lucky for you - ObjectMapper implements Serializable but that is rarely the case for parsers and actually completely unnecessary if the deserializer is initialized correctly.

redefine static methods with ByteBuddy

Can homebody help me please to give me a hint how to redefine static methods using byte-buddy 1.6.9 ?
I have tried this :
public class Source {
public static String hello(String name) {return null;}
}
public class Target {
public static String hello(String name) {
return "Hello" + name+ "!";
}
}
String helloWorld = new ByteBuddy()
.redefine(Source.class)
.method(named("hello"))
.intercept(MethodDelegation.to(Target.class))
.make()
.load(getClass().getClassLoader())
.getLoaded()
.newInstance()
.hello("World");
I got following Exception :
Exception in thread "main" java.lang.IllegalStateException: Cannot inject already loaded type: class delegation.Source
Thanks
Classes can only be loaded once by each class loader. In order to replace a method, you would need to use a Java agent to hook into the JVM's HotSwap feature.
Byte Buddy provides a class loading strategy that uses such an agent, use:
.load(Source.class.getClassLoader(),
ClassReloadingStrategy.fromInstalledAgent());
This does however require you to install a Java agent. On a JDK, you can do so programmatically, by ByteBuddyAgent.install() (included in the byte-buddy-agent artifact). On a JVM, you have to specify the agent on the command line.

GemFire: serialize objects in Java and then deserialize them in c#

To cross the language boundary in Java side the class to be serialized needs to implement the DataSerializable interface; and in order to let the deserializer in c# know what class it is , we need to register a classID. Following the example, I write my class in Java like this:
public class Stuff implements DataSerializable{
static { // note that classID (7) must match C#
Instantiator.register(new Instantiator(Stuff.class,(byte)0x07) {
#Override
public DataSerializable newInstance() {
return new Stuff();
}
});
}
private Stuff(){}
public boolean equals(Object obj) {...}
public int hashCode() {...}
public void toData(DataOutput dataOutput) throws IOException {...}
public void fromData(DataInput dataInput) throws IOException, ClassNotFoundException { ...}
}
It looks OK but when I run it I get this exception:
[warning 2012/03/30 15:06:00.239 JST tid=0x1] Error registering
instantiator on pool:
com.gemstone.gemfire.cache.client.ServerOperationException: : While
performing a remote registerInstantiators at
com.gemstone.gemfire.cache.client.internal.AbstractOp.processAck(AbstractOp.java:247)
at
com.gemstone.gemfire.cache.client.internal.RegisterInstantiatorsOp$RegisterInstantiatorsOpImpl.processResponse(RegisterInstantiatorsOp.java:76)
at
com.gemstone.gemfire.cache.client.internal.AbstractOp.attemptReadResponse(AbstractOp.java:163)
at
com.gemstone.gemfire.cache.client.internal.AbstractOp.attempt(AbstractOp.java:363)
at
com.gemstone.gemfire.cache.client.internal.ConnectionImpl.execute(ConnectionImpl.java:229)
at
com.gemstone.gemfire.cache.client.internal.pooling.PooledConnection.execute(PooledConnection.java:321)
at
com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.executeWithPossibleReAuthentication(OpExecutorImpl.java:646)
at
com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:108)
at
com.gemstone.gemfire.cache.client.internal.PoolImpl.execute(PoolImpl.java:624)
at
com.gemstone.gemfire.cache.client.internal.RegisterInstantiatorsOp.execute(RegisterInstantiatorsOp.java:39)
at
com.gemstone.gemfire.internal.cache.PoolManagerImpl.allPoolsRegisterInstantiator(PoolManagerImpl.java:216)
at
com.gemstone.gemfire.internal.InternalInstantiator.sendRegistrationMessageToServers(InternalInstantiator.java:188)
at
com.gemstone.gemfire.internal.InternalInstantiator._register(InternalInstantiator.java:143)
at
com.gemstone.gemfire.internal.InternalInstantiator.register(InternalInstantiator.java:71)
at com.gemstone.gemfire.Instantiator.register(Instantiator.java:168)
at Stuff.(Stuff.java)
Caused by: java.lang.ClassNotFoundException: Stuff$1
I could not figure out why, is there anyone who has experience can help? Thanks in advance!
In most configurations GemFire servers need to deserialize objects in order to index them, run queries and call listeners. So when you register instantiator the class will be registered on all machines in the Distributed System. Hence, the class itself must be available for loading everywhere in the cluster.
As exception stack trace says the error happens on a remote node.
Check if you have the class Stuff on all machines participating in the cluster. At least on cache servers.

EJB help needed

public void runTest() throws Exception {
InitialContext ctx = new InitialContext();
ResourceManager bean = (ResourceManager) ctx.lookup("ejb/ResourceManagerJNDI");
System.out.println(bean.DummyText());
}
Hello. So i'm trying to create an EJB application, and this is the test client for it. the JNDI lookup is successful but when calling the "DummyText" method, i get the following error:
javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: nested exception is: javax.ejb.CreateException: Could not create stateless EJB; nested exception is:
javax.ejb.EJBException: nested exception is: javax.ejb.CreateException: Could not create stateless EJB (...)
This is how the bean class looks:
#Stateless(name="ResourceManager", mappedName="ejb/ResourceManagerJNDI")
#Remote
#Local
public class ResourceManagerBean implements ResourceManager
{
#EJB
private AccessDAO accessDAO;
#EJB
private ResourceDAO resourceDAO;
#EJB
private DepartmentDAO departmentDAO;
(list of methods)
}
Any advice will be greatly appreciated. Thank you.
Here's my first thoughts.
You should have something like
#Remote
public interface ResourceManagerSessionRemote {
(list of methods)
}
Break your remote and local interfaces out
#Stateless(name="ResourceManager", mappedName="ejb/ResourceManagerJNDI")
public class ResourceManagerBean implements ResourceManagerSessionRemote
{
#EJB
private AccessDAO accessDAO;
#EJB
private ResourceDAO resourceDAO;
#EJB
private DepartmentDAO departmentDAO;
(list of methods)
}