WebLogic Portal & Spring Portlet MVC - spring

I have integrated spring portlet MVC 3.0 into Weblogic Portal 10.3. However, when I tried to activate multi-thread options in portlet, the maximized and minimized windows of portlets didn't run properly.
All my portlets are JavaPortlet as the configuration as below:
<?xml version="1.0" encoding="UTF-8"?>
<portal:root xmlns:netuix="http://www.bea.com/servers/netuix/xsd/controls/netuix/1.0.0" xmlns:portal="http://www.bea.com/servers/netuix/xsd/portal/support/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/servers/netuix/xsd/portal/support/1.0.0 portal-support-1_0_0.xsd">
<netuix:javaPortlet definitionLabel="offshoreTechnology" offerRemote="false"
forkable="true" forkPreRender="true" forkRender="true"
portletName="offshoreTechnology" title="Offshore Technology">
</netuix:javaPortlet>
</portal:root>
The forkable="true" forkPreRender="true" forkRender="true" will activate the multi-threading portlet.
Does anyone have such problem?

Related

Apache CXF SOAP JAXB issue on WebLogic 12c

We are using Java 8, Apache CXF as a SOAP client on top of Spring Boot to send SOAP messages to WS.
If the app is deployed as a WAR on Tomcat 8, the app works well and the SOAP client is sending the right XML messages with the right namespaces.
If the same app WAR is deployed on Weblogic 12c the SOAP message that is produced by the CXF SOAP client has missing namespaces.
We know that the WebLogic maybe uses some old JAXB jars that are responsible for creating the XML message from Java objects and they are different then the Tomcat server and this maybe the reason why we are seeing this issue.
We also know that we can specify in the weblogic.xml in the war file what jars the Weblogic needs to load from the war and what dependencies to load from directly from the Weblogic libraries, but every combination that we tried in the weblogic.xml does not work.
Any good advice will be fully appreciated
Sample XML output from Tomcat server with Apache CXF
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<event xmlns="http://www.test.com" xmlns:ns5="http://www.test2.com" xmlns:ns3="urn:test1:1423.15465:123123:namespace">
<ns5:created-date-time>2020-08-12T08:02:35Z</ns5:created-date-time>
<ns5:payload>
<Test2>
<ns3:ID>f14bb</ns3:ID>
<ns3:createdDateTime>2020-08-12T08:02:35Z</ns3:createdDateTime>
</Test2>
</ns5:payload>
</event>
</env:Body>
</env:Envelope>
Sample code from Weblogic 12c
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<event xmlns="http://www.test.com" xmlns:ns5="http://www.test2.com">
<ns5:created-date-time>2020-08-12T08:02:35Z</ns5:created-date-time>
<ns5:payload>
<Test2>
<ID>f14bb</ID>
<createdDateTime>2020-08-12T08:02:35Z</createdDateTime>
</Test2>
</ns5:payload>
</event>
</env:Body>
</env:Envelope>
The "urn:test1:1423.15465:123123:namespace" is completely ignored in the weblogic server making this XML message not valid by the consumer
weblogic.xml
we are trying to tell weblogic to load our classes from the war file instead of the JaxB classes from the web logic but without success
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>java.xml.bind.*</wls:package-name>
<wls:package-name>org.apache.cxf.*</wls:package-name>
<wls:package-name>javax.xml.ws.*</wls:package-name>
<wls:package-name>javax.wsdl.*</wls:package-name>
</wls:prefer-application-resources>
</wls:container-descriptor>
Except this issue everything else is working fine, the Apache CXF is sending correct in multiple scenarios, just in one is it not adding the namespace we need
It looks like you are describing a class loading problem here. Thus, kindly use the below tag in your weblogic.xml descriptor.
<prefer-web-inf-classes>false</prefer-web-inf-classes>
Some years ago I was struggling with class loading issues because I was missing it. Below you have an example about this extracted from this blog.
If after applying this you still are facing issues with the class loader, you should install Classloader Analysis Tool (CAT) to get the class loader, which is loading the conflicting classes. In this blog you will have some instructions about how to use CAT.
Importantly, in this document Oracle states about this
Note that in order to use prefer-application-packages or prefer-application-resources, prefer-web-inf-classes must be set to false.
This issue was solved by updating the package-info.java
#javax.xml.bind.annotation.XmlSchema(namespace = "urn:test1",
xmlns = {#XmlNs(prefix = "",
namespaceURI = "http://www.test.com")},
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
This is the part of the package-info that was not been there before
xmlns = {#XmlNs(prefix = "",
namespaceURI = "http://www.test.com")}
adding the namespace trick JavaXB to add the original namespace
Please check the mentioned page, which has a different Filtering classloading:
<wls:prefer-application-packages>
<wls:package-name>com.ctc.wstx.*</wls:package-name>
<wls:package-name>javax.wsdl.*</wls:package-name>
<wls:package-name>org.apache.cxf.*</wls:package-name>
<!-- <wls:package-name>javax.jws.*</wls:package-name> -->
</wls:prefer-application-packages>

LegacyCookieProcessor in standalone Tomcat and Spring Boot [duplicate]

My code is working on tomcat 8 version 8.0.33 but on 8.5.4 i get :
An invalid domain [.mydomain] was specified for this cookie.
I have found that Rfc6265CookieProcessor is introduced in tomcat 8 latest versions.
It says on official doc that this can be reverted to LegacyCookieProcessor in context.xml but i don't know how.
Please let me know how to do this.
Thanks
You can try in context.xml
<CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor" />
reference:
https://tomcat.apache.org/tomcat-8.0-doc/config/cookie-processor.html
Case 1: You are using Standalone Tomcat & have access to change files in tomcat server
Please follow answer by #linzkl
Case 2: You are using Standalone Tomcat but you don't have access to change files in tomcat server
Create a new file called context.xml under src/main/webapp/META-INF folder in your application & paste the content given below
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor" />
</Context>
When you deploy your application in Standalone Tomcat, the context.xml file you placed under META-INF folder will override the context.xml file given in tomcat/conf/context.xml
Note: If you are following this solution, you have to do it for every single application because META-INF/context.xml is application specific
Case 3: You are using Embedded Tomcat
Create a new bean for WebServerFactoryCustomizer
#Bean
WebServerFactoryCustomizer<TomcatServletWebServerFactory> cookieProcessorCustomizer() {
return new WebServerFactoryCustomizer<TomcatServletWebServerFactory>() {
#Override
void customize(TomcatServletWebServerFactory tomcatServletWebServerFactory) {
tomcatServletWebServerFactory.addContextCustomizers(new TomcatContextCustomizer() {
#Override
public void customize(Context context) {
context.setCookieProcessor(new LegacyCookieProcessor());
}
});
}
};
}
Enabling the LegacyCookieProcessor which is used in previous versions of Tomcat has solved the problem in my application. As linzkl mentioned this is explained in Apache's website https://tomcat.apache.org/tomcat-8.0-doc/config/cookie-processor.html.
The reason is that the new version of Tomcat does not understand the . (dot) in front of the domain name of the Cookie being used.
Also, make sure to check this post when you are using Internet Explorer. Apparently, it's very likely to break.
You can find context.xml in the following path.
tomcat8/conf/context.xml
<?xml version="1.0" encoding="UTF-8”?>
<!-- The contents of this file will be loaded for each web application —>
<Context>
<!-- Default set of monitored resources. If one of these changes, the -->
<!-- web application will be reloaded. -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!-- <Manager pathname="" /> -->
<CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor"/>
</Context>
The problem is still with Tomcat9. Same process need to follow for Tomcat 9 to set the class.
Add the class in context.xml file.
If you are using eclipse to run the application, need to set in the context.xml file in the server folder. Refer the below screenshot for more reference.
Hope this helps someone.
SameSite issue in tomcat version < 8.5.47 has resolved
In Tomcat 8.5.47 and bellow (Tomcat 8 versions), setting CookieProcessor tag to enable same site (as given bellow) in context.xml does not work due to a bug in Tomcat.
<CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor" sameSiteCookies="none" />
If you find in this situation where it is not a easy thing to upgrade tomcat immediately (which I faced recently), or if you find any other case where you just need custom processing in cookies; You can write your own CookieProcessor class to get around.
Please find a custom CookieProcessor implementation and details of it's deployment steps here.
In my case I wrote a custom CookieProcessor based on LegacyCookieProcessor source code that allows tomcat 8.5.47 to enable SameSite attribute in cookies.
As mentioned by #atul, this issue persists in Tomcat 9. It will most likely persist moving forward with all future versions of Tomcat, since this is the new standard.
Using the legacy cookie processor (by adding the line above to the context.xml file) is working well for us. However, the true 'fix' is to adjust how your cookie is formed in the first place. This will need to be done in your application, not in Tomcat.
The new cookie processor does not allow the domain to start with a . (dot). Adjusting your cookie (if possible) to start with a value other than that will fix this problem without reverting to the old, legacy cookie processor.
Also, it should be obvious, but I didn't see it mentioned above: after updating the context.xml file, you need to restart the Tomcat service for the change to take effect.
Cheers!

How to edit web.xml context param in Websphere console

I have made a web application to be deployed in the Websphere server but i came up with a problem.
I have 20 servlets that use a common parameter so i have this declared on web.xml:
<context-param>
<param-name>filePath</param-name>
<param-value>C:\logs.txt</param-value>
</context-param>
I want this parameter to be easily edited in the Websphere console but doesn't work. I know this works on Tomcat but is there anything equivalent on websphere?
Thanks
You should edit web.xml only on the server, there is know interface for it in the Console, as I remember.
You can find this file here:{WAS_ROOT}/profiles/profilename/config/cells/cellname/applications/enterpriseappname/deployments/deployedname/webmodulename
Link to the documentation:
http://www-01.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.base.doc/ae/tweb_jsfengine.html

Embedded Jetty reads two application contexts

I'm trying to deploy a war file with an embedded Jetty. You can clone a minimal working example here: https://github.com/guilty/jetty-test
When you build the project and try to run the war-project with a jetty-runner (which can be downloaded here: http://mvnrepository.com/artifact/org.eclipse.jetty/jetty-runner/9.2.10.v20150310), everything works fine.
As you can see, I have a jar-project, which has a dependency to war-project (with classes classifier). It tries to start an embedded Jetty server and deploy the war-project, but problem is, it reads the application-context.xml twice. As I understand, it finds it twice in the classpath: once in a built *.war, and once in a dependency I made with classes classifier.
The same happens if you use jetty-runner and call Runner.main(new String[] { "path-to.war" }), though as I said before, it works fine when called from command line.
So my question, I guess, is how to restrict classpath to Jetty, if that's at all possible.
As I mentioned, this is a minimal working example, not a real-world application. If I can be of any assistance -- please let me know.
Edit: I've been asked to put relevant code here, because links may rot.
Since I won't post all the code, I'm going to describe the situation. I have a *.war project, which is a standard web application powered by spring. It has a class, which throws an exception if more than one instance of it is created by spring (which should never happen, since it's scope is singleton).
Another project references the war-project with a classes classifier (i.e. gets everything that lays in src/main/java and src/main/resources) and tries to deploy the war-file produced by war-project. Here is the relevant deployment code:
Server server = new Server(8080);
WebAppContext webAppContext = new WebAppContext(args[0], "/");
server.setHandler(webAppContext);
server.start();
This code runs, but the server fails to start, because a second instance of the bean I wrote about before gets created and it throws an exception.
web.xml of the war-project:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:application-context.xml</param-value>
</context-param>
</web-app>
application-context.xml of the war-project contains only one bean, with default (singleton) scope and nothing else.
Here's the relevant pom.xml part of jar-project:
<dependency>
<groupId>com.github.guilty.jettyTest</groupId>
<artifactId>web-project</artifactId>
<version>1.0-SNAPSHOT</version>
<classifier>classes</classifier>
</dependency>

Spring MVC redirect cutting JSESSIONID in URL

I'm trying to redirect from a Spring MVC Controller in my Webapplication to an external URL given by a certain payment service. The URL Pattern is:
https://xxz.et/xyz/abc.jsp;jsessionid=<SessionID>.worker11?FRONTENDLANGUAGESELECTED=de
What the browser Address bar shows is:
https://xxz.net/xyz/abc.jsp?FRONTENDLANGUAGESELECTED=de
and the payment service returns Session Timeout. If I enter the complete URL manually, it works. I tried redirecting either by httpResponse.sendRedirect() or making the method return redirct:.
I have had the same problem. This is because you use servlets 2.4, you can change this in you file: webapp.xml for use Servlets 3.0.
Use this xml config header:
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
I hope I could have helped you. a greeting

Resources