Wink JsonProvider throwing java.lang.reflect.UndeclaredThrowableException - apache-wink

I have a jax-ws service that is calling a JAX-RS service using Wink client.
When I deployed the code to the server (WAS 7.0.0.29) and tested the service I got an exception that wasn't occurring in RAD (included below).
With more tracing all I could find was java.lang.reflect.UndeclaredThrowableException being thrown. The exception is coming out of the JsonProvider.writeTo when it attempts to get the callback parameter.
Unable to determine what was causing the exception I took the JsonProvider source and added an additional catch for Throwable and placed this class in the classpath before the class from the Wink distribution. This allowed my service to succeed (since we are not using a callback).
Now I know where the exception is from, but I am not able to determine what class it really is trying to indicate is missing. I need help figuring out what may be missing.
[7/24/15 6:41:55:984 PDT] 00000046 WebServiceExc E org.apache.axis2.jaxws.WebServiceExceptionLogger log A java.lang.NoClassDefFoundError throwable was caught. The detail message is: at java.lang.J9VMInternals.initialize(J9VMInternals.java:140)
at com.sun.proxy.$Proxy60.getQueryParameters(Unknown Source)
at org.apache.wink.providers.json.JsonProvider.writeTo(JsonProvider.java:96)
at org.apache.wink.providers.json.JsonProvider.writeTo(JsonProvider.java:53)
at org.apache.wink.client.internal.handlers.AbstractConnectionHandler.writeEntity(AbstractConnectionHandler.java:116)
at org.apache.wink.client.internal.handlers.httpclient.ApacheHttpClientConnectionHandler.access$200(ApacheHttpClientConnectionHandler.java:72)
at org.apache.wink.client.internal.handlers.httpclient.ApacheHttpClientConnectionHandler$EntityWriter.writeTo(ApacheHttpClientConnectionHandler.java:405)
at org.apache.http.entity.HttpEntityWrapper.writeTo(HttpEntityWrapper.java:98)
at org.apache.http.impl.client.EntityEnclosingRequestWrapper$EntityWrapper.writeTo(EntityEnclosingRequestWrapper.java:108)
at org.apache.http.impl.entity.EntitySerializer.serialize(EntitySerializer.java:122)
at org.apache.http.impl.AbstractHttpClientConnection.sendRequestEntity(AbstractHttpClientConnection.java:271)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.sendRequestEntity(ManagedClientConnectionImpl.java:197)
at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:257)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:713)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:518)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
at org.apache.wink.client.internal.handlers.httpclient.ApacheHttpClientConnectionHandler.processRequest(ApacheHttpClientConnectionHandler.java:113)
at org.apache.wink.client.internal.handlers.httpclient.ApacheHttpClientConnectionHandler.handle(ApacheHttpClientConnectionHandler.java:87)
at org.apache.wink.client.internal.handlers.HandlerContextImpl.doChain(HandlerContextImpl.java:52)
at org.apache.wink.client.internal.handlers.AcceptHeaderHandler.handle(AcceptHeaderHandler.java:79)
at org.apache.wink.client.internal.handlers.HandlerContextImpl.doChain(HandlerContextImpl.java:52)
at org.apache.wink.client.internal.ResourceImpl.invoke(ResourceImpl.java:228)
at org.apache.wink.client.internal.ResourceImpl.invoke(ResourceImpl.java:189)
at org.apache.wink.client.internal.ResourceImpl.post(ResourceImpl.java:315)
at net.flowers.ecommerce.personalization.PersonalizationClient.createKey(Unknown Source)
at com.bco.retail.externalservices.esb.personalization.servicefacade.PersonalizationService.createKey(Unknown Source)
at com.bco.retail.externalservices.esb.personalization.servicefacade.PersonalizationServiceDelegate.createKey(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at org.apache.axis2.jaxws.server.dispatcher.JavaDispatcher.invokeTargetOperation(JavaDispatcher.java:120)
at org.apache.axis2.jaxws.server.dispatcher.JavaBeanDispatcher.invoke(JavaBeanDispatcher.java:117)
at org.apache.axis2.jaxws.server.EndpointController.invoke(EndpointController.java:111)
at org.apache.axis2.jaxws.server.JAXWSMessageReceiver.receive(JAXWSMessageReceiver.java:161)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:189)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
at com.ibm.ws.websvcs.transport.http.WASAxis2Servlet.doPost(WASAxis2Servlet.java:1442)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at com.ibm.ws.cache.servlet.ServletWrapper.serviceProxied(ServletWrapper.java:307)
at com.ibm.ws.cache.servlet.CacheHook.handleFragment(CacheHook.java:576)
at com.ibm.ws.cache.servlet.CacheHook.handleServlet(CacheHook.java:250)
at com.ibm.ws.cache.servlet.ServletWrapper.service(ServletWrapper.java:259)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1661)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:944)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:507)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:181)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3954)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:945)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:191)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:453)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:515)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:306)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:277)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1656)
I also have the following from the Wink Trace logging that is logging out right after starting the call to getQueryParameters and continues to repeat (more times than shown below) and seems to end when the exception is thrown.
[7/24/15 16:46:01:840 PDT] 00000054 SystemOut O TRACE ProvidersRegistry - Getting ContextResolver for interface javax.ws.rs.core.UriInfo which has #Produces compatible with */*
[7/24/15 16:46:01:840 PDT] 00000054 SystemOut O TRACE ProvidersRegistry - ContextResolvers MediaTypeMap was empty so returning null
[7/24/15 16:46:01:840 PDT] 00000054 SystemOut O TRACE ProvidersRegistry - Getting ContextResolver for interface javax.ws.rs.core.UriInfo which has #Produces compatible with */*
[7/24/15 16:46:01:841 PDT] 00000054 SystemOut O TRACE ProvidersRegistry - ContextResolvers MediaTypeMap was empty so returning null
[7/24/15 16:46:01:841 PDT] 00000054 SystemOut O TRACE ProvidersRegistry - Getting ContextResolver for interface javax.ws.rs.core.UriInfo which has #Produces compatible with */*
[7/24/15 16:46:01:841 PDT] 00000054 SystemOut O TRACE ProvidersRegistry - ContextResolvers MediaTypeMap was empty so returning null
[7/24/15 16:46:01:841 PDT] 00000054 SystemOut O TRACE ProvidersRegistry - Getting ContextResolver for interface javax.ws.rs.core.UriInfo which has #Produces compatible with */*
[7/24/15 16:46:01:841 PDT] 00000054 SystemOut O TRACE ProvidersRegistry - ContextResolvers MediaTypeMap was empty so returning null
[7/24/15 16:46:01:841 PDT] 00000054 SystemOut O TRACE ProvidersRegistry - Getting ContextResolver for interface javax.ws.rs.core.UriInfo which has #Produces compatible with */*
[7/24/15 16:46:01:841 PDT] 00000054 SystemOut O TRACE ProvidersRegistry - ContextResolvers MediaTypeMap was empty so returning null
[7/24/15 16:46:01:841 PDT] 00000054 SystemOut O TRACE ProvidersRegistry - Getting ContextResolver for interface javax.ws.rs.core.UriInfo which has #Produces compatible with */*
[7/24/15 16:46:01:841 PDT] 00000054 SystemOut O TRACE ProvidersRegistry - ContextResolvers MediaTypeMap was empty so returning null
[7/24/15 16:46:01:841 PDT] 00000054 SystemOut O TRACE ProvidersRegistry - Getting ContextResolver for interface javax.ws.rs.core.UriInfo which has #Produces compatible with */*
[7/24/15 16:46:01:841 PDT] 00000054 SystemOut O TRACE ProvidersRegistry - ContextResolvers MediaTypeMap was empty so returning null
[7/24/15 16:46:01:841 PDT] 00000054 SystemOut O TRACE ProvidersRegistry - Getting ContextResolver for interface javax.ws.rs.core.UriInfo which has #Produces compatible with */*
[7/24/15 16:46:01:841 PDT] 00000054 SystemOut O TRACE ProvidersRegistry - ContextResolvers MediaTypeMap was empty so returning null
I greatly appreciate any assistance in fixing this problem.
thank you

Related

Error in Entity Framework 6.1 - modelBuilder.Build

I have been unsuccessfully trying to track down the follwoing error message:
modelBuilder.Build (Database.Connection)
'modelBuilder.Build (Database.Connection)' löste eine Ausnahme des Typs 'System.ArgumentNullException' aus
Data: {System.Collections.ListDictionaryInternal}
HResult: -2147467261
HelpLink: null
InnerException: null
Message: "Der Wert darf nicht NULL sein.\r\nParametername: entitySet"
ParamName: "entitySet"
Source: "EntityFramework"
StackTrace: " bei System.Data.Entity.Utilities.Check.NotNull[T](T value, String parameterName)\r\n bei System.Data.Entity.Core.Mapping.EntitySetMapping..ctor(EntitySet entitySet, EntityContainerMapping containerMapping)\r\n bei System.Data.Entity.ModelConfiguration.Edm.DbDatabaseMappingExtensions.AddEntitySetMapping(DbDatabaseMapping databaseMapping, EntitySet entitySet)\r\n bei System.Data.Entity.ModelConfiguration.Edm.Services.TableMappingGenerator.Generate(EntityType entityType, DbDatabaseMapping databaseMapping)\r\n bei System.Data.Entity.ModelConfiguration.Edm.Services.DatabaseMappingGenerator.GenerateEntityTypes(DbDatabaseMapping databaseMapping)\r\n bei System.Data.Entity.ModelConfiguration.Edm.Services.DatabaseMappingGenerator.Generate(EdmModel conceptualModel)\r\n bei System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo)\r\n bei System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)"
TargetSite: {T NotNull[T](T, System.String)}
Can somebody give me a hint where to search for the cause? The validation of the model runs without errors.
That be super!
Thank you!
mph
This error was caused by a malformed configuration which threw an exception which was corrupted while bubbling up and some information - the important part - was lost.
I had to debug deep into EF's bally to find the issue.
In this case it was the mix of wrong configured mappings and automatic detection of relationships.

Issue with Sitefinity 7.3 on azure webrole

I am migrating a sitefinity application onto an azure web role. The database is already migrated to sql azure. And with that connectionstring in DataConfig.config the application runs fine in my local machine. But once I add a cloud project and (made the necessary changes mentioned in telerik documentation - azure assemblies redirection,dataconfig change,app.dll.config file , internal endpoint, local storage) and set this application as a web role it does not work. When I run the cloud project in azure emulator locally or deploy as a cloud service I get the following error.
Enum conversion failed as the property/field is not nullable and no
value has been read from the database. Description: An unhandled
exception occurred during the execution of the current web request.
Please review the stack trace for more information about the error and
where it originated in the code.
Exception Details: System.InvalidOperationException: Enum conversion
failed as the property/field is not nullable and no value has been
read from the database.
Source Error: An unhandled exception was generated during the
execution of the current web request. Information regarding the origin
and location of the exception can be identified using the exception
stack trace below.
Stack Trace:
[InvalidOperationException: Enum conversion failed as the
property/field is not nullable and no value has been read from the
database.] OpenAccessRuntime.Data.EnumConverter.Read(DataHolder&
holder) +470
OpenAccessRuntime.Relational.RelationalGenericState.copyPass1Fields(ResultSet
rs, FetchGroupField[] fetchGroups, Int32 firstCol) +346
[DataStoreException: Error reading field
Telerik.Sitefinity.Forms.Model.FormDraft.k__BackingField
from ResultSet: System.InvalidOperationException: Enum conversion
failed as the property/field is not nullable and no value has been
read from the database. at
OpenAccessRuntime.Data.EnumConverter.Read(DataHolder& holder) at
OpenAccessRuntime.Relational.RelationalGenericState.copyPass1Fields(ResultSet
rs, FetchGroupField[] fetchGroups, Int32 firstCol)
System.InvalidOperationException: Enum conversion failed as the
property/field is not nullable and no value has been read from the
database. at OpenAccessRuntime.Data.EnumConverter.Read(DataHolder&
holder) at
OpenAccessRuntime.Relational.RelationalGenericState.copyPass1Fields(ResultSet
rs, FetchGroupField[] fetchGroups, Int32 firstCol)]
DynamicModule.ns.Wrapped_OpenAccessFormsProvider_f4f053b2c49247a8908c30d75bf02970.GetForm(Guid formId) +413
Telerik.Sitefinity.Modules.Forms.Web.UI.FormsControl.get_FormData()
+759 Telerik.Sitefinity.Modules.Forms.Web.UI.FormsControl.ProcessFormInitialization()
+21 Telerik.Sitefinity.Modules.Forms.Web.UI.FormsControl.InitializeControls(GenericContainer
container) +55
Telerik.Sitefinity.Web.UI.SimpleView.CreateChildControls() +88
System.Web.UI.Control.EnsureChildControls() +189
System.Web.UI.Control.PreRenderRecursiveInternal() +60
System.Web.UI.Control.PreRenderRecursiveInternal() +222
System.Web.UI.Control.PreRenderRecursiveInternal() +222
System.Web.UI.Control.PreRenderRecursiveInternal() +222
System.Web.UI.Control.PreRenderRecursiveInternal() +222
System.Web.UI.Control.PreRenderRecursiveInternal() +222
System.Web.UI.Control.PreRenderRecursiveInternal() +222
System.Web.UI.Control.PreRenderRecursiveInternal() +222
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+4297
I checked the telerik forum as well and found only 2 posts with this error but the solutions suggested did not work.
any solutions to resolve this issue will be helpful.
After adding assembly redirect for all the telerik dlls and other third party DLLs in web. Config and app.DLL.config I also ran 3 update scripts mentioned in sitefinity forum in the db. This fixed the issue and site came up.

Struts 2.1.6 Upgradation with Websphere 7 Server

I am trying to deploy the Struts - 2.1.6 application on Websphere 7.0.27 server. I have enabled the security for the LDAP authentication. When I try to run the application, I am getting following error message :
[3/20/14 12:51:21:086 MDT] 00000017 SystemOut O 2014-03-20 12:51:21,086 WARN com.opensymphony.xwork2.config.providers.InterceptorBuilder - Unable to load config class org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor at interceptor** - wsjar:file:/C:/IBM/WebSphere/AppServer/profiles/AppSrvHSCS/installedApps/IBM-7eee9b3778eNode02Cell/acys-hscs.ear/acys-hscs-web.war/WEB-INF/lib/struts2-core-2.1.6.jar!/struts-default.xml:146:127 probably due to a missing jar, which might be fine if you never plan to use the validation interceptor
[3/20/14 12:51:21:093 MDT] 00000017 SystemOut O 2014-03-20 12:51:21,089 ERROR com.opensymphony.xwork2.config.providers.InterceptorBuilder - **Actual exception
Caught Exception while registering Interceptor class org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor - interceptor - wsjar:file:/C:/IBM/WebSphere/AppServer/profiles/AppSrvHSCS/installedApps/IBM-7eee9b3778eNode02Cell/acys-hscs.ear/acys-hscs-web.war/WEB-INF/lib/struts2-core-2.1.6.jar!/struts-default.xml:146:127
Check to make sure that the DTD declaration in your validation xml files is accurate (from here).

Multiple instances of stateful EJB when injecting via CDI

This is mostly about understanding the differences when injecting a stateful EJB (SFSB) with #Inject compared to injecting it with #EJB.
One of the main differences ought to be the contextual awareness when injecting via #Inject. So my assumption was that if I create two #RequestScoped beans and inject in each an SFSB twice (once with #Inject, once with #EJB), the SFSB injected via #Inject would be the same instance in both #RequestScoped beans, whereas the ones injected via #EJB would be different instances.
This assumption seems to be wrong, but I do not understand why. Shouldn't CDI be aware of the fact that both beans are #RequestScoped and therefore inject the same SFSB? Why is this not so, or is my test code somewhat flawed?
This is my SFSB and its interface:
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.Local;
import javax.ejb.PrePassivate;
import javax.ejb.Stateful;
import package.MyStateful;
#Stateful
#Local(MyStateful.class)
public class MyStatefulImpl implements MyStateful {
#PostConstruct
private void postConstruct() {
System.out.println("SFSB postconstruct ref: " + this.toString());
}
#PreDestroy
private void preDestroy() {
System.out.println("SFSB predestroy ref: " + this.toString());
}
#PrePassivate
private void prePassivate() {
System.out.println("SFSB prepassivate ref: " + this.toString());
}
#Override
public String myToString() {
return toString();
}
}
public interface MyStateful {
String myToString();
}
And this is one #RequestScoped bean:
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import package.MyStateful;
#Named
#RequestScoped
public class MyFirstRequestScoped {
#Inject
MyStateful myStatefulByCDI;
#EJB
MyStateful myStatefulByEJB;
public MyStateful getMyStatefulByCDI() {
System.out.println("first#myStatefulByCDI proxy ref: " + myStatefulByCDI.toString());
System.out.println("first#myStatefulByCDI stateful ref: " + myStatefulByCDI.myToString());
return myStatefulByCDI;
}
public MyStateful getMyStatefulByEJB() {
System.out.println("first#myStatefulByEJB proxy ref: " + myStatefulByEJB.toString());
System.out.println("first#myStatefulByEJB stateful ref: " + myStatefulByEJB.myToString());
return myStatefulByEJB;
}
}
There is another #RequestScoped bean named MySecondRequestScoped with an analoguous implementation.
When these are called from a JSF xhtml page via EL (nothing special, just a <h:outputText value="#{myFirstRequestScoped.myStatefulByCDI}" /> and so on to trigger their creation), this is the console output (WebSphere ApplicationServer 8.5.5.0):
[1/4/14 12:39:11:759 CET] 000000dc SystemOut O SFSB postconstruct ref: package.MyStatefulImpl#c03fcdee
[1/4/14 12:39:11:761 CET] 000000dc SystemOut O SFSB postconstruct ref: package.MyStatefulImpl#36b3bb10
[1/4/14 12:39:11:761 CET] 000000dc SystemOut O first#myStatefulByCDI proxy ref: package.EJSLocal0SFMyStatefulImpl_8d170245#48da7f98(BeanId(Project#ProjectEJB.jar#MyStatefulImpl, 5D0CBA11-0143-4000-E000-6A007F000001))
[1/4/14 12:39:11:762 CET] 000000dc SystemOut O first#myStatefulByCDI stateful ref: package.MyStatefulImpl#36b3bb10
[1/4/14 12:39:11:768 CET] 000000dc SystemOut O SFSB postconstruct ref: package.MyStatefulImpl#9b3971c7
[1/4/14 12:39:11:768 CET] 000000dc SystemOut O SFSB postconstruct ref: package.MyStatefulImpl#456cec27
[1/4/14 12:39:11:769 CET] 000000dc SystemOut O second#myStatefulByCDI proxy ref: package.EJSLocal0SFMyStatefulImpl_8d170245#48da7fa1(BeanId(Project#ProjectEJB.jar#MyStatefulImpl, 5D0CBA18-0143-4000-E001-6A007F000001))
[1/4/14 12:39:11:769 CET] 000000dc SystemOut O second#myStatefulByCDI stateful ref: package.MyStatefulImpl#456cec27
[1/4/14 12:39:11:769 CET] 000000dc SystemOut O first#myStatefulByEJB proxy ref: package.EJSLocal0SFMyStatefulImpl_8d170245#48da7f9b(BeanId(Project#ProjectEJB.jar#MyStatefulImpl, 5D0CBA0E-0143-4000-E000-6A007F000001))
[1/4/14 12:39:11:769 CET] 000000dc SystemOut O first#myStatefulByEJB stateful ref: package.MyStatefulImpl#c03fcdee
[1/4/14 12:39:11:769 CET] 000000dc SystemOut O second#myStatefulByEJB proxy ref: package.EJSLocal0SFMyStatefulImpl_8d170245#48da7fa1(BeanId(Project#ProjectEJB.jar#MyStatefulImpl, 5D0CBA18-0143-4000-E000-6A007F000001))
[1/4/14 12:39:11:770 CET] 000000dc SystemOut O second#myStatefulByEJB stateful ref: package.MyStatefulImpl#9b3971c7
[1/4/14 12:39:11:848 CET] 000000dc SystemOut O SFSB predestroy ref: package.MyStatefulImpl#36b3bb10
[1/4/14 12:39:11:849 CET] 000000dc SystemOut O SFSB predestroy ref: package.MyStatefulImpl#456cec27
[1/4/14 12:50:11:765 CET] 00000120 SystemOut O SFSB prepassivate ref: package.MyStatefulImpl#c03fcdee
[1/4/14 12:50:11:766 CET] 00000120 SystemOut O SFSB prepassivate ref: package.MyStatefulImpl#9b3971c7
So it seems that:
4 instances of the SFSB are created; I would have expected this to be just 3. Those injected via #EJB aren't aware of the context, so I would have thought it's ok if they're created for every injection point. But since CDI should be aware of the context (#RequestScoped), I thought CDI would reinject the SFSB already created.
The only difference between #Inject and #EJB seems to be here that the life-cycle is automatically managed when injected via CDI - the method annotated #PreDestroy is called for those (36b3bb10 and 456cec27). These injected via #EJB (c03fcdee and 9b3971c7) are later only passivated and don't seem to be destroyed any time later.
The latter seems to be a good reason to use #Inject instead of #EJB, but what I don't understand is what is really meant by the contextual awareness of CDI, when there's a new instance of the SFSB created regardless of the scope?
By the way, this behaves the same when using #SessionScoped beans, even if the second bean is created after following a link to another page (to make sure that the SFSB injected via #Inject definitely exists already). Moreover, the SFSB instances injected via #EJB are created just once for the lifetime of the session, just like the ones injected via #Inject - so these seem to be aware of the context, too, somehow...? When mixing #SessionScoped and #RequestScoped beans, the #SessionScoped bean gets another instance of the SFSB injected than the #RequestScoped bean, which is fine - but which seems not to be a feature of CDI somehow, since this is true for both those instances of the SFSB injected via #Inject as well as for those injected via #EJB.
Edit: Conclusion of the observed behaviour:
The only difference between injecting an SFSB via #Inject and #EJB seems to be that in the former case the SFSB is automatically destroyed when the scope is left and in the latter case it's not. Is this correct? This would strike me as odd, since I expected CDI to behave differently...
Any hints about what I'm missing, i.e. misunderstanding when it comes to the "C" in "CDI"? I hope it's not some WebSphere "speciality"...
In order for your SFSB to be scoped to the request, you need to give it the #RequestScoped scope. Then you should see the same instance injected. Now since both of these are proxy'd, the easiest way to confirm is to set some value from one bean, and get the value from another bean.

Grails getOutputStream() has already been called for this response

i have this method in my controller. Whick basically renders pdf file.
def getUserInvoiceImage (GetInvoiceDataCommand form) {
byte[] pdf = invoiceImageService.getUserInvoiceImage(form.invoiceId)
response.setContentType('application/pdf')
response.outputStream << pdf;
response.outputStream.close()
return false;
}
When i double click it, it works okay. But when i collapse and expand my panel the following exception occurs.
Software caused connection abort: socket write error. Stacktrace follows:
java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at net.bull.javamelody.FilterServletOutputStream.write(FilterServletOutputStream.java:64)
at net.bull.javamelody.CounterResponseStream.write(CounterResponseStream.java:75)
at com.tieto.msi.InvoiceImageController.getUserInvoiceImage(InvoiceImageController.groovy:13)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:151)
at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:271)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:154)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
2013-08-19 12:43:15,636 ERROR KULDARIM org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver: IllegalStateException occurred when processing request: [GET] /MySupplierInvoices/invoiceImage/getUserInvoiceImage - parameters:
invoiceId: 5274216
getOutputStream() has already been called for this response. Stacktrace follows:
org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: getOutputStream() has already been called for this response
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:151)
at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:271)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:154)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalStateException: getOutputStream() has already been called for this response
at net.bull.javamelody.FilterServletResponseWrapper.getWriter(FilterServletResponseWrapper.java:121)
at C__Dev_MyApps_MySupplierInvoices_grails_app_views_error500_gsp.run(error500.gsp:1)
... 10 more
2013-08-19 12:43:15,639 WARN grails.plugin.cache.web.filter.simple.MemoryPageFragmentCachingFilter: Throwable thrown during doFilter on request with URI: /MySupplierInvoices/grails/invoiceImage/getUserInvoiceImage.dispatch and Query: invoiceId=5274216 : Request processing failed; nested exception is org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: getOutputStream() has already been called for this response
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: getOutputStream() has already been called for this response
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:151)
at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:271)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:154)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: getOutputStream() has already been called for this response
... 10 more
Caused by: java.lang.IllegalStateException: getOutputStream() has already been called for this response
at net.bull.javamelody.FilterServletResponseWrapper.getWriter(FilterServletResponseWrapper.java:121)
at C__Dev_MyApps_MySupplierInvoices_grails_app_views_error500_gsp.run(error500.gsp:1)
... 10 more
2013-08-19 12:43:15,640 ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/MySupplierInvoices].[grails]: Servlet.service() for servlet grails threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at net.bull.javamelody.FilterServletResponseWrapper.getWriter(FilterServletResponseWrapper.java:121)
at C__Dev_MyApps_MySupplierInvoices_grails_app_views_error500_gsp.run(error500.gsp:1)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:151)
at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:271)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:154)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
2013-08-19 12:43:15,642 ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/MySupplierInvoices].[default]: Servlet.service() for servlet [default] in context with path [/MySupplierInvoices] threw exception [org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: getOutputStream() has already been called for this response] with root cause
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at net.bull.javamelody.FilterServletResponseWrapper.getWriter(FilterServletResponseWrapper.java:121)
at C__Dev_MyApps_MySupplierInvoices_grails_app_views_error500_gsp.run(error500.gsp:1)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:151)
at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:271)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:154)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
i have read a lot about this issue, but none of solutions helped me. So i`m a bit confused if i do something wrong or just this behavior which i want to reach is not possible.
response.outputStream << pdf;
This code will automatically flush your response, so there's no need to add close() after. Change your code to:
def getUserInvoiceImage (GetInvoiceDataCommand form) {
byte[] pdf = invoiceImageService.getUserInvoiceImage(form.invoiceId)
response.setContentType('application/pdf')
response.outputStream << pdf;
}
I think your panel is using ajax request to get the pdf, When the panel collapse and expand ajax request happening again.
Also see this question and answer
It means that your file is not found
You call flush that's why that message does not thrown.
Comment instruction includes flush calling to see the error message.
if so , management your file existence then , uncomment flush calling.

Resources