Liberty profile: birt and jsf integration - jsf

I'm building a web application running on Liberty profile 8.5, with JSF 2.0 feature enabled (jsf-2.0 in server.xml) and BIRT integration in the web app.
The web application includes all BIRT needed libs in WEB-INF/lib folder, but the only way to make it working (specially for chart report) is to set the classloader to 'parentlast' in the server.xml:
<webApplication contextRoot="MyApp" id="MyApp" location="MyApp.war" name="MyApp">
<classloader delegation="parentLast"/>
</webApplication>
In this way, I correctly see charts and reports.
But the 'parentlast' setting makes JSF not working, with this exception:
[ERROR ] SRVE0315E: An execption occurred:
com.ibm.ws.webcontainer.webapp.WebAppErrorReport:
javax.servlet.ServletException: SRVE0207E: Uncaught initialization
exception created by servlet at
com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:385)
at [internal classes] Caused by: javax.servlet.ServletException:
SRVE0207E: Uncaught initialization exception created by servlet ... 3
more
Caused by: 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><listenerclass>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
Without the parentlast setting, the JSF pages are correctly shown, but BIRT charts don't work.
I understand this behaviour, as the parentlast classloading makes the application seeing at first the application libs, where JSF is not included (it's loaded at server scope).
Any suggestion?
Thank you in advance!

Related

Liberty Profile 8.5 & BIRT

I'm building a web application running on Liberty profile 8.5 using BIRT. The web application includes all BIRT needed libs in WEB-INF/lib folder, but I have the following exception in birt logs just when I run chart reports (not for text reports):
WARNING: Exception org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with uri 'http://www.birt.eclipse.org/ChartModel' not found. (file:///opt/IBM/WLP-8.5.5/usr/servers/IBMWTC/test.chart, 1, 314) at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:77) at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:185) at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:261) at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518) at org.eclipse.birt.chart.model.impl.SerializerImpl.fromXml(SerializerImpl.java:465) ... ...
Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http://www.birt.eclipse.org/ChartModel' not found. (file:///opt/IBM/WLP-8.5.5/usr/servers/IBMWTC/test.chart, 1, 314) at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(XMLHandler.java:2625) ... ...
The only way to make it working is to set the classloader to 'parentlast' in the server.xml:
<webApplication ...>
<classloader delegation="parentLast"/>
</webApplication>
but this setting makes the application not working with other framework (as jsf 2.0 defined at server level through the related liberty feature).

JSF 1.2 application not getting deployed on websphere 8.5

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.

Websphere 8.5 upgrade and java2 security - strange error in spring transaction

We are migrating from WAS 6.1 to 8.5. I simply copied the EAR file which we used to deploy in 6.1 to 8.5. The application worked fine and I was happy until web-sphere admin decided to turn on Java2 security. The current was.policy file had java.security.AllPermission. But I guess this does not work with java2 security, so I changed it and granted io permission to every file which is read/written. After this, all permissions related errors are gone, but i am stuck with a strange exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'wsJtaTm' defined in ServletContext resource [/WEB-INF/applicationContext.xml]:
Instantiation of bean failed; nested exception is
org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.transaction.jta.WebSphereTransactionManagerFactoryBean]:
Constructor threw exception; nested exception is
org.springframework.transaction.TransactionSystemException: Could not find WebSphere 5.1/6.0/6.1 TransactionManager factory class; nested exception is
java.lang.ClassNotFoundException: com.ibm.ws.Transaction.TransactionManagerFactory
My spring transaction is defined like this:
<bean id="wsJtaTm"
class="org.springframework.transaction.jta.WebSphereTransactionManagerFactoryBean" />
<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager" ref="wsJtaTm" />
</bean>
I don't understand why the app would work when Java2 security is turned off, and why would it throw ClassNotFound exception when i turn the java2 security on.
According to my knowledge, com.ibm.ws.Transaction.TransactionManagerFactory should be loaded by server itself and should be made available to the app. i don't have any jar in my app having this class.
The error is originating from the constructor of bean id wsJtaTm. Am I missing something in was.policy file?
On further research, i found that this class is present inside a jar file named com.ibm.ws.runtime.jar in the plugins folder of server installation. I don't understand why this jar becomes in-visible when java2 security is turned on.
Please note I am using spring v2.5
Kindly help.
The com.ibm.ws.Transaction.TransactionManagerFactory class is not API, and WebSphere Application Server restricts access to non-API classes when Java 2 security is enabled (if applications could access internal classes, they could easily circumvent Java 2 security). Try using Spring's org.springframework.transaction.jta.WebSphereUowTransactionManager, which uses the supported UOWManager API.

CometD demo on JBoss 6

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

Run javaEE from netbeans locally

I am trying to run my javaEE site locally in Netbeans IDE. I believe I have everything set up correctly, but I am receiving the following error:
Initializing... deploy?DEFAULT=C:\Documents and
Settings\nicholasr\Desktop\Work Notes\temp code
files\ASP\build\web&name=ASP&force=true failed on GlassFish Server 3.1
Error occurred during deployment: Exception while deploying the app
[ASP] : Servlet [Resource Servlet] and Servlet [Persistent Faces
Servlet] have the same url pattern: [/xmlhttp/*]. Please see
server.log for more details. C:\Documents and
Settings\nicholasr\Desktop\Work Notes\temp code
files\ASP\nbproject\build-impl.xml:871: The module has not been
deployed. at
org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:187)
at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:106) at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor62.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597) at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348) at
org.apache.tools.ant.Target.execute(Target.java:390) at
org.apache.tools.ant.Target.performTasks(Target.java:411) at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368) at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251) at
org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:284)
at
org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:539)
at
org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:154)
BUILD FAILED (total time: 58 seconds)
I've done some searching on the net, but don't see any related links. Does anyone know why I would be getting this error and how it can be resolved? I can provide any additional information if needed. Thanks!
Error occurred during deployment: Exception while deploying the app [ASP] : Servlet [Resource Servlet] and Servlet [Persistent Faces Servlet] have the same url pattern: [/xmlhttp/]*
You seem to be using IceFaces. I don't do IceFaces, but the error message suggests that they shouldn't be mapped on the very same URL pattern. I did some minor research and based on the following documents...
Adding IceFaces 2 to your application
Converting IceFaces 1.8 to IceFaces 2
The previously declared Persistent Faces Servlet and Blocking Servlet are no longer needed in ICEfaces 2, as their functionality has changed and setup has been reduced. Remove all declarations and mappings for those two servlets:
... I can only conclude that the "Persistent Faces Servlet" is typical for IceFaces 1.8.x and the "Resource Servlet" is typical for IceFaces 2.x. You should use the one or the other, not both. I think you're targeting IceFaces 2.x, so you should get rid of the declaration and the mapping of the "Persistent Faces Servlet" in your web.xml altogether.

Resources