Liferay portlet deployment - class cast exception - java

I am new to portlets and I am trying to build one from my JSF 2.0 app. I am using liferay-portal-tomcat-6.1.0-ce-b4, JSF 2.1.3 and PortletFaces bridge 2.0.1.
When I try to install the portlet into liferay, I allways get the following exception and I really dont know why, because according to the documentation, the org.portletfaces.bridge.GenericFacesPortlet shoult implement portlet interface...
09:31:31,709 ERROR [HotDeployUtil:114]
com.liferay.portal.kernel.deploy.hot.HotD eployException: Error
registering portlets for MondisVisualizer-1.3-SNAPSHOT
com.liferay.portal.kernel.deploy.hot.HotDeployException: Error
registering portl ets for MondisVisualizer-1.3-SNAPSHOT
at com.liferay.portal.kernel.deploy.hot.BaseHotDeployListener.throwHotDe
ployException(BaseHotDeployListener.java:46)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(P
ortletHotDeployListener.java:117)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent
(HotDeployUtil.java:111)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(H
otDeployUtil.java:188)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(Ho
tDeployUtil.java:40)
at com.liferay.portal.kernel.servlet.PortletContextListener.doPortalInit
(PortletContextListener.java:101)
at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePor
talLifecycle.java:42)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLif
ecycleUtil.java:61)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLif
ecycleUtil.java:53)
at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLife
cycle(BasePortalLifecycle.java:50)
at com.liferay.portal.kernel.servlet.PortletContextListener.contextIniti
alized(PortletContextListener.java:55)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
t.java:4723)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:
5226)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:
5221)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
at java.lang.Thread.run(Thread.java:619) Caused by: java.lang.ClassCastException: org.portletfaces.bridge.GenericFacesPor
tlet cannot be cast to javax.portlet.Portlet
at com.liferay.portlet.PortletBagFactory.create(PortletBagFactory.java:1
31)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.initPortlet(Po
rtletHotDeployListener.java:603)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy
(PortletHotDeployListener.java:385)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(P
ortletHotDeployListener.java:114)
... 17 more
portlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
<portlet>
<portlet-name>Visualizer</portlet-name>
<portlet-class>org.portletfaces.bridge.GenericFacesPortlet</portlet-class>
<init-param>
<name>javax.portlet.faces.defaultViewId.view</name>
<value>/index.xhtml</value>
</init-param>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>Mondis Visualizer</title>
</portlet-info>
</portlet>
</portlet-app>
liferay-portlet.xml:
<liferay-portlet-app>
<portlet>
<portlet-name>Visualizer</portlet-name>
<instanceable>true</instanceable>
<remoteable>false</remoteable>
<ajaxable>false</ajaxable>
<!-- <header-portlet-css>/resources/styles/bookCatalog.css</header-portlet-css>
<header-portlet-javascript>/resources/scripts/jsf.js</header-portlet-javascript> -->
</portlet>
</liferay-portlet-app>
liferay-display.xml:
<?xml version="1.0"?>
<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 6.0.0//EN" "http://www.liferay.com/dtd/liferay-display_6_0_0.dtd">
<display>
<category name="category.mondis.visualizer">
<portlet id="Visualizer" />
</category>
</display>
Thanks in advance.

I have found the issue, which kills my portlet.
The porlet.jar of the bundled liferay is probably somehow hacked/modified. The workaround is to set portlet.jar dependency as "provided" in maven - and java will link your code at run-time to the (probably modified) library in tomcat. And it will work...
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>

Go to
liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\webapps
There you will find the file which you are trying to deploy,
Also:
D ...... \liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\temp
Temp will create a folder of what you have deployed in the deployed folder. I suggest to delete all the content in temp and restart your server.

Related

Problems accessing restful web service

To make some context, i asked this question last week with some problems configuring tomcat on my computer. Question.
Well, now, i have it set up. I run it from intellij and the local page for tomcat at localhost:8080/ shows up. But, in whatever other URL i try to navigate, it shows me the same message:
ERROR 404 - The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
I think i'm typing the URL wrong or something, but since i had so many problems setting it up (i still have some, because if i try to deploy a war exploded, not even the localhost:8080/ shows up), it might be some other thing i'm not seeing.
Here's my pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>restTest</groupId>
<artifactId>RestTest</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>1.18.3</version>
</dependency>
</dependencies>
</project>
And my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<servlet>
<servlet-name>API</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>restTest</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>API</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
My resource class:
package restTest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
#Path("/hello")
public class HelloWorld {
#GET
#Produces(MediaType.TEXT_PLAIN)
public String getMessage() {
return "Hello world!";
}
}
My project structure:
And, i don't know if it's needed, but in the other question, it helped:
Using CATALINA_BASE: "C:\Users\vitor\.IntelliJIdea2018.2\system\tomcat\Tomcat_9_0_8_RestTest"
Using CATALINA_HOME: "C:\Program Files\Apache Software Foundation\Tomcat 9.0"
Using CATALINA_TMPDIR: "C:\Program Files\Apache Software Foundation\Tomcat 9.0\temp"
Using JRE_HOME: "C:\Program Files\Java\jre1.8.0_191"
Using CLASSPATH: "C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin\bootstrap.jar;C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin\tomcat-juli.jar"
I decided to ask another question because that one had a different intent, and i'm having different problems now (although some of the other one remains).
I tried this URLs:
localhost:8080/hello
localhost:8080/RestTest/hello
localhost:8080/restTest/hello
localhost:8080/restTest
But all of them gave me the same error. Am i ponting to the wrong URL, or is something wrong with my tomcat configuration? Like i said, when i try to deploy a war exploded, it shows a lot of errors mentioned in the last question.
Thanks!
Edit: the errors when i try to deploy a war exploded are:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
java.lang.NoClassDefFoundError: com/google/common/base/Function
java.lang.ClassNotFoundException: com.google.common.base.Function
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
javax.management.RuntimeOperationsException: Exception invoking method manageApp
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]

Weblogic 12c JPA 2.1 spring boot

I want to deploy a spring boot application to weblogic 12c (12.1.2).
The application using latest spring boot libraries. I try to using prefer-web-inf-classes but I run out of luck.
If I try to using prefer-webinf-classes I got (my application is using validation api 1.1.0.Final):
weblogic.application.ModuleException: java.lang.NoSuchMethodError: javax.validation.spi.ConfigurationState.getParameterNameProvider()Ljavax/validation/ParameterNameProvider;
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:211)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NoSuchMethodError: javax.validation.spi.ConfigurationState.getParameterNameProvider()Ljavax/validation/ParameterNameProvider;
at org.hibernate.validator.internal.engine.ValidatorFactoryImpl.<init>(ValidatorFactoryImpl.java:142)
at org.hibernate.validator.HibernateValidator.buildValidatorFactory(HibernateValidator.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Truncated. see log file for complete stacktrace
If I try to using this configuration in web.xml:
<wls:prefer-application-packages>
<wls:package-name>antlr.*</wls:package-name>
<wls:package-name>org.apache.commons.*</wls:package-name>
<wls:package-name>org.apache.xmlbeans.*</wls:package-name>
<wls:package-name>org.springframework.*</wls:package-name>
<wls:package-name>org.hibernate.*</wls:package-name>
<wls:package-name>org.hibernate.validator.*</wls:package-name>
<wls:package-name>javax.validation.*</wls:package-name>
<wls:package-name>javax.persistence.*</wls:package-name>
<wls:package-name>javax.validation.spi.*</wls:package-name>
<wls:package-name>org.slf4j.*</wls:package-name>
<wls:package-name>org.joda.*</wls:package-name>
<wls:package-name>com.fasterxml.*</wls:package-name>
</wls:prefer-application-packages>
I got hibernate weblogic "org.eclipse.persistence.jpa.PersistenceProvider cannot be cast to javax.persistence.spi.PersistenceProvider" exception from validator.
How can I solve this? (upgrade weblogic is not an option)
Thanks
I had same issue with Spring Boot and WebLogic 12c with error
org.eclipse.persistence.jpa.PersistenceProvider cannot be cast to javax.persistence.spi.PersistenceProvider
I was getting this error only if I was using any of validation annotations.
Solved by adding this to weblogic.xml:
<prefer-application-resources>
<resource-name>META-INF/services/javax.persistence.spi.PersistenceProvider</resource-name>
</prefer-application-resources>
Sorry for my late answer. My final solution:
add weblogic.xml into your war with these content:
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
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/ejb-jar_3_0.xsd
http://xmlns.oracle.com/weblogic/weblogic-web-app
http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<wls:container-descriptor>
<wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
</wls:container-descriptor>
</wls:weblogic-web-app>
Create ear (It's important) and add weblogic-application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application xmlns="http://xmlns.oracle.com/weblogic/weblogic-application"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-application
http://xmlns.oracle.com/weblogic/weblogic-application/1.4/weblogic-application.xsd">
<prefer-application-packages>
<package-name>org.slf4j.*</package-name>
<package-name>com.fasterxml.*</package-name>
<package-name>org.joda.*</package-name>
<package-name>org.hibernate.*</package-name>
<package-name>org.jboss.*</package-name>
<package-name>javax.validation.*</package-name>
</prefer-application-packages>
</weblogic-application>
This is work for me...
Obviously, there is a classloading conflict between the API and the implementation (eclipse.jpa.PersistenceProvider).
However, the reason for such conflict is yet to explain, since the 'prefer-application-packages' is supposed to tell the container to use what comes within the application package (i.e. both the API and implementation).
A workaround that worked for me in WLS 12.2.1 is as follows :
Exclude the dependency to the JAP2 API :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
</exclusion>
</exclusions>
</dependency>
Make sure your the 'prefer-application-packages' in weblogic.xml does not include javax.persistence.* (but should include javax.validation.* and org.hibernate.*)
Using this workaround, you are relying on the JPA2 implementation of the container..
Beware, thought, that this might be confusing if versions are different since behaviour might differ between unit tests (using JPA2 implementation that comes with Spring Boot : hibernate-jpa) and tests in container (using whatever JPA implementation WebLogic provides: likely eclipse JPA Provider).
A bit too late to answer you question I guess but it sounds like you are using a new interface and old implementation. This happens sometimes when you deploy to a container and not using class-path filtering for instance. In turn you will use an older implementation provided by the container. The behavior is very random depending on what gets loaded when. Hope this helps you in right direction or anyone else having similar problem.

Api type [org.atmosphere.cpr.AtmosphereResource] is not found with the qualifiers

I'm doing a websocket app using Atmosphere and I'm trying to reproduce the chat sample in my own environment. I'm working with a TomEE 7 plus server, and the sample works fine on it.
I added the maven dependency to atmosphere-runtime and to servlet 3.0 as is it done in the sample
<!-- PubSub dependencies -->
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>2.3.3</version>
</dependency>
<!-- Spécification servlet 3.0 nécessaire pour atmosphere -->
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_3.0_spec</artifactId>
<version>1.0</version>
</dependency>
Then I put my servlet in the web.xml file
<!-- Atmosphere Servlet -->
<servlet>
<description>AtmosphereServlet</description>
<servlet-name>AtmosphereServlet</servlet-name>
<servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
<!-- limit classpath scanning to speed up starting, not mandatory -->
<init-param>
<param-name>org.atmosphere.cpr.packages</param-name>
<param-value>my.package.web.websocket</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.interceptor.HeartbeatInterceptor.clientHeartbeatFrequencyInSeconds</param-name>
<param-value>10</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>AtmosphereServlet</servlet-name>
<url-pattern>/chat/*</url-pattern>
</servlet-mapping>
But then when I try to Inject AtmosphereResource in my Chat class I got this error :
GRAVE: CDI Beans module deployment failed
org.apache.webbeans.exception.inject.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [org.atmosphere.cpr.AtmosphereResource] is not found with the qualifiers
Qualifiers: [#javax.enterprise.inject.Default()]
for injection into Field Injection Point, field name : resource, Bean Owner : [Chat, Name:null, WebBeans Type:MANAGED, API Types:[my.package.web.websocket.Chat,java.lang.Object], Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]]
at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:215)
at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:192)
at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:160)
at org.apache.openejb.cdi.CdiBuilder.build(CdiBuilder.java:41)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:846)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:652)
at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1261)
at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1100)
at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:130)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5416)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [org.atmosphere.cpr.AtmosphereResource] is not found with the qualifiers
Qualifiers: [#javax.enterprise.inject.Default()]
for injection into Field Injection Point, field name : resource, Bean Owner : [Chat, Name:null, WebBeans Type:MANAGED, API Types:[my.package.wen.websocket.Chat,java.lang.Object], Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]]
at org.apache.webbeans.util.InjectionExceptionUtil.throwUnsatisfiedResolutionException(InjectionExceptionUtil.java:60)
at org.apache.webbeans.container.InjectionResolver.checkInjectionPoint(InjectionResolver.java:195)
at org.apache.webbeans.container.BeanManagerImpl.validate(BeanManagerImpl.java:960)
at org.apache.webbeans.config.BeansDeployer.validate(BeansDeployer.java:491)
at org.apache.webbeans.config.BeansDeployer.validateInjectionPoints(BeansDeployer.java:422)
at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:202)
... 18 more
Ha and another usefull Information I don't use the ObjectMapperInjectable.java so I don't have the META-INF/Services/org.atmosphere.inject.Injectable file (it's used in the sample).
And I have a beans.xml in my projet, i'm able to inject my business service in Chat.java
I understand that it doesn't find the Default qualifier, but I don't understand why.
Do I need to specify a Qualifier for AtmospherResource interface (I don't think so) ? Are not there a default implementation ?
Is there someone who solved the same problem ?
Thanks
EDIT
After some test it seems come from the beans.xml. If I add it in the original sample project under META-INF/ I got the same error.

java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map; when deploying jersey ws to Weblogic

I'm deploying a web service application on Weblogic 12. The application uses jersey and thus depends on javax.ws.rs-api:2.0.1 library.
However when I deploy it to server I have a following error :
Caused By: java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:304)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:285)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
at javax.servlet.GenericServlet.init(GenericServlet.java:240)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:337)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:288)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
...
I think that weblogic might have it's own version of javax.ws.rs.core.Application that doesn't have this getProperties() method. I'm packaging the application in a WAR file and tried to use
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
in weblogic.xml, to explicitly tell Weblogic to use 2.0.1 version of this library.
Nothing helped so far, the issue still in place..
Thanks.
I found this to work as a solution. Add it in your weblogic.xml:
<wls:container-descriptor>
<wls:prefer-application-packages>
<!-- jersey-bundle-*.jar-->
<wls:package-name>com.sun.jersey.*</wls:package-name>
<wls:package-name>com.sun.research.ws.wadl.*</wls:package-name>
<wls:package-name>com.sun.ws.rs.ext.*</wls:package-name>
<!-- Jackson-*.jar -->
<wls:package-name>org.codehaus.jackson.*</wls:package-name>
<!-- jettison-*.jar -->
<wls:package-name>org.codehaus.jettison.*</wls:package-name>
<!-- jsr311*.jar -->
<wls:package-name>javax.ws.rs.*</wls:package-name>
<!-- asm.jar -->
<wls:package-name>org.objectweb.asm.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
Reference from Oracle Weblogic Documenation

java.lang.NullPointerException at com.sun.faces.context.flash.ELFlash.getFlash

I had created a simple JSF2.0 app and it runs fine in my computer, but when I try to run it in Heroku, I get this error:
HTTP ERROR 500
Problem accessing /login.xhtml. Reason:
Server Error
Caused by:
java.lang.NullPointerException
at com.sun.faces.context.flash.ELFlash.getFlash(ELFlash.java:93)
at com.sun.faces.context.flash.ELFlash.getELFlash(ELFlash.java:124)
at com.sun.faces.context.flash.ELFlash.doPostPhaseActions(ELFlash.java:722)
at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:108)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:547)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:481)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:940)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:409)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:874)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
at org.eclipse.jetty.server.Server.handle(Server.java:349)
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:441)
at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:904)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:565)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:217)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:46)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:545)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:43)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
at java.lang.Thread.run(Thread.java:636)
So, any solution to this problem?
Thanks in advance.
java.lang.NullPointerException
at com.sun.faces.context.flash.ELFlash.getFlash(ELFlash.java:93)
at com.sun.faces.context.flash.ELFlash.getELFlash(ELFlash.java:124)
I don't recognize the ELFlash#getELFlash() method as part of recent Mojarra implementations. Perhaps you're using a very early 2.0.0 implementation which has a bug related to this. Upgrading to the latest should fix this problem.
but the problem with annotations persists in Heroku
javax.el.PropertyNotFoundException: /login.xhtml #15,55 value="#{user.name}": Target Unreachable, identifier 'user' resolved to null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100‌​)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(Html‌​BasicInputRenderer.java:95)
JSF2 annotations will fail if your faces-config.xml is not properly declared conform JSF2 specification. Make sure that the <faces-config> root declaration look like this:
<faces-config
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-facesconfig_2_0.xsd"
version="2.0">
<!-- config here -->
</faces-config>

Categories