JSF1064 "Unable to find or serve resource" warning on jsf 2.0 - jsf

I'm working on an Enterprise project with Java EE 5 and JSF 2.0 (Mojarra 2.0.3) on Weblogic 10.3.3
I don't have an error, but a very annoying warning in my console when going through my application.
Whenever I perform a redirect in JSF, I get a warning in my console of the following form:
Nov 7, 2011 5:36:46 PM com.sun.faces.application.resource.ResourceHandlerImpl logMissingResource
WARNING: JSF1064: Unable to find or serve resource, images/jquery-theme/ui-icons_cc0000_256x240.png.
Nov 7, 2011 5:36:46 PM com.sun.faces.application.resource.ResourceHandlerImpl logMissingResource
WARNING:
java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at weblogic.servlet.internal.ChunkOutput.writeChunkTransfer(ChunkOutput.java:507)
at weblogic.servlet.internal.ChunkOutput.writeChunks(ChunkOutput.java:486)
at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:382)
at weblogic.servlet.internal.ChunkOutput$2.checkForFlush(ChunkOutput.java:580)
at weblogic.servlet.internal.ChunkOutput.write(ChunkOutput.java:306)
at weblogic.servlet.internal.ChunkOutputWrapper.write(ChunkOutputWrapper.java:146)
at weblogic.servlet.internal.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:138)
at java.nio.channels.Channels$WritableByteChannelImpl.write(Channels.java:275)
at com.sun.faces.application.resource.ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:277)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:310)
But in my application, the resource is displayed correctly. I don't know why this warning is being shown, when the image is loaded without a problem. I've read on an icefaces forum that it might be related to the <h:outputScript/> or the <h:outputStylesheet/> tags.
This is my usage of these tags:
<h:outputStylesheet name="jquery-theme/jquery-ui-1.8.16.custom.css" library="css"/>
and
<h:outputScript name="jquery-ui-1.8.16.custom.min.js" library="js"/>
These files are in the src/main/resources/css and src/main/resources/js folders respectively, and once again, they are correctly loaded and visible in the source code of the page. I just want to get rid of these warnings in my console.

java.net.SocketException: Software caused connection abort: socket write error
The connection was aborted while the resource was still busy downloading. That can happen when you for example navigated to a different page, or pressed Esc, or the closed the browser window while the browser is still busy downloading all resources.
I checked the Mojarra source code and see the following in ResourceHandlerImpl#handleResourceRequest() (lines 292-294 in Mojarra 2.1.3):
} catch (IOException ioe) {
send404(context, resourceName, libraryName, ioe, true);
}
So, the IOException on writing the response is been caught and forcibly handled as a 404. Personally, this should have been ignored or delegated to the servletcontainer by throws IOException, not forcibly be transformed into a HTTP 404 error.
I've reported this as issue 2245 the Mojarra guys. Until then, you can't do anything much against it, but it may be good to know that those warnings won't be logged when the javax.faces.PROJECT_STAGE is set to Production instead of Development. Instead, it will be logged as FINE.

Related

wildfly 25 JSF Security

I'm fully aware that wildfly 25 has dropped legacy security realms.
So I tried to move from wildfly 20.0.1 to wildfly 25.0.1.
According to the quickstart ee-security, I did
/subsystem=elytron/policy=jacc:add(jacc-policy={})
I also I had to remove in my jboss-web.xml the value :
<security-domain>jaspitest</security-domain>
Otherwise I do get :
{
"WFLYCTL0412: Required services that are not installed:" => ["jboss.security.security-domain.jaspitest"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.deployment.unit.\"unite_compte.war\".component.SocieteGestionSIXDAOImpl.CREATE is missing [jboss.security.security-domain.jaspitest]",
I also have my own IdentityStore.
When I try to access the site, the login page appears as expected. When I submit the credentials my IdentityStore is called and the validate(Credential) method returns a valid CredentialValidationResult.
Unfortunately, I do get an Exception :
17:05:14,710 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (default task-3) #{loginView.submit}: java.lang.IllegalStateException: java.io.IOException: java.io.IOException: ELY01177: Authorization failed.: javax.faces.FacesException: #{loginView.submit}: java.lang.IllegalStateException: java.io.IOException: java.io.IOException: ELY01177: Authorization failed.
Caused by: java.io.IOException: ELY01177: Authorization failed.
at org.wildfly.security.jakarta.authentication#1.17.1.Final//org.wildfly.security.auth.jaspi.impl.JaspiAuthenticationContext$1.handleOne(JaspiAuthenticationContext.java:188)
at org.wildfly.security.jakarta.authentication#1.17.1.Final//org.wildfly.security.auth.jaspi.impl.JaspiAuthenticationContext$1.lambda$handle$0(JaspiAuthenticationContext.java:100)
at org.wildfly.security.jakarta.authentication#1.17.1.Final//org.wildfly.security.auth.jaspi.impl.SecurityActions.doPrivileged(SecurityActions.java:39)
at org.wildfly.security.jakarta.authentication#1.17.1.Final//org.wildfly.security.auth.jaspi.impl.JaspiAuthenticationContext$1.handle(JaspiAuthenticationContext.java:99)
What shall I do to make it work ?
As the quickstart says, you have to update the Wildlfy configuration as well. Specifically, you have to run the configure-elytron.cli script of the quickstart
More info: https://github.com/wildfly/quickstart/tree/main/ee-security#configure-the-server

How can I add Marvin Framework to a dynamic web project running on tomcat?

Marvin Framework is running perfectly in my Java project in Eclipse. I have copied the whole marvin folder to the project root folder, following the readme file. All good.
Now, when setting up the same app as dynamic web project in Eclipse and try to run it on Eclipses tomcat 9, I get a HTTP Status 500 – Internal Server Error caused by java.lang.ClassNotFoundException (see 'ERROR 1'below).
It seems, in a dynamic web project the jars should be in WEB-INF/lib. When copying marvin_1.5.5.jar to WEB-INF/lib the class marvin.image.MarvinImage is found correctly (ERROR 1 disappears).
But unfortunately the Marvin image plugins are not found. I have tried to copy the whole marvin folder to WEB-INF/lib - did not work. I got another HTTP Status 500 – Internal Server Error with java.lang.NullPointerException (see 'ERROR 2' below).
I have tried to set the MarvinDefinitions.setImagePluginPath to myproject/WebContent/WEB-INF/lib/plugins/ - did not work. I got an error in the console: java.nio.file.NoSuchFileException: \myproject\WebContent\WEB-INF\lib\plugins\org.marvinproject.image.transform.scale.jar.
-> Does anyone know how to implement Marvin in a dynamic web project properly?
ERROR 1
HTTP Status 500 – Internal Server Error
Type Exception Report
Message Servlet execution threw an exception
Beschreibung The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
javax.servlet.ServletException: Servlet execution threw an exception
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause
java.lang.NoClassDefFoundError: marvin/image/MarvinImage
controller.HomeController.doPost(HomeController.java:58)
javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause
java.lang.ClassNotFoundException: marvin.image.MarvinImage
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1365)
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
controller.HomeController.doPost(HomeController.java:58)
javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
ERROR 2
HTTP Status 500 – Internal Server Error
Type Exception Report
Beschreibung The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
java.lang.NullPointerException
marvin.util.MarvinJarLoader.getClass(MarvinJarLoader.java:69)
marvin.util.MarvinJarLoader.getObject(MarvinJarLoader.java:51)
marvin.util.MarvinPluginLoader.loadPlugin(MarvinPluginLoader.java:55)
marvin.util.MarvinPluginLoader.loadImagePlugin(MarvinPluginLoader.java:37)
marvin.MarvinPluginCollection.checkAndLoadImagePlugin(MarvinPluginCollection.java:1225)
marvin.MarvinPluginCollection.scale(MarvinPluginCollection.java:956)
marvin.MarvinPluginCollection.scale(MarvinPluginCollection.java:973)
controller.HomeController.doPost(HomeController.java:60)
javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
The problem with the way the Marvin zip distribution works is that it loads the JAR files at runtime as files. So you'll have to find out where the plugins were deployed. Retrieving a reference to the ServletContext and setting:
MarvinDefinitions.setImagePluginPath(servletContext.getRealPath("/WEB-INF/lib/plugins"));
might work if the WAR archive was unpacked to a directory (as Eclipse does). But it won't work in every situation.
A better solution is to download the Marvin jars (MarvinFramework and MarvinPlugins) from Maven and put them into your WEB-INF/lib folder (or add them as dependencies of the project if you are using Maven). In this distribution all the plugins will be already loaded and available through the static methods in the marvinplugins.MarvinPluginCollection class.

CodeCollaborator client fails to add files to review

I am trying to submit a code review request using CodeCollaborator client v7.2.7237 (server version is same too) but fails with the following error call stack –
com.smartbear.ccollab.datamodel.DataModelException: org.apache.xmlrpc.XmlRpcException: I/O error while communicating with HTTP server: Read timed out
at com.smartbear.ccollab.datamodel.xmlrpc.XmlRpcClientEngineImplementation$2.invoke(XmlRpcClientEngineImplementation.java:355)
at com.sun.proxy.$Proxy63.loadById(Unknown Source)
at com.smartbear.ccollab.datamodel.xmlrpc.XmlRpcClientEngineImplementation.loadById(XmlRpcClientEngineImplementation.java:441)
at com.smartbear.ccollab.datamodel.Engine$DataObjectCache.loadObjectById(Engine.java:6691)
at com.smartbear.ccollab.datamodel.Engine.loadById(Engine.java:537)
at com.smartbear.ccollab.datamodel.Engine.loadEngineObjectById(Engine.java:564)
at com.smartbear.ccollab.datamodel.Engine.versionCreate(Engine.java:5913)
at com.smartbear.ccollab.datamodel.Scm.uploadScmVersion(Scm.java:629)
at com.smartbear.ccollab.datamodel.Scm.uploadChangeset(Scm.java:448)
at com.smartbear.ccollab.datamodel.Scm.uploadChangeset(Scm.java:392)
at com.smartbear.ccollab.datamodel.Scm.uploadChangelist(Scm.java:291)
at com.smartbear.ccollab.client.commands.AbstractAddChangelistCommand.execute(AbstractAddChangelistCommand.java:139)
at com.smartbear.ccollab.client.commands.admin.review.AbstractReviewCommand.execute(AbstractReviewCommand.java:125)
at com.smartbear.ccollab.client.commands.Command.validateAndExecute(Command.java:345)
at com.smartbear.ccollab.client.commands.Command.validateAndExecute(Command.java:419)
at com.smartbear.collaborator.Collaborator.execute(Collaborator.java:160)
at com.smartbear.collaborator.jobs.AddToReviewJob.processChanges(AddToReviewJob.java:158)
at com.smartbear.collaborator.jobs.AddToReviewJob.run(AddToReviewJob.java:103)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: org.apache.xmlrpc.XmlRpcException: I/O error while communicating with HTTP server: Read timed out
at org.apache.xmlrpc.client.XmlRpcCommonsTransport.writeRequest(XmlRpcCommonsTransport.java:252)
at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:151)
at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:115)
at com.smartbear.ccollab.datamodel.xmlrpc.XmlRpcClientFactory$XmlRpcCommonsTransport2.sendRequest(XmlRpcClientFactory.java:75)
at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:158)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:147)
at com.smartbear.ccollab.datamodel.xmlrpc.XmlRpcClientEngineImplementation$2.invoke(XmlRpcClientEngineImplementation.java:256)
... 18 more
I have no problems accessing Perforce or CodeCollaborator from the machine when I get this error. I tried to submit using CodeCollaborator plugin in P4V (P4V/NTX64/2019.1/1797168) but got the same error message. I tried JRE 1.6, 1.7 but got the same error.
When I login to my CodeCollaborator account, I see that review request is being created but it is failing to add the source files to the review. My colleagues with the same CodeCollaborator, P4 versions are successfully able to submit the review requests. Checked this thread on CodeCollaborator forum who had reported similar issue but there was no solution to try. Any suggestions on how to troubleshoot ? Thanks.

How to handle error being thrown by ClusterListenerThread during the instantiation (by Spring) of my Hazelcast Client bean?

I am using Spring to configure a (lazy loaded) Hazelcast Client that connects to a 2 member cluster.
<hz:client id="hazelcast" lazy-init="true">
<hz:group name="${HzName}" password="${HzPassword}"/>
<hz:properties>
<hz:property name="hazelcast.client.connection.timeout">10000</hz:property>
<hz:property name="hazelcast.client.retry.count">600</hz:property>
<hz:property name="hazelcast.jmx">true</hz:property>
<hz:property name="hazelcast.logging.type">slf4j</hz:property>
</hz:properties>
<hz:network smart-routing="true" redo-operation="true" connection-attempt-period="5000"
connection-attempt-limit="2">
<hz:member>${HzMember1}</hz:member>
<hz:member>${HzMember2}</hz:member>
</hz:network>
</hz:client>
My issue is:
If, at the time of my application starting, BOTH of the cluster members happen to be unavailable then I am seeing ClusterListenerThread throwing a SEVERE exception:
WARNING: Unable to get alive cluster connection, try in 4945 ms later, attempt 1 of 2.
16-Apr-2015 14:57:34 com.hazelcast.client.spi.impl.ClusterListenerThread
WARNING: Unable to get alive cluster connection, try in 4987 ms later, attempt 2 of 2.
16-Apr-2015 14:57:39 com.hazelcast.client.spi.impl.ClusterListenerThread
SEVERE: Error while connecting to cluster!
java.lang.IllegalStateException: Unable to connect to any address in the config!
at com.hazelcast.client.spi.impl.ClusterListenerThread.connectToOne(ClusterListenerThread.java:273)
at com.hazelcast.client.spi.impl.ClusterListenerThread.run(ClusterListenerThread.java:79)
Caused by: com.hazelcast.spi.exception.RetryableIOException: java.util.concurrent.ExecutionException: com.hazelcast.core.HazelcastException: java.net.ConnectException: Connection refused
at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl$OwnerConnectionFuture.createNew(ClientConnectionManagerImpl.java:649)
at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl$OwnerConnectionFuture.access$300(ClientConnectionManagerImpl.java:605)
at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl.ownerConnection(ClientConnectionManagerImpl.java:268)
at com.hazelcast.client.spi.impl.ClusterListenerThread.connectToOne(ClusterListenerThread.java:245)
...which subsequently results in my Hazelcast Client bean not being instantiated and therefore everything downstream that relies upon it's existence blowing up as well.
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hazelcast': Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public static com.hazelcast.core.HazelcastInstance com.hazelcast.client.HazelcastClient.newHazelcastClient(com.hazelcast.client.config.ClientConfig)] threw exception; nested exception is java.lang.IllegalStateException: Cannot get initial partitions!
How can I detect and handle the error being thrown by ClusterListenerThread during the instantiation (by Spring) of my Hazelcast Client bean?
nb. I'm frustrated by the fact that the Client bean is not being constructed (despite there being no available members) because I know for a fact that an already constructed Client can handle having all of it's member's become unavailable and will happily start working again when one or more of those members become available again.
What you need to do is configure connectionAttemptLimit and connectionAttemptPeriod.
If you set connectionAttemptLimit to INT_MAX and pick a reasonable connectiontAttemptPeriod, the client will practically try to connect to given memberlist forever every X seconds. This is currently more like a workaround, because when you first open HazelcastClient it will block until one of the members become available. A further workaround, you can try to open the client in another dedicated thread.
About making a fully supported feature, there was a discussion going on by the hazelcast team here.
https://github.com/hazelcast/hazelcast/issues/552
I am adding a question as a reference to the issue.

Tomcat misteriously loses application-scoped objects after a few days of running

I have a very strange problem which I can't figure out by myself. I have a JSF application that I'm developing and it's deployed on a Tomcat server at client site. It works just fine. However, after a few days, it starts to behave very weird, and I'm getting a lot of exceptions such as the following in the log:
SEVERE: Error Rendering View[/index.xhtml]
com.sun.facelets.tag.TagAttributeException: /menu.xhtml #21,53 test="${!empty bean.menuItems}" /menu.xhtml #21,53 test="${!empty bean.menuItems}": Error reading 'menuItems' on type com.blabla.bean.ApplicationBean
at com.sun.facelets.tag.TagAttribute.getObject(TagAttribute.java:235)
at com.sun.facelets.tag.TagAttribute.getBoolean(TagAttribute.java:79)
at com.sun.facelets.tag.jstl.core.IfHandler.apply(IfHandler.java:49)
at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
.....
Please note that bean refers to an object of type com.blabla.bean.ApplicationBean which is an application-scoped bean. The above xhtml code is inside a c:if, that's why I use the $ notation. As mentioned, the application runs just fine for the first 2-3 days, it is only after a few days when these exceptions occur in the log, and they are only related to the only bean that's in application scope. Normally, when I get such exceptions I check if the getter for the 'menuItems' field is in the bean, but it is there and if it wasn't, the application would not work at all and not work fine for 2 days and then crash.
I also encounter exceptions related to the custom resource bundle that I have in my application:
Caused by: javax.faces.FacesException: Could not load resource bundle for name 'messages': Can't find bundle for base name com.blabla.messages.CustomResourceBundle, locale de
Again, the bundle was loaded during the first 2-3 days of the application life, but then this exception occurs all of a sudden.
Has anybody encountered a similar situation? Can anybody point me in the right direction as to where to look for the problem, since I'm completely out of ideas here.
Thank you in advance.

Resources