Filter struts2 could not be initialized - configuration

I initially wanted to migrate a JAVA EE project into maven. However, I ran into a dispatching error.
I got this stack trace in the file :
C:\Program Files using(x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\logs\My_SERVER\SystemOut.log
> [22/03/18 07:46:32:755 VET] 00000020 XmlConfigurat I
> com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
> Parsing configuration file [struts-default.xml] [22/03/18 07:46:32:766
> VET] 00000020 XmlConfigurat I
> com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
> Parsing configuration file [struts-plugin.xml] [22/03/18 07:46:32:812
> VET] 00000020 XmlConfigurat I
> com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
> Parsing configuration file [struts.xml] [22/03/18 07:46:32:814 VET]
> 00000020 DefaultConfig I
> com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
> Overriding property struts.i18n.reload - old value: false new value:
> true [22/03/18 07:46:32:814 VET] 00000020 DefaultConfig I
> com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
> Overriding property struts.configuration.xml.reload - old value: false
> new value: true [22/03/18 07:46:32:858 VET] 00000020 Dispatcher E
> com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
> Dispatcher initialization failed
> java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at
> com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:295)
> at
> com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:431)
> at
> com.opensymphony.xwork2.inject.ContainerBuilder$5.create(ContainerBuilder.java:207)
> at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51) at
> com.opensymphony.xwork2.inject.ContainerBuilder$3.create(ContainerBuilder.java:93)
> at
> com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuilder.java:487)
> at
> com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuilder.java:484)
> at
> com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:574)
> at
> com.opensymphony.xwork2.inject.ContainerBuilder.create(ContainerBuilder.java:484)
> at
> com.opensymphony.xwork2.config.impl.DefaultConfiguration.createBootstrapContainer(DefaultConfiguration.java:252)
> at
> com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:193)
> at
> com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
> at
> org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
> at
> org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:190)
> at
> com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.init(FilterInstanceWrapper.java:140)
> at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager._loadFilter(WebAppFilterManager.java:509)
> at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.loadFilter(WebAppFilterManager.java:423)
> at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.getFilterInstanceWrapper(WebAppFilterManager.java:282)
> at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.getFilterChain(WebAppFilterManager.java:340)
> at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:812)
> at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:917)
> at
> com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.invokeFilters(DefaultExtensionProcessor.java:924)
> at
> com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:852)
> at
> com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3610)
> at
> com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:274)
> at
> com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:926)
> at
> com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1557)
> at
> com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:173)
> at
> com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
> at
> com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
> at
> com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
> at
> com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1772)
> at
> com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
> 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:202) at
> com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:766)
> at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:896) at
> com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527) Caused by:
> java.lang.reflect.InvocationTargetException at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
> at java.lang.reflect.Method.invoke(Method.java:599) at
> com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:293)
> ... 40 more Caused by: java.lang.NoClassDefFoundError:
> ognl.OgnlRuntime (initialization failure) at
> java.lang.J9VMInternals.initialize(J9VMInternals.java:140) at
> com.opensymphony.xwork2.ognl.OgnlValueStackFactory.setContainer(OgnlValueStackFactory.java:85)
> ... 45 more
>
> [22/03/18 07:46:32:860 VET] 00000020 webapp E
> com.ibm.ws.webcontainer.webapp.WebApp logError SRVE0293E: [Erreur du
> servlet]-[ognl.OgnlRuntime (initialization failure)] :
> java.lang.reflect.InvocationTargetException - Class:
> com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector File:
> ContainerImpl.java Method: inject Line: 295 -
> com/opensymphony/xwork2/inject/ContainerImpl.java:295:-1 at
> org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:428) at
> org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:190)
> at
> com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.init(FilterInstanceWrapper.java:140)
> at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager._loadFilter(WebAppFilterManager.java:509)
> at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.loadFilter(WebAppFilterManager.java:423)
> at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.getFilterInstanceWrapper(WebAppFilterManager.java:282)
> at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.getFilterChain(WebAppFilterManager.java:340)
> at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:812)
> at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:917)
> at
> com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.invokeFilters(DefaultExtensionProcessor.java:924)
> at
> com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:852)
> at
> com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3610)
> at
> com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:274)
> at
> com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:926)
> at
> com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1557)
> at
> com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:173)
> at
> com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
> at
> com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
> at
> com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
> at
> com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1772)
> at
> com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
> 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:202) at
> com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:766)
> at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:896) at
> com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527) Caused by:
> java.lang.RuntimeException:
> java.lang.reflect.InvocationTargetException at
> com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:295)
> at
> com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:431)
> at
> com.opensymphony.xwork2.inject.ContainerBuilder$5.create(ContainerBuilder.java:207)
> at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51) at
> com.opensymphony.xwork2.inject.ContainerBuilder$3.create(ContainerBuilder.java:93)
> at
> com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuilder.java:487)
> at
> com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuilder.java:484)
> at
> com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:574)
> at
> com.opensymphony.xwork2.inject.ContainerBuilder.create(ContainerBuilder.java:484)
> at
> com.opensymphony.xwork2.config.impl.DefaultConfiguration.createBootstrapContainer(DefaultConfiguration.java:252)
> at
> com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:193)
> at
> com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
> at
> org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
> ... 27 more Caused by: java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
> at java.lang.reflect.Method.invoke(Method.java:599) at
> com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:293)
> ... 40 more Caused by: java.lang.NoClassDefFoundError:
> ognl.OgnlRuntime (initialization failure) at
> java.lang.J9VMInternals.initialize(J9VMInternals.java:140) at
> com.opensymphony.xwork2.ognl.OgnlValueStackFactory.setContainer(OgnlValueStackFactory.java:85)
> ... 45 more
>
> [22/03/18 07:46:32:873 VET] 00000020 srt W
> com.ibm.ws.webcontainer.srt.SRTServletResponse addHeader WARNING:
> Cannot set header. Response already committed. [22/03/18 07:46:32:874
> VET] 00000020 srt W
> com.ibm.ws.webcontainer.srt.SRTServletResponse setHeader WARNING:
> Cannot set header. Response already committed. [22/03/18 07:46:32:875
> VET] 00000020 srt W
> com.ibm.ws.webcontainer.srt.SRTServletResponse setHeader WARNING:
> Cannot set header. Response already committed. [22/03/18 07:46:32:875
> VET] 00000020 srt W
> com.ibm.ws.webcontainer.srt.SRTServletResponse setDateHeader WARNING:
> Cannot set header. Response already committed.
I added this dependency to my POM.xml (I thought that it's missing)
<dependency>
<groupId>org.apache.struts.xwork</groupId>
<artifactId>xwork-core</artifactId>
<version>2.2.1</version>
</dependency>
But I still have the error.
Can anyone tell me what I'm missing? Is it perhaps because I'm using Eclipse NEON1?
I have JDK1.7.0_71 and Websphere 7.0.0.
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_71
MAVEN_HOME=D:\Maven\apache-maven-3.3.9

Caused by: java.lang.NoClassDefFoundError:
ognl.OgnlRuntime (initialization failure) at
You have missing OGNL dependencies on class path at run time.
The xwork-core is transitive dependency for struts2-core artifact.
OGNL is also transitive dependency.
Regarding the second error:
Response has been already commuted.
Struts is trying to return error result by using servlet response internally or forward to the error page by it can't do it if response has been commuted. The response becomes commuted as soon as the buffer is flushed. You should check the size of buffer on the response object and how much bytes has written to it.

javassist dependency was messing.
I added this dependeny on the POM file :
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
and it works for me.

Related

Facing a Client instance has been closed issue when using InstancePrincipalsLoginModule

I am attempting to use OCI Instance Principal authorization with Kafka Producer API to produce message to a OCI streams endpoint.
I am referring to the documentation provided here - https://docs.public.oneportal.content.oci.oraclecloud.com/en-us/iaas/Content/Streaming/Tasks/kafkacompatibility_topic-Configuration.htm
I run into the below issue that seems to indicate that the Jersey client instance is closed even as the attempt is being made to call the metadata service endpoint.
> 2022-08-13 07:33:17.393 INFO [,d6d94a84e30ed614,d6d94a84e30ed614] 9
> --- [tp1638249646-16] ePrincipalsAuthenticationDetailsProvider : Instance principals authentication can only be used on OCI compute
> instances. Please confirm this code is running on an OCI compute
> instance. See
> https://docs.oracle.com/en-us/iaas/Content/Identity/Tasks/callingservicesfrominstances.htm
> for more info. 2022-08-13 07:33:17.394 WARN
> [,d6d94a84e30ed614,d6d94a84e30ed614] 9 --- [tp1638249646-16]
> ientAuthenticationDetailsProviderBuilder : Attempt 1 - Rest call to
> get region from metadata service failed
>
> java.lang.IllegalStateException: Client instance has been closed. at
> org.glassfish.jersey.internal.guava.Preconditions.checkState(Preconditions.java:169)
> at
> org.glassfish.jersey.client.JerseyClient.checkNotClosed(JerseyClient.java:257)
> at
> org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:272)
> at
> org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:56)
> at
> com.oracle.bmc.auth.AbstractFederationClientAuthenticationDetailsProviderBuilder.simpleRetry(AbstractFederationClientAuthenticationDetailsProviderBuilder.java:502)
> at
> com.oracle.bmc.auth.AbstractFederationClientAuthenticationDetailsProviderBuilder.simpleRetry(AbstractFederationClientAuthenticationDetailsProviderBuilder.java:490)
> at
> com.oracle.bmc.auth.AbstractFederationClientAuthenticationDetailsProviderBuilder.executeInstanceFallback(AbstractFederationClientAuthenticationDetailsProviderBuilder.java:342)
> at
> com.oracle.bmc.auth.AbstractFederationClientAuthenticationDetailsProviderBuilder.autoDetectEndpointUsingMetadataUrl(AbstractFederationClientAuthenticationDetailsProviderBuilder.java:249)
> at
> com.oracle.bmc.auth.AbstractFederationClientAuthenticationDetailsProviderBuilder.autoDetectUsingMetadataUrl(AbstractFederationClientAuthenticationDetailsProviderBuilder.java:237)
> at
> com.oracle.bmc.auth.InstancePrincipalsAuthenticationDetailsProvider$InstancePrincipalsAuthenticationDetailsProviderBuilder.build(InstancePrincipalsAuthenticationDetailsProvider.java:99)
> at
> com.oracle.bmc.auth.sasl.InstancePrincipalsLoginModule.loadAuthenticationProvider(InstancePrincipalsLoginModule.java:31)
> at
> com.oracle.bmc.auth.sasl.OciLoginModule.initialize(OciLoginModule.java:36)
> at
> com.oracle.bmc.auth.sasl.InstancePrincipalsLoginModule.initialize(InstancePrincipalsLoginModule.java:17)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498) at
> javax.security.auth.login.LoginContext.invoke(LoginContext.java:736)
> at
> javax.security.auth.login.LoginContext.access$000(LoginContext.java:195)
> at javax.security.auth.login.LoginContext$4.run(LoginContext.java:682)
> at javax.security.auth.login.LoginContext$4.run(LoginContext.java:680)
> at java.security.AccessController.doPrivileged(Native Method) at
> javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
> at javax.security.auth.login.LoginContext.login(LoginContext.java:587)
> at
> org.apache.kafka.common.security.authenticator.AbstractLogin.login(AbstractLogin.java:60)
> at
> org.apache.kafka.common.security.authenticator.LoginManager.(LoginManager.java:62)
> at
> org.apache.kafka.common.security.authenticator.LoginManager.acquireLoginManager(LoginManager.java:105)
> at
> org.apache.kafka.common.network.SaslChannelBuilder.configure(SaslChannelBuilder.java:170)
> at
> org.apache.kafka.common.network.ChannelBuilders.create(ChannelBuilders.java:192)
> at
> org.apache.kafka.common.network.ChannelBuilders.clientChannelBuilder(ChannelBuilders.java:81)
> at
> org.apache.kafka.clients.ClientUtils.createChannelBuilder(ClientUtils.java:104)
> at
> org.apache.kafka.clients.producer.KafkaProducer.newSender(KafkaProducer.java:447)
> at
> org.apache.kafka.clients.producer.KafkaProducer.(KafkaProducer.java:428)
> at
> org.apache.kafka.clients.producer.KafkaProducer.(KafkaProducer.java:290)
> at
> org.springframework.kafka.core.DefaultKafkaProducerFactory.createRawProducer(DefaultKafkaProducerFactory.java:863)
> at
> org.springframework.kafka.core.DefaultKafkaProducerFactory.createKafkaProducer(DefaultKafkaProducerFactory.java:704)
> at
> org.springframework.kafka.core.DefaultKafkaProducerFactory.doCreateProducer(DefaultKafkaProducerFactory.java:664)
> at
> org.springframework.kafka.core.DefaultKafkaProducerFactory.createProducer(DefaultKafkaProducerFactory.java:639)
> at
> org.springframework.kafka.core.DefaultKafkaProducerFactory.createProducer(DefaultKafkaProducerFactory.java:633)
> at
> org.springframework.kafka.core.KafkaTemplate.getTheProducer(KafkaTemplate.java:752)
> at
> org.springframework.kafka.core.KafkaTemplate.doSend(KafkaTemplate.java:638)
> at
> org.springframework.kafka.core.KafkaTemplate.send(KafkaTemplate.java:429)
> at
> com.oracle.cxmarketing.messaging.kafka.producer.KafkaMessageProducer.send(KafkaMessageProducer.java:84)
> at
> com.oracle.cxmarketing.messaging.kafka.producer.KafkaMessageProducer.send(KafkaMessageProducer.java:78)
> at
> com.oracle.centralpod.poc.streams.messaging.producer.AccountsProducer.produceMessage(AccountsProducer.java:19)
> at
> com.oracle.centralpod.poc.streams.service.impl.StreamsPocServiceImpl.sendMessage(StreamsPocServiceImpl.java:22)
> at
> com.oracle.centralpod.poc.streams.web.controller.v1.StreamsPocController.sendMessage(StreamsPocController.java:33)
The container that executes this code is running within an OCI compute instance.
Can I get help to understand the cause of this issue?

Go html/template & escaping

Based on the example in the html/template documentation I can't say I fully understand why it appears that less and greater than are inconsistently escaped in my experiment:
https://golang.org/pkg/html/template/#hdr-Introduction
Does this warrant a bug report? I am holding off since I am relatively new to Go.
$ go version
go version go1.16 linux/amd64
I saw similar behavior with go1.15.8.
package main
import (
htmltemplate "html/template"
"os"
texttemplate "text/template"
)
type MyVars struct {
Flavor string
}
func main() {
Vars := MyVars{
Flavor: "##### html #####",
}
htmlTmpl, _ := htmltemplate.ParseFiles("index.html")
htmlTmpl.Execute(os.Stdout, Vars)
Vars = MyVars{
Flavor: "##### text #####",
}
textTmpl, _ := texttemplate.ParseFiles("index.html")
textTmpl.Execute(os.Stdout, Vars)
}
$ cat index.html
{{ .Flavor }}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
< span >Hello< /span >
<span>Hello</span>
{{ "<" }}span{{ ">" }}Hello{{ "<" }}/span{{ ">" }}
$ ./experiment
##### html #####
<?xml version="1.0" encoding="UTF-8" standalone="no"?> # Why is only < escaped?
< span >Hello< /span > # Why is only < escaped?
<span>Hello</span> # Why is neither < nor > escaped?
<span>Hello</span>
##### text #####
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
< span >Hello< /span >
<span>Hello</span>
<span>Hello</span>
1: {{ .Flavor }}
2: <?xml version="1.0" encoding="UTF-8" standalone="no"?>
3: < span >Hello< /span >
4: <span>Hello</span>
5: {{ "<" }}span{{ ">" }}Hello{{ "<" }}/span{{ ">" }}
The < on lines 2 and 3 are text. The HTML template package escapes < in text to prevent a document reader from misinterpreting the < as the start of a tag.
The > on lines 2 and 3 is written as is to the output. There is no security benefit to escaping the >.
The < and > on line 4 are part of a tag. Tags are not escaped.
The < and > on line 5 are the value of an expression. The HTML template package fully escapes expression results.

Communication between Jsp page and Database

I'm learning to programming and I'm trying to create in a page a list of booking that a user has done.
In particular, I would like to recover all the bookings made by a user using his email
I have create a JSP page:
<body>
<%=session.getAttribute("Nome") +" "+ session.getAttribute("Cognome") + " "+ session.getAttribute("Email") %>
<br>
Prenotazioni Effettuate:
<%
try{
String email=(String)session.getAttribute("Email");
// out.print("Hello "+n);
Class.forName("com.mysql.cj.jdbc.Driver");
// out.println("driver loaded");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Hotel","root" ,"123456789");
// out.println("Connect");
Statement stmt = con.createStatement();
// out.println("conncetion successfull");
String query="";
String emailp = "";
String arrivdate = "";
query="select * from reservation where email = "+email;
ResultSet r = stmt.executeQuery(query);
while (r.next())
{
emailp = r.getString("email");
arrivdate = r.getString("arrivalDate");
%>
Email: <%= emailp %>
Arrival date: <%= arrivdate %>
<% }}
catch(Exception e)
{
}
out.close();
%>
I don't understand why nothing is printed.
Is it a query problem or a code problem that's wrong? do you know how to help me?
GRAVE: Servlet.service() for servlet [jsp] in context with path
> [/Apartment] threw exception [java.lang.IllegalStateException:
> Exception occurred when flushing data] with root cause
> java.io.IOException: Stream closed at
> org.apache.jasper.runtime.JspWriterImpl.ensureOpen(JspWriterImpl.java:187)
> at
> org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:105)
> at
> org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:180)
> at
> org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:120)
> at
> org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:75)
> at
> org.apache.jsp.Prenotazionieffettuate_jsp._jspService(Prenotazionieffettuate_jsp.java:198)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) at
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)
> at
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> at
> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
> at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
> at
> org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
> at
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:412)
> at
> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
> at
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
> at
> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1385)
> at
> org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> at
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
> at java.lang.Thread.run(Thread.java:748)
I solved using this way:
String query="SELECT * FROM reservation WHERE email= '" + session.getAttribute("Email") + "'";

IBM Liberty server shutsdown after it startsup

The Liberty server starts properly and begins to shutdown withing a second.
The server is being started in eclipse version Juno in my Windows development system. The application is a web application with ejb in it. Server configuration details below.
<server description="localWAS">
<!-- Enable features -->
<featureManager>
<feature>jsp-2.2</feature>
<feature>localConnector-1.0</feature>
<feature>jndi-1.0</feature>
<feature>wmqJmsClient-1.1</feature>
<feature>jdbc-4.0</feature>
<feature>ejbLite-3.1</feature>
<!-- <feature>jpa-2.0</feature> -->
<feature>json-1.0</feature>
<feature>managedBeans-1.0</feature>
<feature>cdi-1.0</feature>
<feature>servlet-3.0</feature>
</featureManager>
<variable name="[commonlib]" value="/commonlib"/>
<variable name="appLocation" value="[deployment ready app location]" />
<variable name="hostname" value="[host]" />
<httpEndpoint host="${hostname}" httpPort="[httpPort]"
httpsPort="[httpsPort]" id="defaultHttpEndpoint" />
<dataSource id="[oracledb]" jndiName="[oracledb-jndi]">
<jdbcDriver javax.sql.ConnectionPoolDataSource="oracle.jdbc.pool.OracleConnectionPoolDataSource">
<library>
<fileset dir="${[commonlib]}" includes="ojdbc6.jar" />
</library>
</jdbcDriver>
<properties.oracle databaseName="[databaseName]" password="[password]"
portNumber="1521" serverName="[serverName]" user="[user]" />
</dataSource>
more data sources
<variable name="wmqJmsClient.rar.location" value="/servers/IBM/lib/WMQ/ra/wmq.jmsra.rar" />
<jmsQueueConnectionFactory
connectionManagerRef="AIXQCF" jndiName="jms/aixQCF">
<properties.wmqJms channel="SYSTEM.ADMIN.SVRCONN"
hostName="jdawg.pharmacy.com" pollingInterval="5s" port="1416"
queueManager="JDAWG.QAS" rescanInterval="5s" transportType="CLIENT" />
</jmsQueueConnectionFactory>
<connectionManager id="AIXQCF" maxPoolSize="2" />
<jmsQueue id="[jmsQueueId]" jndiName="jms/[jmsQueueName]">
<properties.wmqJms baseQueueName="[baseQueueName]" />
</jmsQueue>
more queues
<jndiEntry id="[jndiEntryId]" jndiName="[jndiEntryName]"
value="[jndiEntryValue]" />
more jndi entries
<logging
traceSpecification="*=info:com.ibm.ws.http.internal.*=all:com.ibm.ws.webcontainer.*=all:com.ibm.ws.http.channel.*=all:Naming=all:NamingService=all:com.ibm.ws.app*=all" />
<applicationMonitor updateTrigger="mbean" />
<application context-root="[application-context-root]" id="[application-id]"
location="${appLocation}" name="[application-name]" type="war" /></server>
I looked at the trace log file located at [..liberty\usr\servers[profile]\logs] and extracted some logs that might be useful.
Here are some classes in logs listed to shorten the lines..
ApplicationStateCoordinator - com.ibm.ws.app.manager.ApplicationStateCoordinator
ApplicationStateMachineImpl - com.ibm.ws.app.manager.internal.statemachine.ApplicationStateMachineImpl
ApplicationConfigurator - com.ibm.ws.app.manager.internal.ApplicationConfigurator
AppManagerActivator - com.ibm.ws.app.manager.ready.AppManagerActivator
Util - com.ibm.ws.classloading.internal.Util
VirtualHostImpl - com.ibm.ws.http.internal.VirtualHostImpl
DynamicVirtualHostConfiguration - com.ibm.ws.webcontainer.osgi.DynamicVirtualHostConfiguration
logs:
[15:01:59:784] 0000001d id= ApplicationStateCoordinator > updateStartingAppStatus Entry
com.ibm.ws.app.manager_101
STARTED
[15:01:59:784] 0000001d id= ApplicationStateCoordinator < updateStartingAppStatus Exit
[15:01:59:784] 0000001d id=4150c9af internal.ApplicationConfigurator < notifyAppStarted Exit
[15:01:59:784] 0000001d id=6be25de7 ApplicationStateMachineImpl > setInterruptible Entry
[15:01:59:784] 0000001d id=6be25de7 ApplicationStateMachineImpl > executeQueuedActions Entry
[15:01:59:784] 0000001d id= ApplicationStateMachineImpl 1 ASM[0]: [appName]: executeQueuedActions: interruptible=false
[15:01:59:784] 0000001d id=6be25de7 ApplicationStateMachineImpl < executeQueuedActions Exit
false
[15:01:59:784] 0000001d id=6be25de7 ApplicationStateMachineImpl < setInterruptible Exit
[15:01:59:784] 0000001d id=6be25de7 ApplicationStateMachineImpl < enterState Exit
[15:01:59:784] 0000001d id= ApplicationStateMachineImpl 1 ASM[0]: [appName]: run: called enterState STOPPED
[15:01:59:784] 0000001d id=6be25de7 ApplicationStateMachineImpl < run Exit
[15:01:59:784] 00000012 id= ApplicationStateCoordinator < getSlowlyStartingApps Exit
null
[15:01:59:784] 00000012 id=30ba9255 ready.AppManagerActivator < start Exit
[15:01:59:784] 00000012 id=b34dbc66 LogService-242-ready 1 BundleEvent STARTED
Event:org.osgi.framework.BundleEvent[source=ready_1.0.3.cl50220140403-1858 [242]]
[15:01:59:815] 00000018 id= com.ibm.ws.kernel.feature.internal.FeatureManager I CWWKF0008I: Feature update completed in 37.251 seconds.
[15:01:59:815] 00000018 id= com.ibm.ws.kernel.feature.internal.FeatureManager A CWWKF0011I: The server defaultServer is ready to run a smarter planet.
[15:02:01:501] 0000002a id=b34dbc66 LogService-242-ready 1 BundleEvent STOPPING
Event:org.osgi.framework.BundleEvent[source=ready_1.0.3.cl50220140403-1858 [242]]
[15:02:01:501] 0000002a id=30ba9255 ready.AppManagerActivator > stop Entry
org.eclipse.osgi.framework.internal.core.BundleContextImpl#a8e8834d
[15:02:01:501] 0000002a id= ApplicationStateCoordinator > getSlowlyStoppingApps Entry
30
SECONDS
[15:02:01:501] 0000002a id=4150c9af internal.ApplicationConfigurator > getStoppingAppPids Entry
[15:02:01:501] 0000002a id=4150c9af internal.ApplicationConfigurator < getStoppingAppPids Exit
[com.ibm.ws.app.manager_101]
[15:02:01:501] 0000002a id=4150c9af internal.ApplicationConfigurator > stopRunningApps Entry
[15:02:01:501] 0000002a id=6be25de7 ApplicationStateMachineImpl > uninstall Entry
<br>
[15:02:01:501] 0000002a id= ApplicationStateMachineImpl 1 ASM[0]: [appName]: createDependency: created AppDep[7]: desc="resolves when the app [appName] finishes stopping, at which point it will be removed", future=com.ibm.ws.threading.internal.NonCancelableResultFuture#cf28eb9
[15:02:01:501] 0000002a id= ApplicationStateMachineImpl 1 ASM[0]: [appName]: created SCA[1] action=REMOVE
[15:02:01:516] 00000021 id= ApplicationStateMachineImpl 1 ASM[0]: [appName]: run: executing SCA[1] action=REMOVE
<br>.
<br>
[15:02:02:387] 00000021 id= Util > ensureNotNull Entry
Parameter 'domain' must not be null
Thread Context
[15:02:02:387] 00000021 id= Util > ensure Entry
Parameter 'domain' must not be null
true
[15:02:02:387] 00000021 id= Util < ensure Exit
[15:02:02:387] 00000021 id= Util < ensureNotNull Exit
Thread Context
[15:02:02:387] 00000021 id= Util > ensureNotNull Entry
Parameter 'id' must not be null
WebModule:[appName]-[appName]-/[appName]
[15:02:02:387] 00000021 id= Util > ensure Entry
Parameter 'id' must not be null
true
[15:02:02:387] 00000021 id= Util < ensure Exit
<br>.
<br>
[15:02:02:450] 00000021 id= VirtualHostImpl A CWWKT0017I: Web application removed (default_host): http://[host]:9080/[appName]/
[15:02:02:450] 00000021 id=a90f2905 DynamicVirtualHostConfiguration 1 Context root removed /[appName]/*
A couple of things to check -- Do you have application code that is calling System.exit? Are you starting the server without using nohup and then exiting the shell?

How to display text and image side by side in column of a table in html

I have a table in whose column I show both a image and text.Image is being displayed on upper side and text is being displayed below it.But I want to show both side by side.Moreover I want table to be fit on screen i.e I don't want to have scroll bars.
My Html code is
<% #page language = "java"
contentType = "text/html; charset=ISO-8859-1"
pageEncoding = "ISO-8859-1" %>
<% #taglib uri = "http://java.sun.com/jsp/jstl/core"
prefix = "c" %>
<% #taglib prefix = "fmt"
uri = "http://java.sun.com/jsp/jstl/fmt" %>
< !DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd" >
< html >
< head >
< meta http - equiv = "refresh"
content = "30" >
< title > Insert title here < /title>
<style>
.green {
color: green;
text-transform: capitalize;
}
.red {
color: red;
text-transform: capitalize;
}
</div >
< /style>
</head >
< body style = 'margin:0;padding:0;' >
< jsp: useBean id = "bs"
class = "beam_Status.BeamStatus_Bean" >
< /jsp:useBean>
<div id="loadData">
<CENTER><H1>BEAMLINE STATUS</H1 > < /CENTER>
<center>
<table border = "1" width="100%" height="60">
<tr>
<th><h1><b>BEAMLINES</b > < /h1></th >
< th > < h1 > < b > STATUS < /b></h1 > < /th>
</tr >
< c: forEach
var = "country"
items = "${bs.beam_CurrentStatus()}" >
< h3 > < b >
< c: choose >
< c: when test = "${country.value == 'IN OPERATION'}" >
< tr >
< td class = "green"
style = "text-transform: uppercase;" > < center > < h2 > $ {
country.key
} < /h2></center > < /td>
<td class="green" style="text-transform: uppercase; " ><img style="vertical-align:middle;" src = "red.png" height="50" width="50" / > < h2 > $ {
country.value
} < /h2></td >
< /tr>
</c: when >
< c: otherwise >
< tr >
< td class = "red"
style = "text-transform: uppercase; " > < center > < h2 > $ {
country.key
} < /h2></center > < /td>
<td class="red" style="text-transform: uppercase; " ><img style="vertical-align:middle;" src = "green.png" height="50" width="50" / > < h2 > $ {
country.value
} < /h2> </td >
< /tr>
</c: otherwise >
< /c:choose>
</b > < /h3>
</c: forEach >
< /table>
</center >
< /div>
<script>
< /html >
My output.
I want the second column text and image to be aligned side by side and table to fit the screen.
Thanks in advance.
Got it, just added
display: inline-block
<h2 style="vertical-align:middle; display: inline-block;">
I think it's simpler to break the column with image and text in 2 distinct columns: 1 for the image and 1 for the text. In css you can use: table {width:100%}
Make the following changes in the image tag:
add display:block and add float:left
In the text to show it side by side, just add float:left assuming text is inside a block element like a p tag.
For table to occupy full screen use width:100%;