How to use alternate version of Mojarra with Glassfish 4 (Netbeans/Maven) - jsf

I've been Using Eclipse/Ant for some time and decided to take a look at Netbeans/Maven for my JSF development. Along the way, I thought I'd try to use a version of Mojarra that is newer than the one I have installed in glassfish/modules. I can't seem to get that to work, and since I'm new to both Maven and Netbeans, I'm not sure if it's something with those, or something else.
I've made a very simple app which uses a backing bean to print out the Mojarra version from the index page:
Info.java:
#Named
#RequestScoped
public class Info
{
public String getVersion()
{
return FacesContext.class.getPackage().getImplementationVersion();
}
}
index.xhtml:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:body>
<h:outputText value="The Mojarra version is #{info.version}" />
</h:body>
</html>
When I run this, I see the page contents of
The Mojarra version is 2.2.5
as I'd expect (I put the 2.2.5 jar into glassfish/modules some time back). I then added the dependency for Mojarra 2.2.7 that I found from the Mojarra Web Site:
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.2.x</version>
</dependency>
with "x" replaced by "7". The resulting POM file looks like this (most of it is boilerplate from Netbeans):
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>com.mycompany</groupId>
<artifactId>mavenproject1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>mavenproject1</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.2.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When I run the app, there is no difference in the output, it still shows version 2.2.5. I found this article with an answer from #BalusC that mentions Glassfish must be explicitly told to override the installed version of faces to use an alternate version deployed with the app, by putting this in WEB-INF/glassfish-web.xml for early versions of GF3:
<class-loader delegate="false" />
<property name="useBundledJsf" value="true" />
Even though I'm using GF4, I thought I'd give it a try, and added a glassfish-web.xml with this:
glassfish-web.xml:
<glassfish-web-app error-url="">
<class-loader delegate="false" />
<property name="useBundledJsf" value="true" />
</glassfish-web-app>
The result is a page that has shows the message with an empty version string:
The Mojarra version is
The GF log also indicates no errors. The .war file that is created includes WEB-INF/lib/javax.faces-2.2.7.jar, so I suspect the problem has something to do with the GF configuration, rather than the Netbeans/Maven packaging.
I know I can download the 2.2.7 jar and put it in the glassfish/modules directory (which is how I began using 2.2.5). But the ultimate goal is to try alternate versions of JSF in an app-specific way (ideally, by just changing Maven coordinates for the JSF dependency), rather than change the GF install. Is there anyway to do this through configuration of the app and without altering the GF install?
Update 9/14/2015:
I built a new Netbeans project:
GlassFish 4.1 (out of the box), which has Mojarra 2.2.7, by default.
NB Maven/Web Application project, with JSF 2.2 Framework.
Modified the index.xhtml file as shown above.
Added a Info.java class, containing the contents, above (javax.enterprise.context.RequestScoped, javax.inject.Named).
Added a WEB-INF/glassfish-web.xml and added the lines shown above.
Added the dependency to the pom.xml file as shown above, but using javax.faces version 2.2.12.
Essentially, I'm getting the same result. If the useBundledJsf property setting is not in the glassfish-web.xml file, the version displays as 2.2.7 (even though the war file has 2.2.12 in it). And if the useBundledJsf property setting is there, along with the change to the class-loader to "false", the version is blank.
I also installed Mojarra 2.2.10 by changing the javax.faces file in the glassfish install to use 2.2.10. When I do that, I get the same results -- either the version is empty, or it shows 2.2.10 (2.2.12 is still configured, and in the war in both cases).

An alternative solution can be to try Payara 4.1.1.154 as it comes bundled with Mojarra 2.2.12
I think this can be a good solution for your needs.
This section details the modules that have been updated since the last release (4.1.153).
Mojarra 2.2.12
Webservices 2.3.2-b608
JAXB 2.2.12-b141219.1637
JAXB-API 2.2.13-b141020.1521
Weld 2.2.16.Final
Tyrus 1.11
JBatch 1.0.1-b09
Grizzly 2.3.23
HK2 2.4.0-b32
Jersey 2.22
Hazelcast 3.5.2

Related

Lombok: The setter method is not getting recognized

Lombok plugin is integrated with IJ IDE and I don't see any compilation errors in the service, but while starting the spring boot app getting
Error: java: cannot find symbol. (for setter method).
Is there any additional settings we need to do in IDE for it to understand and recognize the methods?
Adding the below missing plugin section in pom file fixed the issue.
<build>
<plugins>
<plugin>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.20</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>

Deploying JSF 1.2 based web application to JBoss EAP 7.0

I have a web application which is based on JSF 1.2 . The JSF jars are packed in the WAR library. We we try to deploy the war in JBoss EAP 7.0 , the war gets deployed successfully but the application does not run.
I found that JBoss EAP 7.0 does not support JSF 1.2 . My web application is not JSF 2.0 complaint. It will be great help if some body can list down steps to do so.
Thanks
Please try these steps:
Add a deployment-structure.xml to your project (WEB-INF/jboss-deployment-structure.xml to the WAR or META-INF/jboss-deployment-structure.xml to the EAR) with the exclusions:
<exclusions>
<module name="javax.faces.api" slot="main" />
<module name="com.sun.jsf-impl" slot="main" />
<module name="org.jboss.as.jsf-injection" slot="main" />
</exclusions>
Import all dependecies in pom.xml, what jsf need. Like that:
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>1.2-b19</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>1.2-b19</version>
</dependency>
<dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>1.1.11</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.0</version>
</dependency>
Actually this combination worked for me on EAP 7 version of JBOSS 7.1.5 servers.
This way I was able to load jsf1.2 jars from my WEB-INF/lib folder rather than what was supplied by JBOSS 7.1.5.
I had a EAR file which had the WAR file.
Web.xml:
<context-param>
<param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
<param-value>true</param-value>
</context-param>
In ear META-INF/jboss-deployment-structure.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<ear-subdeployments-isolated>true</ear-subdeployments-isolated>
<deployment>
<exclusions>
<module name="javax.faces.api" slot="main" />
<module name="com.sun.jsf-impl" slot="main" />
</exclusions>
</deployment>
<sub-deployment name="yourwarfilename.war">
<exclusions>
<module name="javax.faces.api" slot="main" />
<module name="com.sun.jsf-impl" slot="main" />
</exclusions>
</sub-deployment>
</jboss-deployment-structure>

How to set liquibase classpath

I created a JHipster project. I would like to run the liquibase changesets manually. By default the changesets are included from the classpath. The changelog is in src/main/resources/config/liquibase/master.xml, and the changesets are in src/main/resources/config/liquibase/changelog.
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
<include file="classpath:config/liquibase/changelog/00000000000000_initial_schema.xml" relativeToChangelogFile="false"/>
<!-- jhipster-needle-liquibase-add-changelog - JHipster will add liquibase changelogs here -->
<!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints changelogs here -->
</databaseChangeLog>
When running mvn liquibase:update, I get an error because the changesets are not in the classpath even though the file exists:
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.5.3:update (default-cli) on project playground: Error setting up or running Liquibase: liquibase.exception.SetupException: classpath:config/liquibase/changelog/00000000000000_initial_schema.xml does not exist -> [Help 1]
So I try to run from the command line by setting the classpath.
liquibase --classpath=src/main/resources --classpath=postgresql-42.1.3.jar
--url=jdbc:postgresql://localhost:5432/playground
--driver=org.postgresql.Driver
--changeLogFile=src/main/resources/config/liquibase/master.xml
--username playground --password=***** update
with the same error: Unexpected error running Liquibase: classpath:config/liquibase/changelog/00000000000000_initial_schema.xml does not exist
A workaround is to remove the reference classpath: in the include part but I would like to avoid to edit the file each time a changeset is added by jhipster when using jhipster entity or jhipster import-jdl.
The solution is to run mvn process-resources before running a liquibase command, so the files under src/main/resources will be in the target/classes folder. And then remove the classpath: part as stated in https://github.com/jhipster/generator-jhipster/pull/6121
well... I faced the same problem due I don't want that jhipster automatically update the production database.
So starting with #Sydney suggestion I decided to write a new profile in POM that changes the 'classpath:' word in process-resources phase, and for that I used an ANT plugin for make an replacement over master.xml file to <empty>. So this was a result:
<profile>
<id>only-liquibase</id>
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.version}</version>
<configuration>
<changeLogFile>target/classes/config/liquibase/master.xml</changeLogFile>
<driver></driver>
<url></url>
<defaultSchemaName></defaultSchemaName>
<username>dentalaser</username>
<password></password>
<referenceUrl>hibernate:spring:ec.com.dentalaser.domain?dialect=&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy</referenceUrl>
<verbose>true</verbose>
<logging>debug</logging>
</configuration>
<dependencies>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>${javassist.version}</version>
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate5</artifactId>
<version>${liquibase-hibernate5.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${validation-api.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo>Reemplazando el classpath el archivo a desplegar en AWS</echo>
<replace file="${project.build.directory}/classes/config/liquibase/master.xml" token="classpath:" value=""/>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
After that from command line execute something like this:
./mvnw process-resources liquibase:updateSQL -DskipTests -Dliquibase.url="jdbc:postgresql://<IP>:<PORT>/<DATABASE>" -Dliquibase.password="<supersecret>" -Ponly-liquibase
or this:
./mvnw process-resources liquibase:updateSQL -DskipTests -Dliquibase.url="offline:postgresql" -Ponly-liquibase
I really hope that this help you!!!

Omnifaces as JBoss AS7 module

I'm trying to extract the Omnifaces library from a .war archive to JBoss module, however, there are problems with org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type org.omnifaces.cdi.ViewScoped. Application deploys successfully but breaks on first page load.
I've read BalusC's report on problems with .wars packaged in .ear (http://balusc.blogspot.com/2013_10_01_archive.html) but I'm not sure if it applies to this situation as well since we have only .war.
When the Omnifaces library is included in .war's lib folder via Maven as a compile time dependency everything works flawlessly:
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>1.7</version>
</dependency>
Setting the dependency to provided scope, creating a JBoss module and appending the jboss-deployment structure to:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.omnifaces" export="true" meta-inf="import"/>
<!-- i tried multiple export and meta-inf combinations -->
</dependencies>
</deployment>
</jboss-deployment-structure>
module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.omnifaces">
<resources>
<resource-root path="omnifaces-1.7.jar"/>
</resources>
<dependencies>
<module name="javaee.api"/>
<module name="javax.api"/>
<module name="javax.faces.api" />
</dependencies>
</module>
Is it possible to use Omnifaces this way, as a JBoss module?
OmniFaces is as being a JSF utility library designed as WAR module, not as EAR or appserver module.

RestEasy / CDI on TomEE 1.5.2

I'm trying to get a ResteasyApplication running. My major problem is to implement CDI which should be not too hard.
So here is my prob. I'm using #Named on my Service class and #Inject at my RestService class
#Path("/patient")
#Produces({ MediaType.APPLICATION_XML, MediaType.TEXT_XML, MediaType.APPLICATION_JSON
})
#Consumes
#Stateless
public class PatientREST {
#Inject
PatientService patientService;...
#Named
public class PatientService {
// Resteasy demands a no-arg constructor
public PatientService() {
}
public Patient getPatient(String patientNumber) {...
My beans.xml looks like this
<?xml version="1.0" encoding="UTF-8"?>
<beans 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/beans_1_0.xsd">
</beans>
All over I tried to use it like several TomEE- HowTos describes.
When I'm trying to deploy this on my TomEE (1.5.2) I'm getting this in the stacktrace.
uses #Inject but CDI is not enabled. Maybe youd need to add a beans.xml file.
javax.enterprise.inject.UnsatisfiedResolutionException: Api type [de.klinikum.service.PatientService] is not found with the qualifiers
Qualifiers: [#javax.enterprise.inject.Default()]
for injection into Field Injection Point, field name : patientService, Bean Owner : [PatientREST, Name:null, WebBeans Type:ENTERPRISE, API Types:[java.lang.Object,de.klinikum.communication.PatientREST,java.io.Serializable], Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]]
Any Idea?
I was trying a bit more .. and now... deployment works. But I still get an HTTP500 Failure caused by an null pointer
type Exception report
message java.lang.NullPointerException
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException
org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:365)
org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:233)
org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:209)
org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:557)
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126)
org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause
java.lang.NullPointerException
de.klinikum.communication.PatientREST.getPatient(PatientREST.java:48)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)
org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:269)
org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:227)
org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:216)
org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542)
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126)
org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
note The full stack trace of the root cause is available in the Apache Tomcat (TomEE)/7.0.37 logs.
Seems like the container is not able to provide the patientService bean... but why ?
.------------------
Still get the same Failure.. Maybe I need some special dependencys ? ...
Here is 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>de.klinikumlmu.server</groupId>
<artifactId>KlinikumServer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>KlinikumServer</name>
<properties>
<sesame.version>
2.7.0
</sesame.version>
</properties>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webXml>WebContent\WEB-INF\web.xml</webXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.openejb.maven</groupId>
<artifactId>tomee-maven-plugin</artifactId>
<version>1.5.2</version>
<configuration>
<tomeeVersion>1.5.2</tomeeVersion>
<!-- <tomeeClassifier>plus</tomeeClassifier> -->
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0-4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-runtime</artifactId>
<version>${sesame.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>catalina</artifactId>
<version>6.0.26</version>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>cdi-tomee</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>2.3.6.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<version>2.3.6.Final</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.10</version>
</plugin>
</plugins>
</reporting>
</project>
I'm geeting deeper an deeper into it.
I've tried to place the beans.xml in the WEB-INF Folder and in the META-INF Folder to...
we got the answer^^..
to use CDI with Resteasy and TomEE you have to include special resteasy cdi dependency. Since we use this everything works find...
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-cdi</artifactId>
<version>${resteasy.version}</version>
<exclusions>
<exclusion>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
</exclusion>
</exclusions>
</dependency>
Thanks for our help...
Your REST end point needs to have #RequestScoped on it to enable CDI injection. Also, your injection point should be
#Inject
#Named("PatientService")
PatientService patientService;
Since you have a #Named on the service.
An aside, there is no such thing as TomEE 7. There is TomEE 1.5.x and Tomcat 7.0. I'm assuming you're using TomEE 1.5.x

Resources