WASSession E SessionContextMBeanAdapter findAttCausingNotSerializableException - multithreading

We are getting below mentioned exception in our sysout.log file.
Please provide your help on how we can solve this.
Is there any setting which we can make into the Websphere Application Server?
000000a3 WASSession E SessionContextMBeanAdapter
findAttCausingNotSerializableException Miscellaneous data: Attribute
"EXCELEXPORTERREGISTERID" is declared to be serializable but is found
to generate exception "java.io.NotSerializableException" with message
"com.ubs.fsl.idama.action.codification.CodificationsHandler$1". Fix
the application so that the attribute "EXCELEXPORTERREGISTERID" is
correctly serializable at runtime.
We have implemented serialization where ever required in our java code.
After that it is giving the below exception.
00000078 WASSession E SessionContextMBeanAdapter
findAttCausingNotSerializableException Miscellaneous data: Attribute
"com.ubs.fsl.ca.ia.CAReceptionRoomIA" is declared to be serializable
but is found to generate exception "java.io.NotSerializableException"
with message "com.ibm.ws.webcontainer.srt.SRTServletRequest". Fix the
application so that the attribute
"com.ubs.fsl.ca.ia.CAReceptionRoomIA" is correctly serializable at
runtime.
Note : The above exceptions started when we migrated from WAS 7.0.0.31 to WAS 9.0.0.5.

Related

Why does cxf throw an unmarshalling error on elements that have no namespace prefix when the namespace should be inherited

I am creating a SOAP client that runs in a Java 11 Spring Boot server and makes requests to a Java 8 server. I'm using cxf-rt-frontend-jaxws:3.4.3 and cxf-rt-transports:3.4.3 in a Gradle 6.9 build with the com.github.bjornvester.wsdl2java Gradle plugin version 1.1.
My client can call a simple echo test SOAP operation with no problem. That service passes a request object containing a single String and gets a response object containing the String. So I know the basic connection is working and the other end is responding.
My problem arises when I call an operation that has no input and returns a list of objects in the response. I get this error:
org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element (uri:"", local:"ProposalInfo"). Expected elements are <{http://V2.pub.proposal.server.ws.cayuse.com/}ProposalInfo>
I am told that other systems call these operations with no problem.
I have stepped through the cxf and JAXB code and notice that the IntelliJ shows this text associated with a BranchingReaderSource. Not sure if this is a true error or just a side-effect of the debugger trying to call toString() on this class (which has no such method).
Method threw 'java.lang.NullPointerException' exception. Cannot evaluate com.ctc.wstx.io.BranchingReaderSource.toString()
I also notice that a class called ValidationEventLocatorImpl gets a NullPointerException on this line because "toURL" is null. I think this is because toURL comes from the empty prefix of in the response.
this.url = toURL(loc.getSystemId());
I have tried using wrapping-style "false" but that does not change anything.
I also tried to use TransformInInterceptor to map elements with no prefix to the desired prefix, but that did not work. It seems the unmarshalling error gets thrown before the interceptor runs.
Here is the WSDL used for this service; the operation that I am calling is getUnpairedProposals. I also attach a copy of the response to this operation -- the operation that is not getting unmarshalled properly. My reading of this response is that the namespace defined on the ns2:getUnPairedProposalsResponse tag should apply to the child elements such as .
Additional info:
I made several attempts to use TransformInterceptor to map the elements:
Added a map entry for "getUnPairedProposalsResponse -> {http://V2.pub.proposal.server.ws.cayuse.com/}getUnPairedProposalsResponse". This did nothing.
Inserted the TransformInterceptor at Phase.PRE_STREAM. Also had no effect.
Changed the mapping from #1 to the same but added a prefix {}, as in {}getUnPairedProposalsResponse -> {http://V2.pub.proposal.server.ws.cayuse.com/}getUnPairedProposalsResponse. This got me a null pointer exception in cxf at TransformUtils line 128 in the convertToQnamesMap method.

Mockito latest versions support to surpress static block

I am trying to add tests using latest (5.7.0) Mockito and using Mockito.mockStatic(...)
to mock class with static methods which works fine . However when I have class with static block it is unable to create mock and fais with java.lang.InternalError: class redefinition failed: invalid class .
Is this supported in latest mockito versions or still I have to live with other alternatives like powermock.
I did face the same error and couldn't find answer in the internet, so I see that it is 1 month old question but might help someone.
The problem was that mocked class (or classes that this static block used) was not in the classpath. Before you can mock the method all static blocks or fields initializators will be run, and it causes the problem.
You can verify what class is missing in your classpath by simply trying to use this static method before mocking it. You should get java.lang.NoClassDefFoundError with a class name.
When you resolve this problem, everything should work.
I had this issue, and for me it was due to an Error being thrown from instrumentation.retransformClasses called from org.mockito.internal.creation.bytebuddy.inlineBytecodeGenerator. Somewhere between there and findOrInsert in net.bytebuddy.TypeCache, the Throwable looses its context (for mockito-core 4.1.0 and bytebuddy 1.12.0)
In my case, the error being thrown was a NoClassDefFoundError for Jetty Servlet. This ultimately turned out to be a dodgy local build of a different maven module I had been working on, so clearing out my ~/.m2 and downloading a legit version fixed that right up.
You might be able to catch the Error being thrown in inlineBytecodeGenerator and taking a look at what's really going on, if this is in fact the same problem.

Hazelcast Supplier and Aggregation gives Concurrent Execution Exception

I am trying to get a set of the distinct values of an object's field stored in a Hazelcast map.
This line of java code:
instructions.aggregate(Supplier.all(value -> value.getWorkArea()), Aggregations.distinctValues());
has the following stacktrace :
java.util.concurrent.ExecutionException: com.hazelcast.nio.serialization.HazelcastSerializationException: java.lang.ClassNotFoundException: com.example.instruction.repository.HazelcastInstructionRepository$GeneratedEvaluationClass
com.hazelcast.nio.serialization.HazelcastSerializationException: java.lang.ClassNotFoundException: com.example.instruction.repository.HazelcastInstructionRepository$GeneratedEvaluationClass
java.lang.ClassNotFoundException: com.example.instruction.repository.HazelcastInstructionRepository$GeneratedEvaluationClass
If I were to try this line :
instructions.aggregate(Supplier.all()), Aggregations.distinctValues());
or:
instructions.aggregate(Supplier.fromPredicate(Predicates.and(Predicates.equal("type", "someType"), equal("groupId", null),
Predicates.equal("workArea", "someWorkArea"))), Aggregations.distinctValues());
It just works ... It seems to be something wrong when I am making a reference to the object's field. (I also tried it with other fields of the object and the same error gets returned)
This is running on my local environment and I am sure that the objects are being placed correctly in the Hazelcast map since the other aggregations/predicates are working.
Do you have any ideas about what am I doing wrong?
Many Thanks!
EDITED: So the problem is the closure. It's not available on all nodes. Only on the calling node.
Also. This feature is deprecated. Plz use the fast-aggregations instead.
http://docs.hazelcast.org/docs/latest/manual/html-single/#fast-aggregations

Error on SimpleTemplateEngine embedded in Java: Could not instantiate custom Metaclass for class: java.util.ArrayList

I have a app where my users input a HTML template with SimpleTemplateEngine notation, and execute this template with code above, in a Java Class:
new SimpleTemplateEngine().createTemplate(templateStr).make(map).toString()
and I obtain this error:
groovy.lang.GroovyRuntimeException: Could not instantiate custom Metaclass for class: java.util.ArrayList. Reason: java.lang.NoSuchMethodException: groovy.runtime.metaclass.java.util.ArrayListMetaClass.<init>(groovy.lang.MetaClass)
I observe that error occurrs in a loop in a java.util.ArrayLIst in a JPA Entity loaded by Hibernate:
<%for(int k=0; k< Registro[i].listUsers.size();k++){%>
HTML CODE
<%}%>
Anyone can help me? I no have more ideas about this error...
Thanks!
I'm guessing that the part Registro[i] is for getting the value of a static property which name is held under the variable i (or at least that is what will happen) unless the getAt(String) method has been overloaded on Registro.
Either way I also guess that returns an object that has a listUsers property that should be at least a Collection.
Maybe the problem is with the initialization of said listUsers property.
Some Registro code could be used for better understanding.

integrating Swagger with JAX-RS and JAXB help needed

I'm working on REST Api using JAX-RS and JAXB. I also would like to use Swagger to generate docs for the api. I followed the example here https://github.com/wordnik/swagger-core/wiki/java-jax-rs . So I have added com.wordnik.swagger.jaxrs.listing to init parameters in web.xml as below:
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.api.resources;com.api;com.wordnik.swagger.jaxrs.listing;</param-value>
</init-param>
When I tray to access the localhost:9090/rapi/api-docs.json url I get the following error:
SEVERE: Mapped exception to response: 500 (Internal Server Error)
javax.ws.rs.WebApplicationException: javax.xml.bind.JAXBException: class com.wordnik.swagger.core.Documentation nor any of its super class is known to this context.
at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.writeTo(AbstractRootElementProvider.java:159)
at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:306)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1451)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1363)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1353)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:414)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
Caused by: javax.xml.bind.JAXBException: class com.wordnik.swagger.core.Documentation nor any of its super class is known to this context.
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:611)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:486)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:320)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:177)
at com.sun.jersey.json.impl.BaseJSONMarshaller.marshallToJSON(BaseJSONMarshaller.java:103)
at com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider.writeTo(JSONRootElementProvider.java:143)
at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.writeTo(AbstractRootElementProvider.java:157)
I fixed it by adding com.wordnik.swagger.core to my custom JAXBContextProvider as below:
public JAXBContextProvider() throws JAXBException {
this.context = new JSONJAXBContext(JSONConfiguration.natural().build(),
"com.api.model.impl.v1:com.api.resource.framework:com.wordnik.swagger.core");
}
This caused another error:
SEVERE: The provider class, class comapi.JAXBContextProvider, could not be instantiated. Processing will continue but the class will not be utilized
javax.xml.bind.JAXBException: "com.wordnik.swagger.core.Documentation" doesnt contain ObjectFactory.class or jaxb.index
I have been using jaxb.index files to keep the context aware of the classes with JAXB annotations, however there is no jaxb.index file in swagger package which inludes the Documentation class. Has anyone come across similar issue when integrating Swagger with JAXB and JAX-RS?
Turned out I needed to create JAXBContext in addition to already created JSONJAXBContext.
I added
this.swaggerJAXBcontext = JAXBContext.newInstance(com.wordnik.swagger.core.Documentation.class);
to constructor and this to getContext(Class type) method:
if (type.equals(com.wordnik.swagger.core.Documentation.class)){
return swaggerJAXBcontext;
}

Resources