default configuration change for SBT - sbt

I integrated SBT in my existing application and able to run the application with sbt enabled. I deployed in my test server and it works fine but when I moved to the production, Since the context path of the application is different it breaks.
Ex: in test server my application url is
https://somedomian/SampleSbt
In production
htt....somedomain/serve/meth/SampleSbt
I'm getting error in firebug as
htt.....domain/sbt/js/sdk/sbt/ErrorTransport.js -> Forbidden
I tried changing the context path /my code path /managed-beans.xml and many ways but still it gives the same error
want to change the path from http.....somedomain/sbt/js/sdk/sbt/Errortransport.js to http.....somedomain/serv/meth/sbt/js/sdk/sbt/Errortransport.js

Can you try to add the servlet init parameter called "toolkitUrl" to the library servlet, defined in your application web.xml with value "%local_server%/somedomain/serv/meth/sbt".
So the modified library servlet declaration should look like -
<servlet>
<description>This servlet initializes the specified JavaScript library for use by the Social Business Toolkit.</description>
<display-name>Social Business Toolkit Library Servlet</display-name>
<servlet-name>LibraryServlet</servlet-name>
<servlet-class>com.ibm.sbt.jslibrary.servlet.LibraryServlet</servlet-class>
<init-param>
<param-name>toolkitUrl</param-name>
<param-value>%local_server%/somedomain/serv/meth/sbt</param-value>
</init-param>
</servlet>

After the discussion yesterday with Projjwal Saha, the issue should be resolved.
Can you update if it is, or let us know in case you still see the issue.

Related

How to filter requests ONLY from application context path?

Environment:
Jboss 5.2
Servlet 2.4
Java 7
I'm trying to execute a filter requests ONLY when the application context path is called but I didn't find any way with url-pattern, because url-pattern /* take all requests.
I would like to execute a filter when request this url http://localhost:8080/myapp but the filter is not triggered.
<filter-mapping>
<filter-name>PrincipalFilter</filter-name>
<url-pattern>/</url-pattern>
</filter-mapping>
I also tried with emtpy string but I got an error on parsing web.xml on deploying, maybe the server is too old.
Any ideas?
I also tried with emtpy string
That's the correct solution. See also Difference between / and /* in servlet mapping url pattern.
but I got an error on parsing web.xml on deploying, maybe the server is too old
That'll be it. You really need to upgrade anything which is older than the previous major version (Servlet API is currently already at 4.0 and 2.4 was released in 2003, so that's even more than a decade old!), else you won't be able to upgrade with minimal effort, and you'd be forced to end up basically rewriting the entire application.
If you really cannot upgrade, then your best bet is to listen on /* instead and simply check if request.getRequestURI() returns solely the request.getContextPath() before performing the actual logic, else just continue the filter chain without changes.

Weblogic 12.2.1.3 webjar-locator not working

I have a multi module Maven Spring project and can't get webjars-locator-weblogic to work with it.
The webjars are reachable and the mapping is declared as:
<mvc:resources mapping="/webjars/**" location="classpath:META-INF/resources/webjars/" />
However, if i try to use the version agnostic link, the response is always 404. Have already tried with both webjar-locator and webjar-locator-weblogic dependencies with no success.
Have been using this exact same configuration with other servers and never had any issues.
What am i missing?

Server equivalent to application web.xml

I'm running a .war file in 3 different Servers, but for each server I need a different description in the web.xml file, that will be accessed like:
context.getInitParameter("CompanyKey")
Is there a equivalent for a server file? It's being a pain to change this file at each deploy.
Im currently using GlassFish 4.1
After some search, I found out that GlassFish holds a file called default-web.xml in the config folder.
All variables listed here takes precedence over the variables in the application (war) web.xml.
I just transferred my variables there and it worked!
Some helpful links for those searching about web.xml, context.xml and default-web.xml (it helped me to get to my answer):
https://blogs.oracle.com/alexismp/entry/how_to_use_tomcat_context
http://docs.oracle.com/cd/E19798-01/821-1752/geurd/index.html
How can I share a variable or object between two or more Servlets?
What is the glassfish alternative to context.xml

Jetty: Detect if Webapp failed to start

I am launching an embedded Jetty instance containing a single webapp. The webapp launches on start-up. I'd like to know how to detect if the Webapp's contextInitialized throws an exception.
When the webapp throws an exception, Server.start() doesn't and server.isRunning() returns true. Is there a way for me to listen for webapp exceptions from outside the container?
Answering my own question.
Setting WebAppContext.setThrowUnavailableOnStartupException(true) causes the server to propagate any webapp exceptions to Server.start(). I'm guessing one could also invoke WebAppContext.isFailed() after server start-up to check individual contexts.
I stumbled across this trying to make this work for a non-embedded solution. In case anyone is in a similar boat, the solution for that case is to create WEB-INF/jetty-env.xml with the following contents:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="throwUnavailableOnStartupException">true</Set>
</Configure>
The server will fail startup on an exception as expected.

Weblogic 10.3 - Servlet failed with Exception

I am trying to upgrade my application from Weblogic 8.1 SP 6 to Weblogic 10.3. For this, I have installed Weblogic 10.3 and created a domain. WLS 10.3 started successfully from my domain.
I recomplied the code in Java 1.6 and deployed successfully with out any code changes.
I have deployed the application and trying to launch the application welcome (login) page.
Then I am seeing the below error :
Predefined Constants Object: com.abc.xyz272.businessclasses.PredefinedConstants#3d80183
DataSourceName='null'
sessionTimeOutLimit='36000'
00:39:31==>Servlet: getRemoteUser=null
00:39:31==>Servlet: getHeader=null
00:39:31==>count=0
<Oct 29, 2010 12:39:31 AM MDT> <Error> <HTTP> <BEA-101020> <[weblogic.servlet.internal.WebAppServletContext#2e28f75 - appName: 'mbqccrpt', name: 'xyzControllerServlet', context-path: '/xyzControllerServlet', spec-version: 'null'] Servlet failed with Exception
java.lang.NullPointerException
at com.abc.xyz272.servlets.xyzControllerServlet.processRequest(Unknown Source)
at com.abc.xyz272.servlets.xyzControllerServlet.doPost(Unknown Source)
at com.abc.xyz272.servlets.xyzControllerServlet.doGet(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
Truncated. see log file for complete stacktrace
I have one more question. The application running on Weblogic 8.1 is using apache server as well for launching the Static pages. For upgrading the application in weblogic 10.3 do we require the apache server?
I can answer the 2nd part of your question.
The main purpose usually used for an Apache server fronting the Weblogic is to offload static contents such as images,HTMLs, JS, CSS files to the Apache web server. Only dynamic requests are passed on to the Weblogic, thus reducing traffic especially if across a firewall.
This is an architectural decision which does not depend on the version of Weblogic. Rather, this depends on certain concerns such as Clustering of the App servers (using Apache as a load balancer), Volume of static data since Apache serves static data quite fast - so why push that load onto Weblogic.
And regarding your NullPointerException, it seems to be because your datasource is not defined properly (it shows as null) but you are calling some operations on it
Few Weeks Back, I was also here on this page, filtering out the internet for a suitable solution for this very same problem spec-version: 'null'] Servlet failed with Exception, until the time when everything else didn't work except the solution which I found myself after a lot of effort.
I encountered this issue while migrating one application from Oracle's 10g App Server to Weblogic 10.3.5.
As per the legendary practice, while doing the migration, we had placed one weblogic.xml file in the /WEB-INF/ folder and that was the actual problem. I just replaced that incorrect weblogic.xml file with my own version of weblogic.xml file and things worked fine.
Even though the faulty weblogic.xml file had many other elements inside the root element for the reasons best known to the person who had initially placed it, in my version of this DD file I had only the root element. And so finally the problem was resolved. So it's worth to take this into consideration.
getRemoteUser() returning null:
As getRemoteUser() method is deprecated in Weblogic 10.3, it will return null when the application is accessed by users. To avoid this problem replace getRemoteUser() with thegetHeader(“proxy-remote-user”) method, to return the remote-user as a string.
String usr= request.getHeader("proxy-remote-user");
Issue with Servlet Path Mapping:
We have the following Servlet mapping in web.xml which was working
fine in Weblogic 8.1
<servlet-mapping> in web.xml
<servlet>
<servlet-name>ServletName</servlet-name>
<servlet-class>com.abc.servlets.servletname</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> ServletName </servlet-name>
<url-pattern>/*.*</url-pattern>
</servlet-mapping>
But after migrating to 10.3, the same Servlet mapping is not working as the request is going into the infinite loop while launching the application home page. Since the web application is using Servlet as a controller where all the requests hits the controller and then are forwarded to respective JSP’s. To avoid this problem we replaced url-pattern “/*” with “/” in the servlet-mapping as below.
<servlet-mapping>
<servlet-name> ServletName </servlet-name>
<url-pattern>/ServletName </url-pattern>
</servlet-mapping>

Resources