We have a J2EE app running beautifully on tomcat-based app servers, but all groovy scripts seem to fail on weblogic (10.3.5.0) and also IBM WebSphere. It seems the script processing, not the content of the scripts are the issue. The app itsells is a spring MVC web app and the GroovyServlet is part of the web.xml descriptor:
<!-- Servlets -->
<servlet>
<servlet-name>Groovlet</servlet-name>
<servlet-class>groovy.servlet.GroovyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Groovlet</servlet-name>
<url-pattern>*.groovy</url-pattern>
</servlet-mapping>
Calling a simple executor.groovy file results in an exception. My test script is small:
response.contentType = "application/json"
out.println "test"
But fails:
GroovyServlet Error: script: '/executor.groovy': Script processing failed.null
java.lang.NullPointerException
Anyone has a solution? Are there general issues with Groovy on weblogic or websphere?
Don't know if you're still having this issue :)
I had the same problem - the NullPointerException is caused by ServletContext.getRealPath(...) returning null.
There is a setting in Weblogic admin console which controls whether getRealPath() can be used.
It can also be configured in your weblogic.xml file by inserting the following (not sure how to deal with this in Websphere).
<container-descriptor>
<show-archived-real-path-enabled>true</show-archived-real-path-enabled>
</container-descriptor>
Sounds like response or out are not properly binded in weblogic. Did you try your servlet on another container. Also publishing more about the stacktrace and the web.xml could help
Related
I am trying to deploy JSF 1.2 application on WAS 8.5 server. But it is throwing below error on deployment.
Note: In the WAS admin, Under JSF implementation use console, I have selected the "Sun Reference Implementation 1.2 " option . But still problem persist.
[12/17/14 15:12:41:222 PST] 00000095 webapp E com.ibm.ws.webcontainer.webapp.WebApp notifyServletContextDestroyed SRVE0285E: Exception caught while destroying context: {0}
java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.
A typical config looks like this;
<listener>
<listener- class> org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:196)
at org.apache.myfaces.context.servlet.FacesContextImplBase.getApplication(FacesContextImplBase.java:131)
at org.apache.myfaces.webapp.AbstractFacesInitializer._dispatchApplicationEvent(AbstractFacesInitializer.java:261)
at org.apache.myfaces.webapp.AbstractFacesInitializer.destroyFaces(AbstractFacesInitializer.java:293)
at org.apache.myfaces.webapp.StartupServletContextListener.contextDestroyed(StartupServletContextListener.java:153)
at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextDestroyed(WebApp.java:1748)
You should restart the application server (not just the app). You should also make sure jsf-api.api and jsf-impl.jar are not in WEB-INF/lib of your app.
My current web application uses log4j 1.2, and I'd like to migrate to log4j2, but I haven't been able to figure out how to handle my particular use case.
In my web app's war file, I store a log4j configuration file which has reasonable defaults. My design is to search for a configuration file external to the war file which would override the configuration bundled with the war. That way logging configuration is configured at deployment time and can be different for each server.
Using log4j 1.2, this is accomplished via a ServletContextListener with the following method and it works great:
/**
* Configures system-wide log4j logging system with log4j.xml from the
* class path. This overrides configuration from the default location in
* Tomcat: WEB-INF/classes
*/
private void configureLog4J() {
URL url = ClassLoader.getSystemResource("log4j.xml");
if (url != null) {
DOMConfigurator.configure(url);
log = org.apache.log4j.LogManager.getLogger(LDSContextListener.class);
log.info("log4j.xml loaded from " + url);
}
}
If I'm going to migrate to log4j2, how can I override the internal file with configuration from an external file? log4j2 doesn't have DOMConfigurator in its API.
I found a solution that doesn't exactly replicate what I had before, but comes close enough.
Instead of programmatically configuring log4j, I add log4j-web-2.0.jar to my classpath and add the following to my web.xml:
<context-param>
<param-name>isLog4jAutoInitializationDisabled</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>log4jConfiguration</param-name>
<param-value>file:///usr/jboss/ldsconf/log4j2.xml</param-value>
</context-param>
<listener>
<listener-class>org.apache.logging.log4j.web.Log4jServletContextListener</listener-class>
</listener>
<filter>
<filter-name>log4jServletFilter</filter-name>
<filter-class>org.apache.logging.log4j.web.Log4jServletFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>log4jServletFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
<dispatcher>ASYNC</dispatcher><!-- Servlet 3.0 w/ disabled auto-initialization only; not supported in 2.5 -->
</filter-mapping>
where the log4jConfiguration context-param specifies where my external configuration file is. This isn't the same as the ClassLoader searching the classpath for the configuration file, but it still allows me to reference an external configuration file. Also, if this file isn't present, the system falls back to the internal configuration file, which is exactly what I wanted.
Reference: http://logging.apache.org/log4j/2.x/manual/webapp.html
You can add an environment variable called LOG4J_CONFIGURATION_FILE while you start the application.
I suggest you create a feature request on the Log4j2 Jira issue tracker.
I am planning to use Cometd library in my application that runs on JBoss AS 6. Therefore I downloaded cometd 2.4.0 and tried to deploy example war (from cometd-demo/target) to my AS. I was aware that this was not possible without modifications, so I did the changes in web.xml:
Changed to servlet 3.0 in web-app tag (it is originally 2.5). Used complete tag from CometD faq answer. Also uncommented continuation filter that was already in web.xml, based on this description
Based on faq answer, added async-supported tag. However, this causes problems: if I just uncomment it, web.xml can't be parsed. I found out that this is due to order of tags in XML, so moved async-supported tag down the order, just after load-on-startup tag. However, Jboss still throws exceptions:
ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/cometd-demo-2.4.0].[cometd]]
Servlet.service() for servlet cometd threw exception:
java.lang.IllegalStateException: The servlet or filters that are being
used by this request do not support async operation
ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/cometd-demo-2.4.0].[cometd]]
Servlet.service() for servlet cometd threw exception:
java.lang.ClassNotFoundException:
org.eclipse.jetty.server.AbstractHttpConnection from
BaseClassLoader#12a54b
Complete web.xml file that I use is here.
Example runs no my Jboss despite all errors reported, but by watching firebug, I can see that it does quick pooling instead of long pool. It seems that server thinks that browser has multiple connections open, which is not the case (see JSON below):
[{"id":"137","successful":true,"advice":{"interval":2000,"reconnect":"retry","multiple-clients":true,"timeout":20000},"channel":"/meta/connect"}]
Did anyone managed to make examples work with JBoss as6 and how? What I did wrong here?
remove:
<!-- Portability Filter, needed only to run on non Jetty or non Servlet-3.0 containers -->
<filter>
<filter-name>continuation</filter-name>
<filter-class>org.eclipse.jetty.continuation.ContinuationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>continuation</filter-name>
<url-pattern>/cometd/*</url-pattern>
</filter-mapping>
from web.xml
I have the same setup and the same problem even if I remove continuation filter from web.xml.
I've found a thread on cometd-users group complaining about multiple-client issue on Tomcat 7 and the cause seems to be a Tomcat bug around Content-Type that is not set to "application/json".
However I've inspected packets and on JBossAS6 the content-type is correctly set on server responses.
UPDATE
I've give a try using Jetty 7 and the problem disappeared. The "multiple-clients" issue affects Tomcat as well as JBoss6 AS
I am trying sample application "sparklr" and "tonr" packaged with Spring Security OAuth 2.0. Unfortunately, I failed to make these applications work correctly as described in the Spring Security website.
To be specific, I tried two versions of Spring Security OAuth 2.0, one is M5 , the other is the master.
For M5, a exception is thrown out when visiting "sparklr" app with the error message "No bean named 'springSecurityFilterChain' is defined". Accessing sparklr photo through "tonr" application received a blank page as well.
For the master version, the blank page is always returned for any request to both applications.
Is there anyone who has the same problem?
I have fixed the exception problem on M5 by commenting out the "oauth2EndpointUrlFilter" configuration in Sparklr app's web.xml as below.
- <!-- filter>
<filter-name>oauth2EndpointUrlFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>contextAttribute</param-name>
<param-value>org.springframework.web.servlet.FrameworkServlet.CONTEXT.spring</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>oauth2EndpointUrlFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping
-->
I am working on an assignment that is already built to some extent. It is a Spring 3.0 project with Spring Integration and Spring MVC. I see that in web.xml, the is defined and the name is associated to the DispatcherServlet class. But in /web-inf/ I don't see the Dispatcher-servlet.xml
when I looked at the spring documentation, I read that the Dispatcher-servlet.xml is mandatory.
The app is working fine. The jsp is fetched and the flow is as expected.But without the Dispatcher-servlet.xml, how is it working? Any thoughts?
Thanks,
Jan.
Eg: here is my web.xml definition. Over here my dispatcherservlet name is springController-servlet.xml which is placed in the web-inf folder.
<servlet>
<servlet-name>springController</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springController</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
Check yours and revert back. Spring requires a dispatcher servlet file.