Initial Contribution

Signed-off-by: Vinay Vishal <vinay.vishal@oracle.com>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/build.xml
new file mode 100644
index 0000000..9b021d2
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/build.xml
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project name="javaee-comp-test" default="usage" basedir=".">
+
+    <property name="javaee-comp-target" value="all"/>
+
+    <target name="run-test">
+        <antcall target="javaee-comp">
+        <param name="javaee-comp-target" value="run-test"/>
+        </antcall>
+    </target>
+
+    <target name="all">
+        <antcall target="javaee-comp">
+        <param name="javaee-comp-target" value="all"/>
+        </antcall>
+    </target>
+
+    <target name="clean">
+        <antcall target="javaee-comp">
+        <param name="javaee-comp-target" value="clean"/>
+        </antcall>
+    </target>
+
+    <target name="build">
+        <antcall target="javaee-comp">
+        <param name="javaee-comp-target" value="build"/>
+        </antcall>
+    </target>
+
+    <target name="setup">
+        <antcall target="javaee-comp">
+        <param name="javaee-comp-target" value="setup"/>
+        </antcall>
+    </target>
+
+    <target name="deploy">
+        <antcall target="javaee-comp">
+        <param name="javaee-comp-target" value="deploy"/>
+        </antcall>
+    </target>
+
+    <target name="undeploy">
+        <antcall target="javaee-comp">
+        <param name="javaee-comp-target" value="undeploy"/>
+        </antcall>
+    </target>
+
+    <target name="unsetup">
+        <antcall target="javaee-comp">
+        <param name="javaee-comp-target" value="unsetup"/>
+        </antcall>
+    </target>
+
+    <target name="run">
+        <antcall target="javaee-comp">
+        <param name="javaee-comp-target" value="run"/>
+        </antcall>
+    </target>
+
+    <target name="javaee-comp">
+        <record name="javaee-comp.output" action="start" />
+            <ant dir="javaee-component-resource-typesafe-injection" target="${javaee-comp-target}"/>
+            <ant dir="jpa-resource-injection" target="${javaee-comp-target}"/>
+            <ant dir="jpa-resource-injection-non-serializable" target="${javaee-comp-target}"/>
+            <ant dir="jpa-resource-injection-passivating-scope" target="${javaee-comp-target}"/>
+            <ant dir="jpa-resource-injection-with-singleton-ejb-producer" target="${javaee-comp-target}"/>
+            <ant dir="no-interface-ejb" target="${javaee-comp-target}"/>
+            <ant dir="jms-resource-producer-field" target="${javaee-comp-target}"/>
+<!-- TODO: Investigate 
+            <ant dir="jms-resource-producer-field-in-library-jar" target="${javaee-comp-target}"/>
+-->
+            <ant dir="em-resource-injection" target="${javaee-comp-target}"/>
+            <ant dir="em-injection-no-interface-ejb" target="${javaee-comp-target}"/>
+            <ant dir="em-resource-injection-with-resource-declaration-in-another-jar" target="${javaee-comp-target}"/>
+            <ant dir="slsb-injection-into-sessionscoped" target="${javaee-comp-target}"/>
+        <record name="javaee-comp.output" action="stop" />
+    </target>
+
+    <target name="usage">
+	<echo> Usage:
+		ant all (Executes all the javaee-comp tests)
+		ant clean (cleans all the javaee-comp tests)
+		ant build (builds all the javaee-comp tests)
+		ant setup (sets up all resources for javaee-comp tests)
+		ant deploy (deploys all the javaee-comp apps)
+		ant run (Executes all the javaee-comp tests)
+		ant undeploy (undeploys all the  javaee-comp apps)
+		ant unsetup (unsets all resources for javaee-comp tests)
+	</echo>
+    </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/README
new file mode 100644
index 0000000..098e4ae
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/README
@@ -0,0 +1,5 @@
+Test
+- Injection of a no-interface bean in a request-scoped model via @Inject 
+and @EJB and invocation of methods defined in the EJB class and 
+in a super-class of the EJB
+- glassfish issue 13040
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/build.properties
new file mode 100644
index 0000000..2696b45
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/build.properties
@@ -0,0 +1,26 @@
+<!--
+
+    Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+ 
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-eminjection-into-no-interface-ejb"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
+<property name="persistence.xml" value="descriptor/persistence.xml"/>
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/build.xml
new file mode 100644
index 0000000..a0e6a9d
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/build.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+    &commonSetup;
+    &commonBuild;
+    &testproperties;
+    &run;
+
+    <target name="all" depends="build,deploy,run,undeploy" />
+
+	<target name="clean" depends="init-common">
+		<antcall target="clean-common" />
+		<delete>
+			<fileset dir="." includes="*.class" />
+			<fileset dir="client/test/client" includes="*.class" />
+		</delete>
+	</target>
+
+	<target name="compile" depends="clean">
+		<antcall target="compile-common">
+			<param name="src" value="servlet" />
+		</antcall>
+	</target>
+
+	<target name="build" depends="compile">
+		<property name="hasWebclient" value="yes" />
+		<antcall target="webclient-war-common">
+			<param name="hasWebclient" value="yes" />
+			<param name="webclient.war.classes" value="**/*.class" />
+		</antcall>
+
+		<javac srcdir="client" classpath="${env.APS_HOME}/lib/reportbuilder.jar" includes="test/client/WebTest.java" />
+
+	</target>
+
+	<target name="build-publish-war" depends="build, publish-war-common" />
+
+	<target name="deploy" depends="init-common">
+		<antcall target="deploy-war-common" />
+	</target>
+
+	<target name="run" depends="init-common">
+		<java classname="test.client.WebTest">
+			<arg value="${http.host}" />
+			<arg value="${http.port}" />
+			<arg value="${contextroot}" />
+			<classpath>
+				<pathelement location="${env.APS_HOME}/lib/reportbuilder.jar" />
+				<pathelement location="client" />
+			</classpath>
+		</java>
+	</target>
+
+	<target name="undeploy" depends="init-common">
+		<antcall target="undeploy-war-common" />
+	</target>
+
+	<target name="usage">
+		<antcall target="usage-common" />
+	</target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/client/test/client/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/client/test/client/WebTest.java
new file mode 100644
index 0000000..24e3ebb
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/client/test/client/WebTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.client;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+    private static SimpleReporterAdapter stat = new SimpleReporterAdapter(
+            "appserv-tests");
+    private static final String TEST_NAME = "em-injection-of-no-interface-EJB";
+
+    private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0.";
+
+    private String host;
+    private String port;
+    private String contextRoot;
+
+    public WebTest(String[] args) {
+        host = args[0];
+        port = args[1];
+        contextRoot = args[2];
+    }
+
+    public static void main(String[] args) {
+        stat.addDescription("Unit test for Java EE resource injection");
+        WebTest webTest = new WebTest(args);
+        webTest.doTest();
+        stat.printSummary(TEST_NAME);
+    }
+
+    public void doTest() {
+        try {
+            invoke();
+        } catch (Exception ex) {
+            System.out.println(TEST_NAME + " test failed");
+            stat.addStatus(TEST_NAME, stat.FAIL);
+            ex.printStackTrace();
+        }
+    }
+
+    private void invoke() throws Exception {
+
+        String url = "http://" + host + ":" + port + contextRoot + "/myurl";
+        System.out.println("opening connection to " + url);
+        HttpURLConnection conn = (HttpURLConnection) (new URL(url))
+                .openConnection();
+
+        int code = conn.getResponseCode();
+        if (code != 200) {
+            System.out.println("Unexpected return code: " + code);
+            stat.addStatus(TEST_NAME, stat.FAIL);
+        } else {
+            InputStream is = null;
+            BufferedReader input = null;
+            String line = null;
+            try {
+                is = conn.getInputStream();
+                input = new BufferedReader(new InputStreamReader(is));
+                line = input.readLine();
+                System.out.println("line = " + line);
+            } finally {
+                try {
+                    if (is != null) {
+                        is.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+                try {
+                    if (input != null) {
+                        input.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+            }
+            if (EXPECTED_RESPONSE.equals(line)) {
+                stat.addStatus(TEST_NAME, stat.PASS);
+            } else {
+                System.out.println("Wrong response. Expected: "
+                        + EXPECTED_RESPONSE + ", received: " + line);
+                stat.addStatus(TEST_NAME, stat.FAIL);
+            }
+        }
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/descriptor/beans.xml
new file mode 100644
index 0000000..1d355f8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/descriptor/beans.xml
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<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>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/descriptor/persistence.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/descriptor/persistence.xml
new file mode 100644
index 0000000..82f2d7b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/descriptor/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+  <persistence-unit name="pu1" transaction-type="JTA">
+    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+    <jta-data-source>jdbc/__default</jta-data-source>
+    <non-jta-data-source>jdbc/__default</non-jta-data-source>
+    <class>myapp.Department</class>
+    <class>myapp.Employee</class>
+    <properties>
+       <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+       <property name="eclipselink.logging.level" value="INFO"/>
+    </properties>
+  </persistence-unit>
+</persistence>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/beans/TestBeanInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/beans/TestBeanInterface.java
new file mode 100644
index 0000000..8615fd5
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/beans/TestBeanInterface.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans;
+
+public interface TestBeanInterface {
+    public boolean m1();
+    public boolean m2();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/beans/artifacts/InjectViaAtEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/beans/artifacts/InjectViaAtEJB.java
new file mode 100644
index 0000000..594448d
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/beans/artifacts/InjectViaAtEJB.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface InjectViaAtEJB {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/beans/artifacts/InjectViaAtInject.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/beans/artifacts/InjectViaAtInject.java
new file mode 100644
index 0000000..8e11c88
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/beans/artifacts/InjectViaAtInject.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface InjectViaAtInject {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/beans/nonmock/TestBeanSuper.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/beans/nonmock/TestBeanSuper.java
new file mode 100644
index 0000000..3480165
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/beans/nonmock/TestBeanSuper.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock;
+
+import javax.inject.Inject;
+
+import test.beans.TestBeanInterface;
+import test.ejb.TestNoInterfaceEJB;
+
+abstract class TestBeanSuper implements TestBeanInterface {
+    
+    abstract TestNoInterfaceEJB getTestEJB();
+
+    @Override
+    public boolean m1() {
+        System.out.println("TestBean::m1 called");
+        return getTestEJB().m1().equals("Hello:m1");
+    }
+
+    @Override
+    public boolean m2() {
+        System.out.println("TestBean::m2 called");
+        System.out.println("Calling TestNoInterfaceEJB from TestBean");
+        return getTestEJB().m2().equals("Hello:m2");
+    }
+
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/beans/nonmock/TestEJBInjectionViaAtEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/beans/nonmock/TestEJBInjectionViaAtEJB.java
new file mode 100644
index 0000000..9948f7c
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/beans/nonmock/TestEJBInjectionViaAtEJB.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock;
+
+import javax.ejb.EJB;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Named;
+
+import test.beans.artifacts.InjectViaAtEJB;
+import test.ejb.TestNoInterfaceEJB;
+
+
+@RequestScoped
+@InjectViaAtEJB
+@Named
+public class TestEJBInjectionViaAtEJB extends TestBeanSuper{
+    @EJB TestNoInterfaceEJB tnie;
+
+    @Override
+    TestNoInterfaceEJB getTestEJB() {
+        return tnie;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/beans/nonmock/TestEJBInjectionViaInject.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/beans/nonmock/TestEJBInjectionViaInject.java
new file mode 100644
index 0000000..83f9383
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/beans/nonmock/TestEJBInjectionViaInject.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import test.beans.artifacts.InjectViaAtInject;
+import test.ejb.TestNoInterfaceEJB;
+
+
+@RequestScoped
+@InjectViaAtInject
+@Named
+public class TestEJBInjectionViaInject extends TestBeanSuper {
+    @Inject TestNoInterfaceEJB tnie;
+
+    @Override
+    TestNoInterfaceEJB getTestEJB() {
+        return tnie;
+    }
+
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/ejb/TestNoInterfaceEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/ejb/TestNoInterfaceEJB.java
new file mode 100644
index 0000000..64e874e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/ejb/TestNoInterfaceEJB.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.ejb;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.inject.Inject;
+
+@Stateless
+public class TestNoInterfaceEJB extends TestSuperClass {
+    @Inject 
+    EntityManager em;
+
+    public String m2() {
+        System.out.println("TestNoInterfaceEJB::m2");
+        if (em == null ) return "EntityManager injection failed";
+        return "Hello:m2";
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/ejb/TestSuperClass.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/ejb/TestSuperClass.java
new file mode 100644
index 0000000..65af297
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/ejb/TestSuperClass.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.ejb;
+
+public class TestSuperClass {
+    public String m1(){
+        System.out.println("***************TestSuperClass::m1");
+        return "Hello:m1";
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/entity/Department.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/entity/Department.java
new file mode 100644
index 0000000..14191ec
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/entity/Department.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.entity;
+
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "DEPARTMENT")
+public class Department implements java.io.Serializable {
+
+    // Instance variables
+    private int id;
+    private String name;
+    private Set<Employee> employees;
+
+    public Department() {
+    }
+
+    public Department(int id, String name) {
+        this.id = id;
+        this.name = name;
+    }
+
+    // ===========================================================
+    // getters and setters for the state fields
+
+    @Id
+    @Column(name = "ID")
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    @Column(name = "NAME")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    // ===========================================================
+    // getters and setters for the association fields
+    @OneToMany(cascade = CascadeType.ALL, mappedBy = "department")
+    public Set<Employee> getEmployees() {
+        return employees;
+    }
+
+    public void setEmployees(Set<Employee> employees) {
+        this.employees = employees;
+    }
+
+    public String toString() {
+        return "Department id=" + getId() + ", Department Name=" + getName();
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/entity/Employee.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/entity/Employee.java
new file mode 100644
index 0000000..a1820e8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/entity/Employee.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+@Entity
+@Table(name = "EMPLOYEE")
+public class Employee implements java.io.Serializable {
+
+    private int id;
+    private String firstName;
+    private String lastName;
+    private Department department;
+
+    public Employee() {
+    }
+
+    public Employee(int id, String firstName, String lastName) {
+        this.id = id;
+        this.firstName = firstName;
+        this.lastName = lastName;
+    }
+
+    public Employee(int id, String firstName, String lastName,
+            Department department) {
+        this.id = id;
+        this.firstName = firstName;
+        this.lastName = lastName;
+        this.department = department;
+    }
+
+    // ===========================================================
+    // getters and setters for the state fields
+    @Id
+    @Column(name = "ID")
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    @Column(name = "FIRSTNAME")
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    @Column(name = "LASTNAME")
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    // ===========================================================
+    // getters and setters for the association fields
+    // @ManyToOne
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "DEPARTMENT_ID")
+    public Department getDepartment() {
+        return department;
+    }
+
+    @Transient
+    public Department getDepartmentNoWeaving() {
+        try {
+            java.lang.reflect.Field f = Employee.class
+                    .getDeclaredField("department");
+            return (Department) f.get(this);
+        } catch (NoSuchFieldException e) {
+            throw new RuntimeException(
+                    "Please change argument to getDeclaredField", e);
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public void setDepartment(Department department) {
+        this.department = department;
+    }
+
+    public String toString() {
+        return "Employee id=" + getId() + ", firstName=" + getFirstName()
+                + ", lastName=" + getLastName() + ", department="
+                + getDepartment();
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/servlet/NoInterfaceEJBTestServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/servlet/NoInterfaceEJBTestServlet.java
new file mode 100644
index 0000000..246b541
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/servlet/NoInterfaceEJBTestServlet.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.inject.Inject;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.transaction.UserTransaction;
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.InjectViaAtEJB;
+import test.beans.artifacts.InjectViaAtInject;
+import test.util.JpaTest;
+
+@WebServlet(name = "mytest", urlPatterns = { "/myurl" })
+public class NoInterfaceEJBTestServlet extends HttpServlet {
+
+    @Inject
+    @InjectViaAtInject
+    TestBeanInterface testBeanInject;
+
+    @Inject
+    @InjectViaAtEJB
+    TestBeanInterface testBeanEJB;
+
+    @Inject
+    private EntityManager em;
+
+    private @Resource
+    UserTransaction utx;
+
+
+    protected void doGet(HttpServletRequest request,
+            HttpServletResponse response) throws ServletException,
+            IOException {
+        PrintWriter writer = response.getWriter();
+        writer.write("Hello from Servlet 3.0.");
+        String msg = "";
+        //test EJB injection via @EJB
+        if (!testBeanEJB.m2())
+            msg += "Invocation on no-interface EJB -- obtained through @EJB -- (method defined in EJB) failed";
+        if (!testBeanEJB.m1())
+            msg += "Invocation on no-interface EJB -- obtained through @EJB -- (method defined in super class) failed";
+
+        //test EJB injection via @Inject
+        if (!testBeanInject.m2())
+            msg += "Invocation on no-interface EJB -- obtained through @Inject -- (method defined in EJB)  failed";
+
+        //TODO: This fails currently
+        if (!testBeanInject.m1())
+            msg += "Invocation on no-interface EJB -- obtained through @Inject -- (method defined in super class) failed";
+
+        JpaTest jt = new JpaTest(em, utx);
+        boolean status = jt.lazyLoadingInit();
+        if (!status) msg += "Injection and use of EntityMaanger failed";
+        status = jt.lazyLoadingByFind(1);
+        if (!status) msg += "Injection and use of EntityMaanger lazy loading test failed";
+        
+        writer.write(msg + "\n");
+
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/util/JPAResourceProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/util/JPAResourceProducer.java
new file mode 100644
index 0000000..b029006
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/util/JPAResourceProducer.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.util;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+
+@Singleton
+public class JPAResourceProducer {
+    @Produces @PersistenceContext(unitName="pu1")
+    EntityManager customerDatabasePersistenceUnit;
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/util/JpaTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/util/JpaTest.java
new file mode 100644
index 0000000..3d47448
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-injection-no-interface-ejb/servlet/test/util/JpaTest.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.util;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Query;
+import javax.transaction.UserTransaction;
+
+import test.entity.Department;
+import test.entity.Employee;
+
+public class JpaTest {
+
+    private EntityManager em;
+    private UserTransaction utx;
+
+    private static Department deptRef[] = new Department[2];
+    private static Employee empRef[] = new Employee[5];
+
+    public JpaTest() {
+    }
+
+    public JpaTest(EntityManager em, UserTransaction utx) {
+        this.em = em;
+        this.utx = utx;
+    }
+
+    public boolean lazyLoadingInit() {
+        boolean status = false;
+        System.out.println("-----lazeLoadingInit()---------");
+        try {
+            deptRef[0] = new Department(1, "Engineering");
+            deptRef[1] = new Department(2, "Marketing");
+            utx.begin();
+            em.joinTransaction();
+            for (int i = 0; i < 2; i++) {
+                em.persist(deptRef[i]);
+            }
+            utx.commit();
+
+            empRef[0] = new Employee(1, "Alan", "Frechette", deptRef[0]);
+            empRef[1] = new Employee(2, "Arthur", "Wesley", deptRef[0]);
+            empRef[2] = new Employee(3, "Abe", "White", deptRef[0]);
+            empRef[3] = new Employee(4, "Paul", "Hinz", deptRef[1]);
+            empRef[4] = new Employee(5, "Carla", "Calrson", deptRef[1]);
+            utx.begin();
+            em.joinTransaction();
+            for (int i = 0; i < 5; i++) {
+                em.persist(empRef[i]);
+            }
+            utx.commit();
+            status = true;
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+    public boolean lazyLoadingByFind(int employeeID) {
+
+        boolean status = true;
+        System.out.println("------------lazyLoadingAfterFind -----------");
+        System.out.println("employeeID = " + employeeID);
+        Employee emp = em.find(Employee.class, employeeID);
+
+        System.out.println("found: emp.id=" + emp.getId());
+
+        try {
+            // 1. get Department before loading
+            Department deptBL = emp.getDepartmentNoWeaving();
+            System.out.println("1. before loading: deptBL=" + deptBL);
+            String deptNameBL = null;
+            if (deptBL != null) {
+                deptNameBL = deptBL.getName();
+                System.out.println("deptNameBL=" + deptNameBL);
+            }
+            // assert deptBL == null;
+            if (deptBL != null) {
+                status = false;
+            }
+
+            // 2. loading
+            String deptName = emp.getDepartment().getName();
+            System.out.println("2. loading, deptName = " + deptName);
+
+            // 3. get Department after loading
+            Department deptAL = emp.getDepartmentNoWeaving();
+            System.out.println("3. after loading: deptAL=" + deptAL);
+            String deptNameAL = deptAL.getName();
+            System.out.println("deptNameAL=" + deptNameAL);
+            // assert deptAL != null
+            // assert deptAL.getName == deptName;
+            if (deptAL == null || deptNameAL != deptName) {
+                status = false;
+            }
+        } catch (Exception ex) {
+            status = false;
+            ex.printStackTrace();
+        }
+
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+    public boolean lazyLoadingByQuery(String fName) {
+
+        boolean status = true;
+        System.out.println("------------lazyLoadingByQuery -----------");
+        System.out.println("fName = " + fName);
+        Query query = em.createQuery(
+                "SELECT e FROM Employee e WHERE e.firstName like :firstName")
+                .setParameter("firstName", fName);
+        ;
+        Employee emp = (Employee) query.getSingleResult();
+
+        System.out.println("queried: emp.firstName=" + emp.getFirstName());
+
+        try {
+            // 1. get Department before loading
+            Department deptBL = emp.getDepartmentNoWeaving();
+            System.out.println("1. before loading: deptBL=" + deptBL);
+            String deptNameBL = null;
+            if (deptBL != null) {
+                deptNameBL = deptBL.getName();
+                System.out.println("deptNameBL=" + deptNameBL);
+            }
+            // assert deptBL == null;
+            if (deptBL != null) {
+                status = false;
+            }
+
+            // 2. loading
+            String deptName = emp.getDepartment().getName();
+            System.out.println("2. loading, deptName = " + deptName);
+
+            // 3. get Department after loading
+            Department deptAL = emp.getDepartmentNoWeaving();
+            System.out.println("3. after loading: deptAL=" + deptAL);
+            String deptNameAL = deptAL.getName();
+            System.out.println("deptNameAL=" + deptNameAL);
+            // assert deptAL != null
+            // assert deptAL.getName == deptName;
+            if (deptAL == null || deptNameAL != deptName) {
+                status = false;
+            }
+        } catch (Exception ex) {
+            status = false;
+            ex.printStackTrace();
+        }
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/README
new file mode 100644
index 0000000..91f9387
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/README
@@ -0,0 +1,2 @@
+Test
+- EM producer method scenario with extended transaction context (issue 11805)
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/build.properties
new file mode 100644
index 0000000..b2a8756
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/build.properties
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+ 
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-em-resource-injection-extended-transactional-context"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
+<property name="persistence.xml" value="descriptor/persistence.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/build.xml
new file mode 100644
index 0000000..295d086
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/build.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+    &commonSetup;
+    &commonBuild;
+    &testproperties;
+    &run;
+
+    <target name="all" depends="build,create-resources,deploy,run,undeploy,delete-resources" />
+
+	<target name="clean" depends="init-common">
+		<antcall target="clean-common" />
+		<delete>
+			<fileset dir="." includes="*.class" />
+			<fileset dir="client/test/client" includes="*.class" />
+		</delete>
+	</target>
+
+	<target name="compile" depends="clean">
+		<antcall target="compile-common">
+			<param name="src" value="servlet" />
+		</antcall>
+	</target>
+
+	<target name="build" depends="compile">
+		<property name="hasWebclient" value="yes" />
+		<antcall target="webclient-war-common">
+			<param name="hasWebclient" value="yes" />
+			<param name="webclient.war.classes" value="**/*.class" />
+		</antcall>
+
+		<javac srcdir="client" classpath="${env.APS_HOME}/lib/reportbuilder.jar" includes="test/client/WebTest.java" />
+
+	</target>
+
+	<target name="build-publish-war" depends="build, publish-war-common" />
+
+	<target name="deploy" depends="init-common">
+		<antcall target="deploy-war-common" />
+	</target>
+
+	<target name="create-resources" depends="init-common">
+		<antcall target="create-jdbc-connpool-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+		</antcall>
+		<antcall target="create-jdbc-resource-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+			<param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+		</antcall>
+	</target>
+
+
+	<target name="run" depends="init-common">
+		<java classname="test.client.WebTest">
+			<arg value="${http.host}" />
+			<arg value="${http.port}" />
+			<arg value="${contextroot}" />
+			<classpath>
+				<pathelement location="${env.APS_HOME}/lib/reportbuilder.jar" />
+				<pathelement location="client" />
+			</classpath>
+		</java>
+	</target>
+
+	<target name="undeploy" depends="init-common">
+		<antcall target="undeploy-war-common" />
+	</target>
+
+	<target name="delete-resources" depends="init-common">
+		<antcall target="delete-jdbc-resource-common">
+			<param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+		</antcall>
+
+		<antcall target="delete-jdbc-connpool-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+		</antcall>
+	</target>
+
+	<target name="usage">
+		<antcall target="usage-common" />
+	</target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/client/test/client/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/client/test/client/WebTest.java
new file mode 100644
index 0000000..7dc1c83
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/client/test/client/WebTest.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.client;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+    private static SimpleReporterAdapter stat = new SimpleReporterAdapter(
+            "appserv-tests");
+    private static final String TEST_NAME = "em-resource-injection-extended-transaction-context";
+
+    private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0.";
+
+    private String host;
+    private String port;
+    private String contextRoot;
+
+    public WebTest(String[] args) {
+        host = args[0];
+        port = args[1];
+        contextRoot = args[2];
+    }
+
+    public static void main(String[] args) {
+        stat.addDescription("Unit test for Java EE resource injection");
+        WebTest webTest = new WebTest(args);
+        webTest.doTest();
+        stat.printSummary(TEST_NAME);
+    }
+
+    public void doTest() {
+        try {
+            invoke("llinit");
+            invoke("llquery");
+            invoke("llfind");
+            invoke("llinj");
+        } catch (Exception ex) {
+            System.out.println(TEST_NAME + " test failed");
+            stat.addStatus(TEST_NAME, stat.FAIL);
+            ex.printStackTrace();
+        }
+    }
+
+    private void invoke(String testCase) throws Exception {
+
+        String url = "http://" + host + ":" + port + contextRoot + "/myurl"
+                + "?testcase=" + testCase;
+        System.out.println("opening connection to " + url);
+        HttpURLConnection conn = (HttpURLConnection) (new URL(url))
+                .openConnection();
+
+        int code = conn.getResponseCode();
+        if (code != 200) {
+            System.out.println("Unexpected return code: " + code);
+            stat.addStatus(TEST_NAME + testCase, stat.FAIL);
+        } else {
+            InputStream is = null;
+            BufferedReader input = null;
+            String line = null;
+            try {
+                is = conn.getInputStream();
+                input = new BufferedReader(new InputStreamReader(is));
+                line = input.readLine();
+                System.out.println("line = " + line);
+            } finally {
+                try {
+                    if (is != null) {
+                        is.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+                try {
+                    if (input != null) {
+                        input.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+            }
+            if (EXPECTED_RESPONSE.equals(line)) {
+                stat.addStatus(TEST_NAME + testCase, stat.PASS);
+            } else {
+                System.out.println("Wrong response. Expected: "
+                        + EXPECTED_RESPONSE + ", received: " + line);
+                stat.addStatus(TEST_NAME + testCase, stat.FAIL);
+            }
+        }
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/descriptor/beans.xml
new file mode 100644
index 0000000..1d355f8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/descriptor/beans.xml
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<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>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/descriptor/persistence.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/descriptor/persistence.xml
new file mode 100644
index 0000000..82f2d7b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/descriptor/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+  <persistence-unit name="pu1" transaction-type="JTA">
+    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+    <jta-data-source>jdbc/__default</jta-data-source>
+    <non-jta-data-source>jdbc/__default</non-jta-data-source>
+    <class>myapp.Department</class>
+    <class>myapp.Employee</class>
+    <properties>
+       <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+       <property name="eclipselink.logging.level" value="INFO"/>
+    </properties>
+  </persistence-unit>
+</persistence>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/beans/TestBeanInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/beans/TestBeanInterface.java
new file mode 100644
index 0000000..29e137a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/beans/TestBeanInterface.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans;
+
+public interface TestBeanInterface {
+    public void m1();
+    public void m2();
+    
+    public String testDatasourceInjection();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/beans/artifacts/Preferred.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/beans/artifacts/Preferred.java
new file mode 100644
index 0000000..b7584c8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/beans/artifacts/Preferred.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Preferred {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/beans/artifacts/TestDatabase.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/beans/artifacts/TestDatabase.java
new file mode 100644
index 0000000..b69ab8e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/beans/artifacts/TestDatabase.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TestDatabase {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/beans/nonmock/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/beans/nonmock/TestBean.java
new file mode 100644
index 0000000..2363d68
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/beans/nonmock/TestBean.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+import test.beans.artifacts.TestDatabase;
+
+
+@RequestScoped
+@Preferred
+public class TestBean implements TestBeanInterface{
+    public static boolean testBeanInvoked = false;
+    
+    @Inject //@TestDatabase 
+    EntityManager emf;
+
+    @Override
+    public void m1() {
+        testBeanInvoked = true;
+        System.out.println("TestBean::m1 called");
+    }
+
+    @Override
+    public void m2() {
+        System.out.println("TestBean::m2 called");
+    }
+
+    @Override
+    public String testDatasourceInjection() {
+        return (emf==null ? "typesafe injection into testbean failed" : "");
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/entity/Department.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/entity/Department.java
new file mode 100644
index 0000000..14191ec
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/entity/Department.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.entity;
+
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "DEPARTMENT")
+public class Department implements java.io.Serializable {
+
+    // Instance variables
+    private int id;
+    private String name;
+    private Set<Employee> employees;
+
+    public Department() {
+    }
+
+    public Department(int id, String name) {
+        this.id = id;
+        this.name = name;
+    }
+
+    // ===========================================================
+    // getters and setters for the state fields
+
+    @Id
+    @Column(name = "ID")
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    @Column(name = "NAME")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    // ===========================================================
+    // getters and setters for the association fields
+    @OneToMany(cascade = CascadeType.ALL, mappedBy = "department")
+    public Set<Employee> getEmployees() {
+        return employees;
+    }
+
+    public void setEmployees(Set<Employee> employees) {
+        this.employees = employees;
+    }
+
+    public String toString() {
+        return "Department id=" + getId() + ", Department Name=" + getName();
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/entity/Employee.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/entity/Employee.java
new file mode 100644
index 0000000..a1820e8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/entity/Employee.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+@Entity
+@Table(name = "EMPLOYEE")
+public class Employee implements java.io.Serializable {
+
+    private int id;
+    private String firstName;
+    private String lastName;
+    private Department department;
+
+    public Employee() {
+    }
+
+    public Employee(int id, String firstName, String lastName) {
+        this.id = id;
+        this.firstName = firstName;
+        this.lastName = lastName;
+    }
+
+    public Employee(int id, String firstName, String lastName,
+            Department department) {
+        this.id = id;
+        this.firstName = firstName;
+        this.lastName = lastName;
+        this.department = department;
+    }
+
+    // ===========================================================
+    // getters and setters for the state fields
+    @Id
+    @Column(name = "ID")
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    @Column(name = "FIRSTNAME")
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    @Column(name = "LASTNAME")
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    // ===========================================================
+    // getters and setters for the association fields
+    // @ManyToOne
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "DEPARTMENT_ID")
+    public Department getDepartment() {
+        return department;
+    }
+
+    @Transient
+    public Department getDepartmentNoWeaving() {
+        try {
+            java.lang.reflect.Field f = Employee.class
+                    .getDeclaredField("department");
+            return (Department) f.get(this);
+        } catch (NoSuchFieldException e) {
+            throw new RuntimeException(
+                    "Please change argument to getDeclaredField", e);
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public void setDepartment(Department department) {
+        this.department = department;
+    }
+
+    public String toString() {
+        return "Employee id=" + getId() + ", firstName=" + getFirstName()
+                + ", lastName=" + getLastName() + ", department="
+                + getDepartment();
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/servlet/JPAResourceInjectionServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/servlet/JPAResourceInjectionServlet.java
new file mode 100644
index 0000000..4472160
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/servlet/JPAResourceInjectionServlet.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.transaction.UserTransaction;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+import test.beans.artifacts.TestDatabase;
+import test.util.JpaTest;
+
+@WebServlet(name = "mytest", urlPatterns = { "/myurl" })
+public class JPAResourceInjectionServlet extends HttpServlet {
+
+    @PersistenceUnit(unitName = "pu1")
+    private EntityManagerFactory emf;
+
+    @Inject
+    //@TestDatabase
+    private EntityManager emf1;
+
+    private @Resource
+    UserTransaction utx;
+    
+    @Inject
+    @Preferred
+    TestBeanInterface tbi;
+
+    protected void doGet(HttpServletRequest request,
+            HttpServletResponse response) throws ServletException,
+            IOException {
+        PrintWriter writer = response.getWriter();
+        writer.write("Hello from Servlet 3.0.");
+        String msg = "";
+        System.out.println("JPAResourceInjectionServlet::@PersistenceUnit " +
+        		"CDI EntityManagerFactory=" + emf1);
+
+        EntityManager em = emf1;
+        System.out.println("JPAResourceInjectionServlet::createEM" +
+        		"EntityManager=" + em);
+        String testcase = request.getParameter("testcase");
+        System.out.println("testcase=" + testcase);
+
+        if (testcase != null) {
+            JpaTest jt = new JpaTest(em, utx);
+            boolean status = false;
+            if ("llinit".equals(testcase)) {
+                status = jt.lazyLoadingInit();
+            } else if ("llfind".equals(testcase)) {
+                status = jt.lazyLoadingByFind(1);
+            } else if ("llquery".equals(testcase)) {
+                status = jt.lazyLoadingByQuery("Carla");
+            } else if ("llinj".equals(testcase)){
+                status = ((tbi != null) && 
+                        (tbi.testDatasourceInjection().trim().length()==0));
+            }
+            if (status) {
+                msg += "";// pass
+            } else {
+                msg += (testcase + ":fail");
+            }
+        }
+
+        writer.write(msg + "\n");
+
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/util/JPAResourceProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/util/JPAResourceProducer.java
new file mode 100644
index 0000000..1d6fd04
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/util/JPAResourceProducer.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.util;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+
+@Singleton
+public class JPAResourceProducer {
+    @Produces @PersistenceContext(unitName="pu1", type=PersistenceContextType.EXTENDED)
+    //@TestDatabase 
+    EntityManager customerDatabasePersistenceUnit;
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/util/JpaTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/util/JpaTest.java
new file mode 100644
index 0000000..3d47448
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-extended-transaction-context/servlet/test/util/JpaTest.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.util;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Query;
+import javax.transaction.UserTransaction;
+
+import test.entity.Department;
+import test.entity.Employee;
+
+public class JpaTest {
+
+    private EntityManager em;
+    private UserTransaction utx;
+
+    private static Department deptRef[] = new Department[2];
+    private static Employee empRef[] = new Employee[5];
+
+    public JpaTest() {
+    }
+
+    public JpaTest(EntityManager em, UserTransaction utx) {
+        this.em = em;
+        this.utx = utx;
+    }
+
+    public boolean lazyLoadingInit() {
+        boolean status = false;
+        System.out.println("-----lazeLoadingInit()---------");
+        try {
+            deptRef[0] = new Department(1, "Engineering");
+            deptRef[1] = new Department(2, "Marketing");
+            utx.begin();
+            em.joinTransaction();
+            for (int i = 0; i < 2; i++) {
+                em.persist(deptRef[i]);
+            }
+            utx.commit();
+
+            empRef[0] = new Employee(1, "Alan", "Frechette", deptRef[0]);
+            empRef[1] = new Employee(2, "Arthur", "Wesley", deptRef[0]);
+            empRef[2] = new Employee(3, "Abe", "White", deptRef[0]);
+            empRef[3] = new Employee(4, "Paul", "Hinz", deptRef[1]);
+            empRef[4] = new Employee(5, "Carla", "Calrson", deptRef[1]);
+            utx.begin();
+            em.joinTransaction();
+            for (int i = 0; i < 5; i++) {
+                em.persist(empRef[i]);
+            }
+            utx.commit();
+            status = true;
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+    public boolean lazyLoadingByFind(int employeeID) {
+
+        boolean status = true;
+        System.out.println("------------lazyLoadingAfterFind -----------");
+        System.out.println("employeeID = " + employeeID);
+        Employee emp = em.find(Employee.class, employeeID);
+
+        System.out.println("found: emp.id=" + emp.getId());
+
+        try {
+            // 1. get Department before loading
+            Department deptBL = emp.getDepartmentNoWeaving();
+            System.out.println("1. before loading: deptBL=" + deptBL);
+            String deptNameBL = null;
+            if (deptBL != null) {
+                deptNameBL = deptBL.getName();
+                System.out.println("deptNameBL=" + deptNameBL);
+            }
+            // assert deptBL == null;
+            if (deptBL != null) {
+                status = false;
+            }
+
+            // 2. loading
+            String deptName = emp.getDepartment().getName();
+            System.out.println("2. loading, deptName = " + deptName);
+
+            // 3. get Department after loading
+            Department deptAL = emp.getDepartmentNoWeaving();
+            System.out.println("3. after loading: deptAL=" + deptAL);
+            String deptNameAL = deptAL.getName();
+            System.out.println("deptNameAL=" + deptNameAL);
+            // assert deptAL != null
+            // assert deptAL.getName == deptName;
+            if (deptAL == null || deptNameAL != deptName) {
+                status = false;
+            }
+        } catch (Exception ex) {
+            status = false;
+            ex.printStackTrace();
+        }
+
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+    public boolean lazyLoadingByQuery(String fName) {
+
+        boolean status = true;
+        System.out.println("------------lazyLoadingByQuery -----------");
+        System.out.println("fName = " + fName);
+        Query query = em.createQuery(
+                "SELECT e FROM Employee e WHERE e.firstName like :firstName")
+                .setParameter("firstName", fName);
+        ;
+        Employee emp = (Employee) query.getSingleResult();
+
+        System.out.println("queried: emp.firstName=" + emp.getFirstName());
+
+        try {
+            // 1. get Department before loading
+            Department deptBL = emp.getDepartmentNoWeaving();
+            System.out.println("1. before loading: deptBL=" + deptBL);
+            String deptNameBL = null;
+            if (deptBL != null) {
+                deptNameBL = deptBL.getName();
+                System.out.println("deptNameBL=" + deptNameBL);
+            }
+            // assert deptBL == null;
+            if (deptBL != null) {
+                status = false;
+            }
+
+            // 2. loading
+            String deptName = emp.getDepartment().getName();
+            System.out.println("2. loading, deptName = " + deptName);
+
+            // 3. get Department after loading
+            Department deptAL = emp.getDepartmentNoWeaving();
+            System.out.println("3. after loading: deptAL=" + deptAL);
+            String deptNameAL = deptAL.getName();
+            System.out.println("deptNameAL=" + deptNameAL);
+            // assert deptAL != null
+            // assert deptAL.getName == deptName;
+            if (deptAL == null || deptNameAL != deptName) {
+                status = false;
+            }
+        } catch (Exception ex) {
+            status = false;
+            ex.printStackTrace();
+        }
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/README
new file mode 100644
index 0000000..dc88f85
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/README
@@ -0,0 +1,2 @@
+A test to check if resources produced by a class in a library jar is available in servlets and EJBs.
+[issues 11653 and 11640]
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/build.properties
new file mode 100644
index 0000000..1bc0c2e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/build.properties
@@ -0,0 +1,29 @@
+<!--
+
+    Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+ 
+
+<property name="module" value="cdi-full-ear"/>
+<property name="appname" value="${module}"/>         
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="se.client" value="com.acme.Client"/>
+<property name="app.type" value="application"/>
+<property name="sun-application.xml" value="descriptor/sun-application.xml"/>
+<property name="application.xml" value="descriptor/application.xml"/>
+<property name="persistence.xml" value="descriptor/persistence.xml"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
+<property name="contextroot" value="${module}"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/build.xml
new file mode 100644
index 0000000..8539621
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/build.xml
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="cdi-full-ear-App" default="usage" basedir=".">
+
+    &commonSetup;
+    &commonBuild;
+    &testproperties;
+
+    <target name="all" depends="clean,build,deploy,run,undeploy"/>
+
+    <target name="clean" depends="init-common">
+      <antcall  target="clean-common"/>
+    </target>
+ 
+    <target name="compile" depends="clean">
+         <antcall target="compile-common">
+            <param name="src" value="lib"/>
+        </antcall>
+
+       
+        <antcall target="compile-common">
+            <param name="src" value="ejb"/>
+        </antcall>
+
+        <antcall target="compile-common">
+            <param name="src" value="war"/>
+        </antcall>
+
+	    <javac classpath="${env.S1AS_HOME}/lib/javaee.jar:${env.S1AS_HOME}/lib/gf-client.jar:${build.classes.dir}:${env.APS_HOME}/lib/reporter.jar" srcdir="client" destdir="${build.classes.dir}" debug="on" failonerror="true">
+          <compilerarg line="-endorseddirs ${env.S1AS_HOME}/modules/endorsed"/>
+        </javac>
+    </target>
+
+    <target name="build" depends="compile">
+        <mkdir dir="${assemble.dir}"/>
+
+        <antcall target="ejb-jar-common">
+          <param name="ejbjar.classes" value="com/acme/ejb/**/*.class"/>
+        </antcall>
+
+        <!-- build library jar -->
+        <mkdir dir="${build.classes.dir}/META-INF"/>
+        <copy file="${persistence.xml}"
+              tofile="${build.classes.dir}/META-INF/persistence.xml"
+              failonerror="false"/>
+        <copy file="${beans.xml}"
+              tofile="${build.classes.dir}/META-INF/beans.xml"
+              failonerror="false"/>
+
+        <mkdir dir="${build.classes.dir}/lib-dir"/>
+
+        <jar jarfile="${build.classes.dir}/lib-dir/lib.jar" basedir="${build.classes.dir}" includes="com/acme/util/*.class">
+          <metainf dir="${build.classes.dir}/META-INF">
+            <include name="persistence.xml"/>
+            <include name="beans.xml"/>
+          </metainf>
+        </jar>
+
+        <!-- build war -->
+        <!-- must remove ejb classes and lib classes first -->
+        <delete file="${build.classes.dir}/META-INF/beans.xml"/>
+        <delete dir="${build.classes.dir}/com/acme/ejb"/>
+        <delete dir="${build.classes.dir}/com/acme/util"/>
+        <antcall target="webclient-war-common">
+          <param name="hasWebclient" value="true"/>
+        </antcall>
+
+        <copy file="${env.APS_HOME}/lib/reporter.jar" todir="${build.classes.dir}/lib-dir"/>
+
+        <delete file="${assemble.dir}/${appname}.ear"/>
+        <mkdir dir="${assemble.dir}"/>
+        <mkdir dir="${build.classes.dir}/META-INF"/>
+        <copy file="${sun-application.xml}" tofile="${build.classes.dir}/META-INF/sun-application.xml"  	failonerror="false"/>
+        <copy file="${glassfish-resources-ear.xml}" tofile="${build.classes.dir}/META-INF/glassfish-resources.xml" failonerror="false"  filtering="true"/>
+        <ear earfile="${assemble.dir}/${appname}App.ear"
+             appxml="${application.xml}" >
+          <fileset dir="${assemble.dir}">
+            <include name="*.jar"/>
+            <include name="*.war"/>
+          </fileset>
+          <fileset dir="${build.classes.dir}">
+	        <include name="META-INF/sun-application.xml"/>
+            <include name="META-INF/glassfish-resources.xml"/>
+          </fileset>
+<!--
+    <fileset dir="${env.APS_HOME}" includes="lib/reporter.jar"/>
+-->
+    <fileset dir="${build.classes.dir}" includes="lib-dir/*"/>
+  </ear>  
+
+    </target> 
+    
+    <target name="deploy" 
+            depends="init-common">
+        <antcall target="deploy-common"/>
+    </target>
+
+    <target name="run" depends="init-common">
+       <java  fork="on" 
+              failonerror="true"
+              classpath="${env.S1AS_HOME}/lib/javaee.jar:${env.S1AS_HOME}/lib/gf-client.jar:${build.classes.dir}:${env.APS_HOME}/lib/reporter.jar"
+              classname="${se.client}">
+           <arg line="${contextroot}"/>
+           <arg line="${http.host}"/>
+           <arg line="${http.port}"/>
+        </java>
+    </target>
+ 
+    <target name="undeploy" depends="init-common">
+        <antcall target="undeploy-common"/>
+    </target>   
+
+    <target name="usage">
+        <antcall target="usage-common"/>
+    </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/client/com/acme/Client.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/client/com/acme/Client.java
new file mode 100644
index 0000000..c5ca393
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/client/com/acme/Client.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package com.acme;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import javax.annotation.Resource;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+public class Client {
+
+    private static final String TEST_NAME = "em-resource-injection-with-resource-declaration-in-another-jar";
+
+    private static SimpleReporterAdapter stat = 
+                            new SimpleReporterAdapter("appserv-tests");
+
+    private static String appName;
+    private String host;
+    private String port;
+
+    @Resource(lookup = "java:app/env/value1")
+    private static Integer appLevelViaLookup;
+
+    public static void main(String args[]) {
+        appName = args[0];
+        stat.addDescription(appName);
+        Client client = new Client(args);
+        client.doTest();
+        stat.printSummary(appName + "ID");
+        System.out.println("appLevelViaLookup = '" + appLevelViaLookup + "'");
+    }
+
+    public Client(String[] args) {
+        host = args[1];
+        port = args[2];
+    }
+
+    public void doTest() {
+        try {
+            String url = "http://" + host + ":" + port + "/" + appName
+                    + "/HelloServlet";
+            System.out.println("invoking webclient servlet at " + url);
+            URL u = new URL(url);
+            HttpURLConnection c1 = (HttpURLConnection) u.openConnection();
+            int code = c1.getResponseCode();
+            InputStream is = c1.getInputStream();
+            BufferedReader input = new BufferedReader(new InputStreamReader(
+                    is));
+            String line = null;
+            while ((line = input.readLine()) != null) {
+                System.out.println("<response>:" + line);
+                if (line.trim().length() > 0) {
+                    stat.addStatus(TEST_NAME, stat.FAIL);
+                    return;
+                }
+            }
+            if (code != 200) {
+                stat.addStatus(TEST_NAME, stat.FAIL);
+                return;
+            }
+            stat.addStatus(TEST_NAME, stat.PASS);
+
+        } catch (Exception e) {
+            stat.addStatus(TEST_NAME, stat.FAIL);
+            e.printStackTrace();
+        }
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/descriptor/application.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/descriptor/application.xml
new file mode 100644
index 0000000..1188e6a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/descriptor/application.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="6" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd">
+  <display-name>ejb-ejb30-hello-session3App</display-name>
+  <module>
+    <ejb>cdi-full-ear-ejb.jar</ejb>
+  </module>
+  <module>
+    <web>
+      <web-uri>cdi-full-ear-web.war</web-uri>
+      <context-root>cdi-full-ear</context-root>
+    </web>
+  </module>
+  <library-directory>lib-dir</library-directory>
+  <env-entry>
+     <env-entry-name>java:app/env/value1</env-entry-name>
+     <env-entry-type>java.lang.Integer</env-entry-type>
+     <env-entry-value>18338</env-entry-value>
+  </env-entry>
+  <env-entry>
+    <env-entry-name>java:app/env/myString</env-entry-name>
+    <env-entry-type>java.lang.String</env-entry-type>
+    <env-entry-value>myString</env-entry-value>
+  </env-entry>
+</application>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/descriptor/beans.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/descriptor/beans.xml
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/descriptor/persistence.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/descriptor/persistence.xml
new file mode 100644
index 0000000..82f2d7b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/descriptor/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+  <persistence-unit name="pu1" transaction-type="JTA">
+    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+    <jta-data-source>jdbc/__default</jta-data-source>
+    <non-jta-data-source>jdbc/__default</non-jta-data-source>
+    <class>myapp.Department</class>
+    <class>myapp.Employee</class>
+    <properties>
+       <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+       <property name="eclipselink.logging.level" value="INFO"/>
+    </properties>
+  </persistence-unit>
+</persistence>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/ejb/com/acme/ejb/api/Hello.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/ejb/com/acme/ejb/api/Hello.java
new file mode 100644
index 0000000..739e1ec
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/ejb/com/acme/ejb/api/Hello.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package com.acme.ejb.api;
+
+public interface Hello {
+
+    public String hello();
+    public static final String HELLO_TEST_STRING = "hello, world!\n";
+
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/ejb/com/acme/ejb/api/HelloRemote.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/ejb/com/acme/ejb/api/HelloRemote.java
new file mode 100644
index 0000000..0993e59
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/ejb/com/acme/ejb/api/HelloRemote.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package com.acme.ejb.api;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface HelloRemote {
+
+    public String hello();
+
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/ejb/com/acme/ejb/impl/HelloSingleton.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/ejb/com/acme/ejb/impl/HelloSingleton.java
new file mode 100644
index 0000000..083e62f
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/ejb/com/acme/ejb/impl/HelloSingleton.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package com.acme.ejb.impl;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.ejb.DependsOn;
+import javax.ejb.SessionContext;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+
+import com.acme.ejb.api.Hello;
+import com.acme.util.TestDatabase;
+
+@Singleton
+@Startup
+@DependsOn("Singleton4")
+public class HelloSingleton implements Hello {
+
+    @Resource
+    SessionContext sessionCtx;
+
+    @PersistenceUnit(unitName = "pu1")
+    @TestDatabase
+    private EntityManagerFactory emf;
+    
+
+    @PostConstruct
+    private void init() {
+        System.out.println("HelloSingleton::init()");
+
+        String appName;
+        String moduleName;
+        appName = (String) sessionCtx.lookup("java:app/AppName");
+        moduleName = (String) sessionCtx.lookup("java:module/ModuleName");
+        System.out.println("AppName = " + appName);
+        System.out.println("ModuleName = " + moduleName);
+    }
+
+    public String hello() {
+        System.out.println("HelloSingleton::hello()");
+        return testEMF(emf);
+    }
+
+    private String testEMF(EntityManagerFactory emf2) {
+        if (emf == null) return "EMF injection failed, is null in Singleton EJB";
+        if (emf.createEntityManager() == null) return "Usage of EMF failed in Singleton EJB";
+        return Hello.HELLO_TEST_STRING;
+    }
+
+    @PreDestroy
+    private void destroy() {
+        System.out.println("HelloSingleton::destroy()");
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/ejb/com/acme/ejb/impl/Singleton4.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/ejb/com/acme/ejb/impl/Singleton4.java
new file mode 100644
index 0000000..b3fd249
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/ejb/com/acme/ejb/impl/Singleton4.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package com.acme.ejb.impl;
+
+import javax.ejb.*;
+import javax.annotation.*;
+
+
+@Singleton
+public class Singleton4 {
+
+    @PostConstruct
+    public void init() {
+        System.out.println("In SingletonBean4::init()");
+    }
+    
+    @PreDestroy
+    public void destroy() {
+        System.out.println("In SingletonBean4::destroy()");
+    }
+
+
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/lib/com/acme/util/ResourcesProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/lib/com/acme/util/ResourcesProducer.java
new file mode 100644
index 0000000..fdc079b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/lib/com/acme/util/ResourcesProducer.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package com.acme.util;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+@Singleton
+public class ResourcesProducer {
+    @Produces
+    @PersistenceContext(unitName = "pu1")
+    @TestDatabase
+    EntityManager customerDatabasePersistenceUnit;
+    
+    @Inject
+    TestDependentBeanInLib foo;
+    
+    public boolean isInjectionSuccessful(){
+        return (foo != null);
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/lib/com/acme/util/TestDatabase.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/lib/com/acme/util/TestDatabase.java
new file mode 100644
index 0000000..db9e318
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/lib/com/acme/util/TestDatabase.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package com.acme.util;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TestDatabase {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/lib/com/acme/util/TestDependentBeanInLib.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/lib/com/acme/util/TestDependentBeanInLib.java
new file mode 100644
index 0000000..9596b22
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/lib/com/acme/util/TestDependentBeanInLib.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package com.acme.util;
+
+
+public class TestDependentBeanInLib {
+    public TestDependentBeanInLib() {
+        super();
+    }
+    
+    public String foo(){
+        return "foo!";
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/lib/com/acme/util/TestManagedBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/lib/com/acme/util/TestManagedBean.java
new file mode 100644
index 0000000..c7763cc
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/lib/com/acme/util/TestManagedBean.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package com.acme.util;
+
+import javax.annotation.ManagedBean;
+import javax.inject.Inject;
+
+@ManagedBean
+public class TestManagedBean {
+    @Inject
+    private TestDependentBeanInLib tdbl;
+    
+    public boolean isInjectionSuccessful(){
+        return tdbl != null;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/manifest.mf b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/war/com/acme/servlet/HelloServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/war/com/acme/servlet/HelloServlet.java
new file mode 100644
index 0000000..221e1e4
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection-with-resource-declaration-in-another-jar/war/com/acme/servlet/HelloServlet.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package com.acme.servlet;
+
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.ejb.EJB;
+import javax.inject.Inject;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.acme.ejb.api.Hello;
+import com.acme.util.TestDependentBeanInLib;
+import com.acme.util.ResourcesProducer;
+import com.acme.util.TestDatabase;
+import com.acme.util.TestManagedBean;
+
+@WebServlet(urlPatterns = "/HelloServlet", loadOnStartup = 1)
+
+@SuppressWarnings("serial")
+public class HelloServlet extends HttpServlet {
+    String msg = "";
+    
+    @EJB(name = "java:module/m1", beanName = "HelloSingleton", beanInterface = Hello.class)
+    Hello h;
+    
+    @PersistenceUnit(unitName = "pu1")
+    @TestDatabase
+    private EntityManagerFactory emf;
+
+    @Inject
+    private ResourcesProducer rp;
+    
+    @Inject
+    private TestDependentBeanInLib fb;
+    
+    @Inject
+    private TestManagedBean tmb;
+    
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+            throws ServletException, IOException {
+        System.out.println("In HelloServlet::doGet");
+        resp.setContentType("text/html");
+        PrintWriter out = resp.getWriter();
+        
+        checkForNull(emf, "Injection of EMF failed in Servlet");
+        //ensure EMF works!
+        emf.createEntityManager();
+        
+        //call Singleton EJB
+        String response = h.hello();
+        if(!response.equals(Hello.HELLO_TEST_STRING))
+            msg += "Invocation of Hello Singeton EJB failed:msg=" + response;
+        
+        if (!rp.isInjectionSuccessful())
+            msg += "Injection of a bean in lib directory into another " +
+            		"Bean in lib directory failed";
+        checkForNull(fb, "Injection of a bean that is placed in lib directory " +
+        		"into a Servlet that is placed in a WAR failed");
+        checkForNull(tmb, "Injection of a Managed bean that is placed in lib directory " +
+        "into a Servlet that is placed in a WAR failed");
+        
+        if (!rp.isInjectionSuccessful())
+            msg += "Injection of a bean in lib directory into another Bean " +
+            		"in lib directory failed";
+        
+        if (!tmb.isInjectionSuccessful())
+            msg += "Injection of a Bean placed in lib dir into a " +
+            		"ManagedBean placed in lib dir failed";
+        
+        
+        out.println(msg);
+    }
+
+    protected void checkForNull(Object o, String errorMessage){
+        System.out.println("o=" + o);
+        if (o == null) msg += " " + errorMessage;
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/README
new file mode 100644
index 0000000..d620428
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/README
@@ -0,0 +1,5 @@
+Test
+- Use of Java EE component environment resources 
+    - type safe injection of JPA resources (EntityManagerFactory, EntityManager) 
+    by declaring a resource by annotating a producer field wuth a 
+    component environment injection annotation
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/build.properties
new file mode 100644
index 0000000..0411ec9
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/build.properties
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+ 
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-em-resource-injection"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
+<property name="persistence.xml" value="descriptor/persistence.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/build.xml
new file mode 100644
index 0000000..295d086
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/build.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+    &commonSetup;
+    &commonBuild;
+    &testproperties;
+    &run;
+
+    <target name="all" depends="build,create-resources,deploy,run,undeploy,delete-resources" />
+
+	<target name="clean" depends="init-common">
+		<antcall target="clean-common" />
+		<delete>
+			<fileset dir="." includes="*.class" />
+			<fileset dir="client/test/client" includes="*.class" />
+		</delete>
+	</target>
+
+	<target name="compile" depends="clean">
+		<antcall target="compile-common">
+			<param name="src" value="servlet" />
+		</antcall>
+	</target>
+
+	<target name="build" depends="compile">
+		<property name="hasWebclient" value="yes" />
+		<antcall target="webclient-war-common">
+			<param name="hasWebclient" value="yes" />
+			<param name="webclient.war.classes" value="**/*.class" />
+		</antcall>
+
+		<javac srcdir="client" classpath="${env.APS_HOME}/lib/reportbuilder.jar" includes="test/client/WebTest.java" />
+
+	</target>
+
+	<target name="build-publish-war" depends="build, publish-war-common" />
+
+	<target name="deploy" depends="init-common">
+		<antcall target="deploy-war-common" />
+	</target>
+
+	<target name="create-resources" depends="init-common">
+		<antcall target="create-jdbc-connpool-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+		</antcall>
+		<antcall target="create-jdbc-resource-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+			<param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+		</antcall>
+	</target>
+
+
+	<target name="run" depends="init-common">
+		<java classname="test.client.WebTest">
+			<arg value="${http.host}" />
+			<arg value="${http.port}" />
+			<arg value="${contextroot}" />
+			<classpath>
+				<pathelement location="${env.APS_HOME}/lib/reportbuilder.jar" />
+				<pathelement location="client" />
+			</classpath>
+		</java>
+	</target>
+
+	<target name="undeploy" depends="init-common">
+		<antcall target="undeploy-war-common" />
+	</target>
+
+	<target name="delete-resources" depends="init-common">
+		<antcall target="delete-jdbc-resource-common">
+			<param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+		</antcall>
+
+		<antcall target="delete-jdbc-connpool-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+		</antcall>
+	</target>
+
+	<target name="usage">
+		<antcall target="usage-common" />
+	</target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/client/test/client/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/client/test/client/WebTest.java
new file mode 100644
index 0000000..2b9abe8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/client/test/client/WebTest.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.client;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+    private static SimpleReporterAdapter stat = new SimpleReporterAdapter(
+            "appserv-tests");
+    private static final String TEST_NAME = "em-resource-injection";
+
+    private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0.";
+
+    private String host;
+    private String port;
+    private String contextRoot;
+
+    public WebTest(String[] args) {
+        host = args[0];
+        port = args[1];
+        contextRoot = args[2];
+    }
+
+    public static void main(String[] args) {
+        stat.addDescription("Unit test for Java EE resource injection");
+        WebTest webTest = new WebTest(args);
+        webTest.doTest();
+        stat.printSummary(TEST_NAME);
+    }
+
+    public void doTest() {
+        try {
+            invoke("llinit");
+            invoke("llquery");
+            invoke("llfind");
+            invoke("llinj");
+        } catch (Exception ex) {
+            System.out.println(TEST_NAME + " test failed");
+            stat.addStatus(TEST_NAME, stat.FAIL);
+            ex.printStackTrace();
+        }
+    }
+
+    private void invoke(String testCase) throws Exception {
+
+        String url = "http://" + host + ":" + port + contextRoot + "/myurl"
+                + "?testcase=" + testCase;
+        System.out.println("opening connection to " + url);
+        HttpURLConnection conn = (HttpURLConnection) (new URL(url))
+                .openConnection();
+
+        int code = conn.getResponseCode();
+        if (code != 200) {
+            System.out.println("Unexpected return code: " + code);
+            stat.addStatus(TEST_NAME + testCase, stat.FAIL);
+        } else {
+            InputStream is = null;
+            BufferedReader input = null;
+            String line = null;
+            try {
+                is = conn.getInputStream();
+                input = new BufferedReader(new InputStreamReader(is));
+                line = input.readLine();
+                System.out.println("line = " + line);
+            } finally {
+                try {
+                    if (is != null) {
+                        is.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+                try {
+                    if (input != null) {
+                        input.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+            }
+            if (EXPECTED_RESPONSE.equals(line)) {
+                stat.addStatus(TEST_NAME + testCase, stat.PASS);
+            } else {
+                System.out.println("Wrong response. Expected: "
+                        + EXPECTED_RESPONSE + ", received: " + line);
+                stat.addStatus(TEST_NAME + testCase, stat.FAIL);
+            }
+        }
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/descriptor/beans.xml
new file mode 100644
index 0000000..1d355f8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/descriptor/beans.xml
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<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>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/descriptor/persistence.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/descriptor/persistence.xml
new file mode 100644
index 0000000..82f2d7b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/descriptor/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+  <persistence-unit name="pu1" transaction-type="JTA">
+    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+    <jta-data-source>jdbc/__default</jta-data-source>
+    <non-jta-data-source>jdbc/__default</non-jta-data-source>
+    <class>myapp.Department</class>
+    <class>myapp.Employee</class>
+    <properties>
+       <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+       <property name="eclipselink.logging.level" value="INFO"/>
+    </properties>
+  </persistence-unit>
+</persistence>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/beans/TestBeanInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/beans/TestBeanInterface.java
new file mode 100644
index 0000000..29e137a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/beans/TestBeanInterface.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans;
+
+public interface TestBeanInterface {
+    public void m1();
+    public void m2();
+    
+    public String testDatasourceInjection();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/beans/artifacts/Preferred.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/beans/artifacts/Preferred.java
new file mode 100644
index 0000000..b7584c8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/beans/artifacts/Preferred.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Preferred {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/beans/artifacts/TestDatabase.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/beans/artifacts/TestDatabase.java
new file mode 100644
index 0000000..b69ab8e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/beans/artifacts/TestDatabase.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TestDatabase {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/beans/nonmock/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/beans/nonmock/TestBean.java
new file mode 100644
index 0000000..2363d68
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/beans/nonmock/TestBean.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+import test.beans.artifacts.TestDatabase;
+
+
+@RequestScoped
+@Preferred
+public class TestBean implements TestBeanInterface{
+    public static boolean testBeanInvoked = false;
+    
+    @Inject //@TestDatabase 
+    EntityManager emf;
+
+    @Override
+    public void m1() {
+        testBeanInvoked = true;
+        System.out.println("TestBean::m1 called");
+    }
+
+    @Override
+    public void m2() {
+        System.out.println("TestBean::m2 called");
+    }
+
+    @Override
+    public String testDatasourceInjection() {
+        return (emf==null ? "typesafe injection into testbean failed" : "");
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/entity/Department.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/entity/Department.java
new file mode 100644
index 0000000..14191ec
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/entity/Department.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.entity;
+
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "DEPARTMENT")
+public class Department implements java.io.Serializable {
+
+    // Instance variables
+    private int id;
+    private String name;
+    private Set<Employee> employees;
+
+    public Department() {
+    }
+
+    public Department(int id, String name) {
+        this.id = id;
+        this.name = name;
+    }
+
+    // ===========================================================
+    // getters and setters for the state fields
+
+    @Id
+    @Column(name = "ID")
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    @Column(name = "NAME")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    // ===========================================================
+    // getters and setters for the association fields
+    @OneToMany(cascade = CascadeType.ALL, mappedBy = "department")
+    public Set<Employee> getEmployees() {
+        return employees;
+    }
+
+    public void setEmployees(Set<Employee> employees) {
+        this.employees = employees;
+    }
+
+    public String toString() {
+        return "Department id=" + getId() + ", Department Name=" + getName();
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/entity/Employee.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/entity/Employee.java
new file mode 100644
index 0000000..a1820e8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/entity/Employee.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+@Entity
+@Table(name = "EMPLOYEE")
+public class Employee implements java.io.Serializable {
+
+    private int id;
+    private String firstName;
+    private String lastName;
+    private Department department;
+
+    public Employee() {
+    }
+
+    public Employee(int id, String firstName, String lastName) {
+        this.id = id;
+        this.firstName = firstName;
+        this.lastName = lastName;
+    }
+
+    public Employee(int id, String firstName, String lastName,
+            Department department) {
+        this.id = id;
+        this.firstName = firstName;
+        this.lastName = lastName;
+        this.department = department;
+    }
+
+    // ===========================================================
+    // getters and setters for the state fields
+    @Id
+    @Column(name = "ID")
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    @Column(name = "FIRSTNAME")
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    @Column(name = "LASTNAME")
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    // ===========================================================
+    // getters and setters for the association fields
+    // @ManyToOne
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "DEPARTMENT_ID")
+    public Department getDepartment() {
+        return department;
+    }
+
+    @Transient
+    public Department getDepartmentNoWeaving() {
+        try {
+            java.lang.reflect.Field f = Employee.class
+                    .getDeclaredField("department");
+            return (Department) f.get(this);
+        } catch (NoSuchFieldException e) {
+            throw new RuntimeException(
+                    "Please change argument to getDeclaredField", e);
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public void setDepartment(Department department) {
+        this.department = department;
+    }
+
+    public String toString() {
+        return "Employee id=" + getId() + ", firstName=" + getFirstName()
+                + ", lastName=" + getLastName() + ", department="
+                + getDepartment();
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/servlet/JPAResourceInjectionServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/servlet/JPAResourceInjectionServlet.java
new file mode 100644
index 0000000..de25da1
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/servlet/JPAResourceInjectionServlet.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.transaction.UserTransaction;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+import test.util.JpaTest;
+
+@WebServlet(name = "mytest", urlPatterns = { "/myurl" })
+public class JPAResourceInjectionServlet extends HttpServlet {
+
+    @PersistenceUnit(unitName = "pu1")
+    private EntityManagerFactory emf_at_pu;
+
+    @Inject
+    //@TestDatabase
+    private EntityManager emf_at_inj;
+
+    private @Resource
+    UserTransaction utx;
+    
+    @Inject
+    @Preferred
+    TestBeanInterface tbi;
+
+    protected void doGet(HttpServletRequest request,
+            HttpServletResponse response) throws ServletException,
+            IOException {
+        PrintWriter writer = response.getWriter();
+        writer.write("Hello from Servlet 3.0.");
+        String msg = "";
+        System.out.println("JPAResourceInjectionServlet::@PersistenceUnit " +
+        		"CDI EntityManagerFactory=" + emf_at_inj);
+
+        EntityManager em = emf_at_inj;
+        System.out.println("JPAResourceInjectionServlet::createEM" +
+        		"EntityManager=" + em);
+        String testcase = request.getParameter("testcase");
+        System.out.println("testcase=" + testcase);
+
+        if (testcase != null) {
+            JpaTest jt = new JpaTest(em, utx);
+            boolean status = false;
+            if ("llinit".equals(testcase)) {
+                status = jt.lazyLoadingInit();
+            } else if ("llfind".equals(testcase)) {
+                status = jt.lazyLoadingByFind(1);
+            } else if ("llquery".equals(testcase)) {
+                status = jt.lazyLoadingByQuery("Carla");
+            } else if ("llinj".equals(testcase)){
+                status = ((tbi != null) && 
+                        (tbi.testDatasourceInjection().trim().length()==0));
+            }
+            if (status) {
+                msg += "";// pass
+            } else {
+                msg += (testcase + ":fail");
+            }
+        }
+
+        writer.write(msg + "\n");
+
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/util/JPAResourceProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/util/JPAResourceProducer.java
new file mode 100644
index 0000000..dc70909
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/util/JPAResourceProducer.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.util;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import test.beans.artifacts.TestDatabase;
+
+@Singleton
+public class JPAResourceProducer {
+    @Produces @PersistenceContext(unitName="pu1")
+    //@TestDatabase 
+    EntityManager customerDatabasePersistenceUnit;
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/util/JpaTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/util/JpaTest.java
new file mode 100644
index 0000000..3d47448
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/em-resource-injection/servlet/test/util/JpaTest.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.util;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Query;
+import javax.transaction.UserTransaction;
+
+import test.entity.Department;
+import test.entity.Employee;
+
+public class JpaTest {
+
+    private EntityManager em;
+    private UserTransaction utx;
+
+    private static Department deptRef[] = new Department[2];
+    private static Employee empRef[] = new Employee[5];
+
+    public JpaTest() {
+    }
+
+    public JpaTest(EntityManager em, UserTransaction utx) {
+        this.em = em;
+        this.utx = utx;
+    }
+
+    public boolean lazyLoadingInit() {
+        boolean status = false;
+        System.out.println("-----lazeLoadingInit()---------");
+        try {
+            deptRef[0] = new Department(1, "Engineering");
+            deptRef[1] = new Department(2, "Marketing");
+            utx.begin();
+            em.joinTransaction();
+            for (int i = 0; i < 2; i++) {
+                em.persist(deptRef[i]);
+            }
+            utx.commit();
+
+            empRef[0] = new Employee(1, "Alan", "Frechette", deptRef[0]);
+            empRef[1] = new Employee(2, "Arthur", "Wesley", deptRef[0]);
+            empRef[2] = new Employee(3, "Abe", "White", deptRef[0]);
+            empRef[3] = new Employee(4, "Paul", "Hinz", deptRef[1]);
+            empRef[4] = new Employee(5, "Carla", "Calrson", deptRef[1]);
+            utx.begin();
+            em.joinTransaction();
+            for (int i = 0; i < 5; i++) {
+                em.persist(empRef[i]);
+            }
+            utx.commit();
+            status = true;
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+    public boolean lazyLoadingByFind(int employeeID) {
+
+        boolean status = true;
+        System.out.println("------------lazyLoadingAfterFind -----------");
+        System.out.println("employeeID = " + employeeID);
+        Employee emp = em.find(Employee.class, employeeID);
+
+        System.out.println("found: emp.id=" + emp.getId());
+
+        try {
+            // 1. get Department before loading
+            Department deptBL = emp.getDepartmentNoWeaving();
+            System.out.println("1. before loading: deptBL=" + deptBL);
+            String deptNameBL = null;
+            if (deptBL != null) {
+                deptNameBL = deptBL.getName();
+                System.out.println("deptNameBL=" + deptNameBL);
+            }
+            // assert deptBL == null;
+            if (deptBL != null) {
+                status = false;
+            }
+
+            // 2. loading
+            String deptName = emp.getDepartment().getName();
+            System.out.println("2. loading, deptName = " + deptName);
+
+            // 3. get Department after loading
+            Department deptAL = emp.getDepartmentNoWeaving();
+            System.out.println("3. after loading: deptAL=" + deptAL);
+            String deptNameAL = deptAL.getName();
+            System.out.println("deptNameAL=" + deptNameAL);
+            // assert deptAL != null
+            // assert deptAL.getName == deptName;
+            if (deptAL == null || deptNameAL != deptName) {
+                status = false;
+            }
+        } catch (Exception ex) {
+            status = false;
+            ex.printStackTrace();
+        }
+
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+    public boolean lazyLoadingByQuery(String fName) {
+
+        boolean status = true;
+        System.out.println("------------lazyLoadingByQuery -----------");
+        System.out.println("fName = " + fName);
+        Query query = em.createQuery(
+                "SELECT e FROM Employee e WHERE e.firstName like :firstName")
+                .setParameter("firstName", fName);
+        ;
+        Employee emp = (Employee) query.getSingleResult();
+
+        System.out.println("queried: emp.firstName=" + emp.getFirstName());
+
+        try {
+            // 1. get Department before loading
+            Department deptBL = emp.getDepartmentNoWeaving();
+            System.out.println("1. before loading: deptBL=" + deptBL);
+            String deptNameBL = null;
+            if (deptBL != null) {
+                deptNameBL = deptBL.getName();
+                System.out.println("deptNameBL=" + deptNameBL);
+            }
+            // assert deptBL == null;
+            if (deptBL != null) {
+                status = false;
+            }
+
+            // 2. loading
+            String deptName = emp.getDepartment().getName();
+            System.out.println("2. loading, deptName = " + deptName);
+
+            // 3. get Department after loading
+            Department deptAL = emp.getDepartmentNoWeaving();
+            System.out.println("3. after loading: deptAL=" + deptAL);
+            String deptNameAL = deptAL.getName();
+            System.out.println("deptNameAL=" + deptNameAL);
+            // assert deptAL != null
+            // assert deptAL.getName == deptName;
+            if (deptAL == null || deptNameAL != deptName) {
+                status = false;
+            }
+        } catch (Exception ex) {
+            status = false;
+            ex.printStackTrace();
+        }
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/README
new file mode 100644
index 0000000..b3115ec
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/README
@@ -0,0 +1,5 @@
+Test
+- Use of Java EE component environment resources 
+    - type safe injection of Java EE component resources by declaring a 
+    resource by annotating a producer field wuth a component environment injection
+    annotation
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/build.properties
new file mode 100644
index 0000000..3543e4c
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/build.properties
@@ -0,0 +1,24 @@
+<!--
+
+    Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+ 
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-typesafe-javaee-resource-injection"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/build.xml
new file mode 100644
index 0000000..295d086
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/build.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+    &commonSetup;
+    &commonBuild;
+    &testproperties;
+    &run;
+
+    <target name="all" depends="build,create-resources,deploy,run,undeploy,delete-resources" />
+
+	<target name="clean" depends="init-common">
+		<antcall target="clean-common" />
+		<delete>
+			<fileset dir="." includes="*.class" />
+			<fileset dir="client/test/client" includes="*.class" />
+		</delete>
+	</target>
+
+	<target name="compile" depends="clean">
+		<antcall target="compile-common">
+			<param name="src" value="servlet" />
+		</antcall>
+	</target>
+
+	<target name="build" depends="compile">
+		<property name="hasWebclient" value="yes" />
+		<antcall target="webclient-war-common">
+			<param name="hasWebclient" value="yes" />
+			<param name="webclient.war.classes" value="**/*.class" />
+		</antcall>
+
+		<javac srcdir="client" classpath="${env.APS_HOME}/lib/reportbuilder.jar" includes="test/client/WebTest.java" />
+
+	</target>
+
+	<target name="build-publish-war" depends="build, publish-war-common" />
+
+	<target name="deploy" depends="init-common">
+		<antcall target="deploy-war-common" />
+	</target>
+
+	<target name="create-resources" depends="init-common">
+		<antcall target="create-jdbc-connpool-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+		</antcall>
+		<antcall target="create-jdbc-resource-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+			<param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+		</antcall>
+	</target>
+
+
+	<target name="run" depends="init-common">
+		<java classname="test.client.WebTest">
+			<arg value="${http.host}" />
+			<arg value="${http.port}" />
+			<arg value="${contextroot}" />
+			<classpath>
+				<pathelement location="${env.APS_HOME}/lib/reportbuilder.jar" />
+				<pathelement location="client" />
+			</classpath>
+		</java>
+	</target>
+
+	<target name="undeploy" depends="init-common">
+		<antcall target="undeploy-war-common" />
+	</target>
+
+	<target name="delete-resources" depends="init-common">
+		<antcall target="delete-jdbc-resource-common">
+			<param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+		</antcall>
+
+		<antcall target="delete-jdbc-connpool-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+		</antcall>
+	</target>
+
+	<target name="usage">
+		<antcall target="usage-common" />
+	</target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/client/test/client/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/client/test/client/WebTest.java
new file mode 100644
index 0000000..fb8c7f3
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/client/test/client/WebTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.client;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+    private static SimpleReporterAdapter stat = new SimpleReporterAdapter(
+            "appserv-tests");
+    private static final String TEST_NAME = "typesafe-javaee-resource-injection";
+
+    private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0.";
+
+    private String host;
+    private String port;
+    private String contextRoot;
+
+    public WebTest(String[] args) {
+        host = args[0];
+        port = args[1];
+        contextRoot = args[2];
+    }
+
+    public static void main(String[] args) {
+        stat.addDescription("Unit test for stereotypes");
+        WebTest webTest = new WebTest(args);
+        webTest.doTest();
+        stat.printSummary(TEST_NAME);
+    }
+
+    public void doTest() {
+        try {
+            invoke();
+        } catch (Exception ex) {
+            System.out.println(TEST_NAME + " test failed");
+            stat.addStatus(TEST_NAME, stat.FAIL);
+            ex.printStackTrace();
+        }
+    }
+
+    private void invoke() throws Exception {
+
+        String url = "http://" + host + ":" + port + contextRoot + "/myurl";
+        System.out.println("opening connection to " + url);
+        HttpURLConnection conn = (HttpURLConnection) (new URL(url))
+                .openConnection();
+
+        int code = conn.getResponseCode();
+        if (code != 200) {
+            System.out.println("Unexpected return code: " + code);
+            stat.addStatus(TEST_NAME, stat.FAIL);
+        } else {
+            InputStream is = null;
+            BufferedReader input = null;
+            String line = null;
+            try {
+                is = conn.getInputStream();
+                input = new BufferedReader(new InputStreamReader(is));
+                line = input.readLine();
+                System.out.println("line = " + line);
+            } finally {
+                try {
+                    if (is != null) {
+                        is.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+                try {
+                    if (input != null) {
+                        input.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+            }
+            if (EXPECTED_RESPONSE.equals(line)) {
+                stat.addStatus(TEST_NAME, stat.PASS);
+            } else {
+                System.out.println("Wrong response. Expected: "
+                        + EXPECTED_RESPONSE + ", received: " + line);
+                stat.addStatus(TEST_NAME, stat.FAIL);
+            }
+        }
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/descriptor/beans.xml
new file mode 100644
index 0000000..1d355f8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/descriptor/beans.xml
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<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>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/servlet/test/beans/TestBeanInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/servlet/test/beans/TestBeanInterface.java
new file mode 100644
index 0000000..29e137a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/servlet/test/beans/TestBeanInterface.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans;
+
+public interface TestBeanInterface {
+    public void m1();
+    public void m2();
+    
+    public String testDatasourceInjection();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/servlet/test/beans/artifacts/Preferred.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/servlet/test/beans/artifacts/Preferred.java
new file mode 100644
index 0000000..b7584c8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/servlet/test/beans/artifacts/Preferred.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Preferred {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/servlet/test/beans/artifacts/TestDatabase.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/servlet/test/beans/artifacts/TestDatabase.java
new file mode 100644
index 0000000..b69ab8e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/servlet/test/beans/artifacts/TestDatabase.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TestDatabase {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/servlet/test/beans/nonmock/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/servlet/test/beans/nonmock/TestBean.java
new file mode 100644
index 0000000..1947fac
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/servlet/test/beans/nonmock/TestBean.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.sql.DataSource;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+import test.beans.artifacts.TestDatabase;
+
+
+@RequestScoped
+@Preferred
+public class TestBean implements TestBeanInterface{
+    public static boolean testBeanInvoked = false;
+    
+    @Inject @TestDatabase 
+    DataSource ds;
+
+    @Override
+    public void m1() {
+        testBeanInvoked = true;
+        System.out.println("TestBean::m1 called");
+    }
+
+    @Override
+    public void m2() {
+        System.out.println("TestBean::m2 called");
+    }
+
+    @Override
+    public String testDatasourceInjection() {
+        return (ds==null ? "typesafe injection into testbean failed" : "");
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/servlet/test/servlet/DatabaseManager.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/servlet/test/servlet/DatabaseManager.java
new file mode 100644
index 0000000..0b4d0b3
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/servlet/test/servlet/DatabaseManager.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.servlet;
+
+import javax.annotation.Resource;
+import javax.enterprise.inject.Produces;
+import javax.sql.DataSource;
+
+import test.beans.artifacts.TestDatabase;
+
+public class DatabaseManager {
+    @Produces 
+    @TestDatabase
+    @Resource(name = "jdbc/jdbc-dev-test-resource", 
+            mappedName = "jdbc/jdbc-dev-test-resource")
+    DataSource ds;
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/servlet/test/servlet/TypesafeJavaEEResourceInjectionTestServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/servlet/test/servlet/TypesafeJavaEEResourceInjectionTestServlet.java
new file mode 100644
index 0000000..f1d5970
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/javaee-component-resource-typesafe-injection/servlet/test/servlet/TypesafeJavaEEResourceInjectionTestServlet.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.inject.Inject;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.sql.DataSource;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+import test.beans.artifacts.TestDatabase;
+
+@WebServlet(name = "mytest", urlPatterns = { "/myurl" })
+public class TypesafeJavaEEResourceInjectionTestServlet extends HttpServlet {
+    @Inject
+    @Preferred
+    TestBeanInterface tb;
+    
+    @Inject @TestDatabase
+    DataSource ds;
+        
+    public void service(HttpServletRequest req, HttpServletResponse res)
+            throws IOException, ServletException {
+
+        PrintWriter writer = res.getWriter();
+        writer.write("Hello from Servlet 3.0.");
+        String msg = "";
+        
+        if (ds == null)
+            msg += "typesafe Injection of datasource into a servlet failed";
+
+        if (tb == null)
+            msg += "Injection of request scoped bean failed";
+        
+        if (tb.testDatasourceInjection().trim().length() != 0)
+            msg += tb.testDatasourceInjection();
+
+        
+
+        writer.write(msg + "\n");
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/README
new file mode 100644
index 0000000..e613bc1
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/README
@@ -0,0 +1,5 @@
+Test
+- Use of Java EE component environment resources 
+    - type safe injection of Java EE component resources by declaring a 
+    resource by annotating a producer field wuth a component environment injection
+    annotation in a library jar
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/build.properties
new file mode 100644
index 0000000..4806149
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/build.properties
@@ -0,0 +1,24 @@
+<!--
+
+    Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+ 
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-jms-resource-injection-in-library-bean-archive"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/build.xml
new file mode 100644
index 0000000..8df2c24
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/build.xml
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+    &commonSetup;
+    &commonBuild;
+    &testproperties;
+    &run;
+
+    <target name="all" depends="build,create-resources,deploy,run,undeploy,delete-resources" />
+
+	<target name="clean" depends="init-common">
+		<antcall target="clean-common" />
+		<delete>
+			<fileset dir="." includes="*.class" />
+			<fileset dir="client/test/client" includes="*.class" />
+		</delete>
+	</target>
+
+	<target name="compile" depends="clean">
+        <!-- compile and create library jar -->
+        <mkdir dir="tmp"/>
+        <mkdir dir="tmp/META-INF"/>
+        <javac srcdir="producer-library-jar" destdir="tmp" classpath="${s1astest.classpath}" debug="on" failonerror="true"/>
+        <copy file="descriptor/beans.xml" todir="tmp/META-INF"/>
+
+        <mkdir dir="lib"/>
+        <jar jarfile="lib/producer-library.jar" update="true">
+            <fileset dir="tmp" casesensitive="yes">
+              <include name="**/*class*"/>
+              <include name="META-INF/beans.xml"/> <!-- include a beans.xml in the library jar for it to be considered as a bean archive -->
+            </fileset>
+        </jar>
+        <echo message="created library jar at lib/producer-library.jar"/>
+
+		<antcall target="compile-common">
+			<param name="src" value="servlet" />
+		</antcall>
+	</target>
+
+	<target name="build" depends="compile">
+		<property name="hasWebclient" value="yes" />
+		<antcall target="webclient-war-common">
+			<param name="hasWebclient" value="yes" />
+			<param name="webclient.war.classes" value="**/*.class" />
+		</antcall>
+
+		<javac srcdir="client" classpath="${env.APS_HOME}/lib/reportbuilder.jar" includes="test/client/WebTest.java" />
+
+	</target>
+
+	<target name="build-publish-war" depends="build, publish-war-common" />
+
+	<target name="deploy" depends="init-common">
+		<antcall target="deploy-war-common" />
+	</target>
+
+    <target name="create-resources" depends="init-common">
+        <antcall target="asadmin-batch-common">
+          <param name="asadmin.file" value="create_resources.asadmin"/>
+        </antcall>
+    </target>
+    
+    <target name="delete-resources" depends="init-common">
+        <antcall target="asadmin-batch-common">
+          <param name="asadmin.file" value="delete_resources.asadmin"/>
+        </antcall>
+    </target>
+
+
+	<target name="run" depends="init-common">
+		<java classname="test.client.WebTest">
+			<arg value="${http.host}" />
+			<arg value="${http.port}" />
+			<arg value="${contextroot}" />
+			<classpath>
+				<pathelement location="${env.APS_HOME}/lib/reportbuilder.jar" />
+				<pathelement location="client" />
+			</classpath>
+		</java>
+	</target>
+
+	<target name="undeploy" depends="init-common">
+		<antcall target="undeploy-war-common" />
+        <delete file="lib/producer-library.jar"/>
+	</target>
+
+	<target name="usage">
+		<antcall target="usage-common" />
+	</target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/client/test/client/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/client/test/client/WebTest.java
new file mode 100644
index 0000000..70744e7
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/client/test/client/WebTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.client;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+    private static SimpleReporterAdapter stat = new SimpleReporterAdapter(
+            "appserv-tests");
+    private static final String TEST_NAME = "jms-resource-lookup-producer-field-in-library-bean-archive";
+
+    private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0.";
+
+    private String host;
+    private String port;
+    private String contextRoot;
+
+    public WebTest(String[] args) {
+        host = args[0];
+        port = args[1];
+        contextRoot = args[2];
+    }
+
+    public static void main(String[] args) {
+        stat.addDescription("Unit test for stereotypes");
+        WebTest webTest = new WebTest(args);
+        webTest.doTest();
+        stat.printSummary(TEST_NAME);
+    }
+
+    public void doTest() {
+        try {
+            invoke();
+        } catch (Exception ex) {
+            System.out.println(TEST_NAME + " test failed");
+            stat.addStatus(TEST_NAME, stat.FAIL);
+            ex.printStackTrace();
+        }
+    }
+
+    private void invoke() throws Exception {
+
+        String url = "http://" + host + ":" + port + contextRoot + "/myurl";
+        System.out.println("opening connection to " + url);
+        HttpURLConnection conn = (HttpURLConnection) (new URL(url))
+                .openConnection();
+
+        int code = conn.getResponseCode();
+        if (code != 200) {
+            System.out.println("Unexpected return code: " + code);
+            stat.addStatus(TEST_NAME, stat.FAIL);
+        } else {
+            InputStream is = null;
+            BufferedReader input = null;
+            String line = null;
+            try {
+                is = conn.getInputStream();
+                input = new BufferedReader(new InputStreamReader(is));
+                line = input.readLine();
+                System.out.println("line = " + line);
+            } finally {
+                try {
+                    if (is != null) {
+                        is.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+                try {
+                    if (input != null) {
+                        input.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+            }
+            if (EXPECTED_RESPONSE.equals(line)) {
+                stat.addStatus(TEST_NAME, stat.PASS);
+            } else {
+                System.out.println("Wrong response. Expected: "
+                        + EXPECTED_RESPONSE + ", received: " + line);
+                stat.addStatus(TEST_NAME, stat.FAIL);
+            }
+        }
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/create_resources.asadmin b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/create_resources.asadmin
new file mode 100644
index 0000000..940c1b9
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/create_resources.asadmin
@@ -0,0 +1,3 @@
+create-jms-resource --restype javax.jms.ConnectionFactory jms/ConnectionFactory
+create-jmsdest --desttype queue Q1 
+create-jms-resource --restype javax.jms.Queue --property imqDestinationName=Q1 jms/Queue
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/delete_resources.asadmin b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/delete_resources.asadmin
new file mode 100644
index 0000000..29acf02
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/delete_resources.asadmin
@@ -0,0 +1,3 @@
+delete-jms-resource jms/ConnectionFactory
+delete-jms-resource jms/Queue
+delete-jmsdest --desttype queue Q1
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/descriptor/beans.xml
new file mode 100644
index 0000000..1d355f8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/descriptor/beans.xml
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<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>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/producer-library-jar/test/servlet/JMSResourcesProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/producer-library-jar/test/servlet/JMSResourcesProducer.java
new file mode 100644
index 0000000..31f4a60
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/producer-library-jar/test/servlet/JMSResourcesProducer.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.servlet;
+
+import javax.annotation.Resource;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.Session;
+
+
+@ApplicationScoped
+public class JMSResourcesProducer {
+
+    @Resource(mappedName = "jms/ConnectionFactory")
+    private ConnectionFactory connectionFactory;
+
+    @SuppressWarnings("unused")
+    @Produces
+    @Resource(mappedName = "jms/Queue")
+    private Queue queue;
+
+    @Produces
+    public Session produceSession() throws JMSException {
+        /*try {
+            connectionFactory = (ConnectionFactory) new javax.naming.InitialContext().lookup("jms/ConnectionFactory");
+        } catch (javax.naming.NamingException exc) {
+            throw new RuntimeException("couldn't lookup JMS Session", exc);
+        }*/
+        // as per EJB 3.1 specs $13.3.5
+        return connectionFactory.createConnection().createSession(true, 0);
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/servlet/test/beans/TestBeanInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/servlet/test/beans/TestBeanInterface.java
new file mode 100644
index 0000000..29e137a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/servlet/test/beans/TestBeanInterface.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans;
+
+public interface TestBeanInterface {
+    public void m1();
+    public void m2();
+    
+    public String testDatasourceInjection();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/servlet/test/beans/artifacts/Preferred.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/servlet/test/beans/artifacts/Preferred.java
new file mode 100644
index 0000000..b7584c8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/servlet/test/beans/artifacts/Preferred.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Preferred {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/servlet/test/beans/nonmock/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/servlet/test/beans/nonmock/TestBean.java
new file mode 100644
index 0000000..db83a56
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/servlet/test/beans/nonmock/TestBean.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.jms.Queue;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+
+
+@RequestScoped
+@Preferred
+public class TestBean implements TestBeanInterface{
+    public static boolean testBeanInvoked = false;
+    
+    @Inject 
+    Queue ds;
+
+    @Override
+    public void m1() {
+        testBeanInvoked = true;
+        System.out.println("TestBean::m1 called");
+    }
+
+    @Override
+    public void m2() {
+        System.out.println("TestBean::m2 called");
+    }
+
+    @Override
+    public String testDatasourceInjection() {
+        return (ds==null ? "typesafe injection into testbean failed" : "");
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/servlet/test/servlet/JMSResourceInjectionInLibraryBeanArchiveTestServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/servlet/test/servlet/JMSResourceInjectionInLibraryBeanArchiveTestServlet.java
new file mode 100644
index 0000000..5075703
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/servlet/test/servlet/JMSResourceInjectionInLibraryBeanArchiveTestServlet.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.inject.Inject;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+
+@WebServlet(name = "mytest", urlPatterns = { "/myurl" })
+public class JMSResourceInjectionInLibraryBeanArchiveTestServlet extends HttpServlet {
+    @Inject
+    @Preferred
+    TestBeanInterface tb;
+    
+    @Inject
+    private Queue queue;
+
+    @Inject
+    private Session session;
+    
+    public void service(HttpServletRequest req, HttpServletResponse res)
+            throws IOException, ServletException {
+
+        PrintWriter writer = res.getWriter();
+        writer.write("Hello from Servlet 3.0.");
+        String msg = "";
+        
+        if (queue == null)
+            msg += "typesafe Injection of queue into a servlet failed";
+
+        if (session == null)
+            msg += "typesafe Injection of Session into a servlet failed";
+        
+        if (tb == null)
+            msg += "Injection of request scoped bean failed";
+        
+        if (tb.testDatasourceInjection().trim().length() != 0)
+            msg += tb.testDatasourceInjection();
+
+        writer.write(msg + "\n");
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/tmp/META-INF/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/tmp/META-INF/beans.xml
new file mode 100644
index 0000000..1d355f8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field-in-library-jar/tmp/META-INF/beans.xml
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<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>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/README
new file mode 100644
index 0000000..e613bc1
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/README
@@ -0,0 +1,5 @@
+Test
+- Use of Java EE component environment resources 
+    - type safe injection of Java EE component resources by declaring a 
+    resource by annotating a producer field wuth a component environment injection
+    annotation in a library jar
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/build.properties
new file mode 100644
index 0000000..65a6203
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/build.properties
@@ -0,0 +1,24 @@
+<!--
+
+    Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+ 
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-jms-resource-injection"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/build.xml
new file mode 100644
index 0000000..1380e6b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/build.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+    &commonSetup;
+    &commonBuild;
+    &testproperties;
+    &run;
+
+    <target name="all" depends="build,create-resources,deploy,run,undeploy,delete-resources" />
+
+	<target name="clean" depends="init-common">
+		<antcall target="clean-common" />
+		<delete>
+			<fileset dir="." includes="*.class" />
+			<fileset dir="client/test/client" includes="*.class" />
+		</delete>
+	</target>
+
+	<target name="compile" depends="clean">
+		<antcall target="compile-common">
+			<param name="src" value="servlet" />
+		</antcall>
+	</target>
+
+	<target name="build" depends="compile">
+		<property name="hasWebclient" value="yes" />
+		<antcall target="webclient-war-common">
+			<param name="hasWebclient" value="yes" />
+			<param name="webclient.war.classes" value="**/*.class" />
+		</antcall>
+
+		<javac srcdir="client" classpath="${env.APS_HOME}/lib/reportbuilder.jar" includes="test/client/WebTest.java" />
+
+	</target>
+
+	<target name="build-publish-war" depends="build, publish-war-common" />
+
+	<target name="deploy" depends="init-common">
+		<antcall target="deploy-war-common" />
+	</target>
+
+    <target name="create-resources" depends="init-common">
+        <antcall target="asadmin-batch-common">
+          <param name="asadmin.file" value="create_resources.asadmin"/>
+        </antcall>
+    </target>
+    
+    <target name="delete-resources" depends="init-common">
+        <antcall target="asadmin-batch-common">
+          <param name="asadmin.file" value="delete_resources.asadmin"/>
+        </antcall>
+    </target>
+
+
+	<target name="run" depends="init-common">
+		<java classname="test.client.WebTest">
+			<arg value="${http.host}" />
+			<arg value="${http.port}" />
+			<arg value="${contextroot}" />
+			<classpath>
+				<pathelement location="${env.APS_HOME}/lib/reportbuilder.jar" />
+				<pathelement location="client" />
+			</classpath>
+		</java>
+	</target>
+
+	<target name="undeploy" depends="init-common">
+		<antcall target="undeploy-war-common" />
+	</target>
+
+	<target name="usage">
+		<antcall target="usage-common" />
+	</target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/client/test/client/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/client/test/client/WebTest.java
new file mode 100644
index 0000000..c3720d7
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/client/test/client/WebTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.client;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+    private static SimpleReporterAdapter stat = new SimpleReporterAdapter(
+            "appserv-tests");
+    private static final String TEST_NAME = "jms-resource-injection";
+
+    private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0.";
+
+    private String host;
+    private String port;
+    private String contextRoot;
+
+    public WebTest(String[] args) {
+        host = args[0];
+        port = args[1];
+        contextRoot = args[2];
+    }
+
+    public static void main(String[] args) {
+        stat.addDescription("Unit test for stereotypes");
+        WebTest webTest = new WebTest(args);
+        webTest.doTest();
+        stat.printSummary(TEST_NAME);
+    }
+
+    public void doTest() {
+        try {
+            invoke();
+        } catch (Exception ex) {
+            System.out.println(TEST_NAME + " test failed");
+            stat.addStatus(TEST_NAME, stat.FAIL);
+            ex.printStackTrace();
+        }
+    }
+
+    private void invoke() throws Exception {
+
+        String url = "http://" + host + ":" + port + contextRoot + "/myurl";
+        System.out.println("opening connection to " + url);
+        HttpURLConnection conn = (HttpURLConnection) (new URL(url))
+                .openConnection();
+
+        int code = conn.getResponseCode();
+        if (code != 200) {
+            System.out.println("Unexpected return code: " + code);
+            stat.addStatus(TEST_NAME, stat.FAIL);
+        } else {
+            InputStream is = null;
+            BufferedReader input = null;
+            String line = null;
+            try {
+                is = conn.getInputStream();
+                input = new BufferedReader(new InputStreamReader(is));
+                line = input.readLine();
+                System.out.println("line = " + line);
+            } finally {
+                try {
+                    if (is != null) {
+                        is.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+                try {
+                    if (input != null) {
+                        input.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+            }
+            if (EXPECTED_RESPONSE.equals(line)) {
+                stat.addStatus(TEST_NAME, stat.PASS);
+            } else {
+                System.out.println("Wrong response. Expected: "
+                        + EXPECTED_RESPONSE + ", received: " + line);
+                stat.addStatus(TEST_NAME, stat.FAIL);
+            }
+        }
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/create_resources.asadmin b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/create_resources.asadmin
new file mode 100644
index 0000000..940c1b9
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/create_resources.asadmin
@@ -0,0 +1,3 @@
+create-jms-resource --restype javax.jms.ConnectionFactory jms/ConnectionFactory
+create-jmsdest --desttype queue Q1 
+create-jms-resource --restype javax.jms.Queue --property imqDestinationName=Q1 jms/Queue
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/delete_resources.asadmin b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/delete_resources.asadmin
new file mode 100644
index 0000000..29acf02
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/delete_resources.asadmin
@@ -0,0 +1,3 @@
+delete-jms-resource jms/ConnectionFactory
+delete-jms-resource jms/Queue
+delete-jmsdest --desttype queue Q1
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/descriptor/beans.xml
new file mode 100644
index 0000000..1d355f8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/descriptor/beans.xml
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<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>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/servlet/test/beans/TestBeanInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/servlet/test/beans/TestBeanInterface.java
new file mode 100644
index 0000000..29e137a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/servlet/test/beans/TestBeanInterface.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans;
+
+public interface TestBeanInterface {
+    public void m1();
+    public void m2();
+    
+    public String testDatasourceInjection();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/servlet/test/beans/artifacts/Preferred.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/servlet/test/beans/artifacts/Preferred.java
new file mode 100644
index 0000000..b7584c8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/servlet/test/beans/artifacts/Preferred.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Preferred {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/servlet/test/beans/nonmock/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/servlet/test/beans/nonmock/TestBean.java
new file mode 100644
index 0000000..db83a56
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/servlet/test/beans/nonmock/TestBean.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.jms.Queue;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+
+
+@RequestScoped
+@Preferred
+public class TestBean implements TestBeanInterface{
+    public static boolean testBeanInvoked = false;
+    
+    @Inject 
+    Queue ds;
+
+    @Override
+    public void m1() {
+        testBeanInvoked = true;
+        System.out.println("TestBean::m1 called");
+    }
+
+    @Override
+    public void m2() {
+        System.out.println("TestBean::m2 called");
+    }
+
+    @Override
+    public String testDatasourceInjection() {
+        return (ds==null ? "typesafe injection into testbean failed" : "");
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/servlet/test/servlet/JMSResourceInjectionInLibraryBeanArchiveTestServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/servlet/test/servlet/JMSResourceInjectionInLibraryBeanArchiveTestServlet.java
new file mode 100644
index 0000000..5075703
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/servlet/test/servlet/JMSResourceInjectionInLibraryBeanArchiveTestServlet.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.inject.Inject;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+
+@WebServlet(name = "mytest", urlPatterns = { "/myurl" })
+public class JMSResourceInjectionInLibraryBeanArchiveTestServlet extends HttpServlet {
+    @Inject
+    @Preferred
+    TestBeanInterface tb;
+    
+    @Inject
+    private Queue queue;
+
+    @Inject
+    private Session session;
+    
+    public void service(HttpServletRequest req, HttpServletResponse res)
+            throws IOException, ServletException {
+
+        PrintWriter writer = res.getWriter();
+        writer.write("Hello from Servlet 3.0.");
+        String msg = "";
+        
+        if (queue == null)
+            msg += "typesafe Injection of queue into a servlet failed";
+
+        if (session == null)
+            msg += "typesafe Injection of Session into a servlet failed";
+        
+        if (tb == null)
+            msg += "Injection of request scoped bean failed";
+        
+        if (tb.testDatasourceInjection().trim().length() != 0)
+            msg += tb.testDatasourceInjection();
+
+        writer.write(msg + "\n");
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/servlet/test/servlet/JMSResourcesProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/servlet/test/servlet/JMSResourcesProducer.java
new file mode 100644
index 0000000..31f4a60
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jms-resource-producer-field/servlet/test/servlet/JMSResourcesProducer.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.servlet;
+
+import javax.annotation.Resource;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.Session;
+
+
+@ApplicationScoped
+public class JMSResourcesProducer {
+
+    @Resource(mappedName = "jms/ConnectionFactory")
+    private ConnectionFactory connectionFactory;
+
+    @SuppressWarnings("unused")
+    @Produces
+    @Resource(mappedName = "jms/Queue")
+    private Queue queue;
+
+    @Produces
+    public Session produceSession() throws JMSException {
+        /*try {
+            connectionFactory = (ConnectionFactory) new javax.naming.InitialContext().lookup("jms/ConnectionFactory");
+        } catch (javax.naming.NamingException exc) {
+            throw new RuntimeException("couldn't lookup JMS Session", exc);
+        }*/
+        // as per EJB 3.1 specs $13.3.5
+        return connectionFactory.createConnection().createSession(true, 0);
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/README
new file mode 100644
index 0000000..c5e296b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/README
@@ -0,0 +1,6 @@
+Test
+- Use of Java EE component environment resources 
+    - type safe injection of JPA resources (EntityManagerFactory, EntityManager) 
+    by declaring a resource by annotating a producer field wuth a 
+    component environment injection annotation
+    - test if injection of non-serializable resource like EntityManager is supported. This should not result in a deployment failure
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/build.properties
new file mode 100644
index 0000000..fa73b33
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/build.properties
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+ 
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-jpa-resource-injection-non-serializable"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
+<property name="persistence.xml" value="descriptor/persistence.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/build.xml
new file mode 100644
index 0000000..295d086
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/build.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+    &commonSetup;
+    &commonBuild;
+    &testproperties;
+    &run;
+
+    <target name="all" depends="build,create-resources,deploy,run,undeploy,delete-resources" />
+
+	<target name="clean" depends="init-common">
+		<antcall target="clean-common" />
+		<delete>
+			<fileset dir="." includes="*.class" />
+			<fileset dir="client/test/client" includes="*.class" />
+		</delete>
+	</target>
+
+	<target name="compile" depends="clean">
+		<antcall target="compile-common">
+			<param name="src" value="servlet" />
+		</antcall>
+	</target>
+
+	<target name="build" depends="compile">
+		<property name="hasWebclient" value="yes" />
+		<antcall target="webclient-war-common">
+			<param name="hasWebclient" value="yes" />
+			<param name="webclient.war.classes" value="**/*.class" />
+		</antcall>
+
+		<javac srcdir="client" classpath="${env.APS_HOME}/lib/reportbuilder.jar" includes="test/client/WebTest.java" />
+
+	</target>
+
+	<target name="build-publish-war" depends="build, publish-war-common" />
+
+	<target name="deploy" depends="init-common">
+		<antcall target="deploy-war-common" />
+	</target>
+
+	<target name="create-resources" depends="init-common">
+		<antcall target="create-jdbc-connpool-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+		</antcall>
+		<antcall target="create-jdbc-resource-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+			<param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+		</antcall>
+	</target>
+
+
+	<target name="run" depends="init-common">
+		<java classname="test.client.WebTest">
+			<arg value="${http.host}" />
+			<arg value="${http.port}" />
+			<arg value="${contextroot}" />
+			<classpath>
+				<pathelement location="${env.APS_HOME}/lib/reportbuilder.jar" />
+				<pathelement location="client" />
+			</classpath>
+		</java>
+	</target>
+
+	<target name="undeploy" depends="init-common">
+		<antcall target="undeploy-war-common" />
+	</target>
+
+	<target name="delete-resources" depends="init-common">
+		<antcall target="delete-jdbc-resource-common">
+			<param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+		</antcall>
+
+		<antcall target="delete-jdbc-connpool-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+		</antcall>
+	</target>
+
+	<target name="usage">
+		<antcall target="usage-common" />
+	</target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/client/test/client/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/client/test/client/WebTest.java
new file mode 100644
index 0000000..19e1eb6
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/client/test/client/WebTest.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.client;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+    private static SimpleReporterAdapter stat = new SimpleReporterAdapter(
+            "appserv-tests");
+    private static final String TEST_NAME = "jpa-resource-injection-non-serializable";
+
+    private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0.";
+
+    private String host;
+    private String port;
+    private String contextRoot;
+
+    public WebTest(String[] args) {
+        host = args[0];
+        port = args[1];
+        contextRoot = args[2];
+    }
+
+    public static void main(String[] args) {
+        stat.addDescription("Unit test for Java EE resource injection");
+        WebTest webTest = new WebTest(args);
+        webTest.doTest();
+        stat.printSummary(TEST_NAME);
+    }
+
+    public void doTest() {
+        try {
+            invoke("llinit");
+            invoke("llquery");
+            invoke("llfind");
+            invoke("llinj");
+        } catch (Exception ex) {
+            System.out.println(TEST_NAME + " test failed. Unexpected error obtained:" + ex);
+            stat.addStatus(TEST_NAME, stat.FAIL);
+            //ex.printStackTrace();
+        }
+    }
+
+    private void invoke(String testCase) throws Exception {
+
+        String url = "http://" + host + ":" + port + contextRoot + "/myurl"
+                + "?testcase=" + testCase;
+        System.out.println("opening connection to " + url);
+        HttpURLConnection conn = (HttpURLConnection) (new URL(url))
+                .openConnection();
+
+        int code = conn.getResponseCode();
+        if (code != 200) {
+            System.out.println("Unexpected return code: " + code);
+            stat.addStatus(TEST_NAME + testCase, stat.FAIL);
+        } else {
+            InputStream is = null;
+            BufferedReader input = null;
+            String line = null;
+            try {
+                is = conn.getInputStream();
+                input = new BufferedReader(new InputStreamReader(is));
+                line = input.readLine();
+                System.out.println("line = " + line);
+            } finally {
+                try {
+                    if (is != null) {
+                        is.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+                try {
+                    if (input != null) {
+                        input.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+            }
+            if (EXPECTED_RESPONSE.equals(line)) {
+                stat.addStatus(TEST_NAME + testCase, stat.PASS);
+            } else {
+                System.out.println("Wrong response. Expected: "
+                        + EXPECTED_RESPONSE + ", received: " + line);
+                stat.addStatus(TEST_NAME + testCase, stat.FAIL);
+            }
+        }
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/descriptor/beans.xml
new file mode 100644
index 0000000..1d355f8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/descriptor/beans.xml
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<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>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/descriptor/persistence.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/descriptor/persistence.xml
new file mode 100644
index 0000000..713e047
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/descriptor/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+  <persistence-unit name="pu2" transaction-type="JTA">
+    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+    <jta-data-source>jdbc/__default</jta-data-source>
+    <non-jta-data-source>jdbc/__default</non-jta-data-source>
+    <class>myapp.Department</class>
+    <class>myapp.Employee</class>
+    <properties>
+       <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+       <property name="eclipselink.logging.level" value="INFO"/>
+    </properties>
+  </persistence-unit>
+</persistence>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/beans/TestBeanInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/beans/TestBeanInterface.java
new file mode 100644
index 0000000..29e137a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/beans/TestBeanInterface.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans;
+
+public interface TestBeanInterface {
+    public void m1();
+    public void m2();
+    
+    public String testDatasourceInjection();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/beans/artifacts/Preferred.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/beans/artifacts/Preferred.java
new file mode 100644
index 0000000..b7584c8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/beans/artifacts/Preferred.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Preferred {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/beans/artifacts/TestDatabase.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/beans/artifacts/TestDatabase.java
new file mode 100644
index 0000000..b69ab8e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/beans/artifacts/TestDatabase.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TestDatabase {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/beans/nonmock/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/beans/nonmock/TestBean.java
new file mode 100644
index 0000000..e2d6110
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/beans/nonmock/TestBean.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityManager;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+import test.beans.artifacts.TestDatabase;
+
+
+@SessionScoped //a passivating scope
+@Preferred
+public class TestBean implements TestBeanInterface, Serializable{
+    public static boolean testBeanInvoked = false;
+    
+    @Inject @TestDatabase 
+    EntityManagerFactory emf;
+
+	//Inject a non-serializable resource
+    @Inject @TestDatabase
+    EntityManager em;
+
+    @Override
+    public void m1() {
+        testBeanInvoked = true;
+        System.out.println("TestBean::m1 called");
+    }
+
+    @Override
+    public void m2() {
+        System.out.println("TestBean::m2 called");
+    }
+
+    @Override
+    public String testDatasourceInjection() {
+        String s = (emf==null ? "typesafe injection into testbean of EntityManagerFactory failed" : "");
+        s += (em == null ? "typesafe injection of EntityManager into testbean failed":"");
+        return s;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/entity/Department.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/entity/Department.java
new file mode 100644
index 0000000..14191ec
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/entity/Department.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.entity;
+
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "DEPARTMENT")
+public class Department implements java.io.Serializable {
+
+    // Instance variables
+    private int id;
+    private String name;
+    private Set<Employee> employees;
+
+    public Department() {
+    }
+
+    public Department(int id, String name) {
+        this.id = id;
+        this.name = name;
+    }
+
+    // ===========================================================
+    // getters and setters for the state fields
+
+    @Id
+    @Column(name = "ID")
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    @Column(name = "NAME")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    // ===========================================================
+    // getters and setters for the association fields
+    @OneToMany(cascade = CascadeType.ALL, mappedBy = "department")
+    public Set<Employee> getEmployees() {
+        return employees;
+    }
+
+    public void setEmployees(Set<Employee> employees) {
+        this.employees = employees;
+    }
+
+    public String toString() {
+        return "Department id=" + getId() + ", Department Name=" + getName();
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/entity/Employee.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/entity/Employee.java
new file mode 100644
index 0000000..a1820e8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/entity/Employee.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+@Entity
+@Table(name = "EMPLOYEE")
+public class Employee implements java.io.Serializable {
+
+    private int id;
+    private String firstName;
+    private String lastName;
+    private Department department;
+
+    public Employee() {
+    }
+
+    public Employee(int id, String firstName, String lastName) {
+        this.id = id;
+        this.firstName = firstName;
+        this.lastName = lastName;
+    }
+
+    public Employee(int id, String firstName, String lastName,
+            Department department) {
+        this.id = id;
+        this.firstName = firstName;
+        this.lastName = lastName;
+        this.department = department;
+    }
+
+    // ===========================================================
+    // getters and setters for the state fields
+    @Id
+    @Column(name = "ID")
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    @Column(name = "FIRSTNAME")
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    @Column(name = "LASTNAME")
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    // ===========================================================
+    // getters and setters for the association fields
+    // @ManyToOne
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "DEPARTMENT_ID")
+    public Department getDepartment() {
+        return department;
+    }
+
+    @Transient
+    public Department getDepartmentNoWeaving() {
+        try {
+            java.lang.reflect.Field f = Employee.class
+                    .getDeclaredField("department");
+            return (Department) f.get(this);
+        } catch (NoSuchFieldException e) {
+            throw new RuntimeException(
+                    "Please change argument to getDeclaredField", e);
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public void setDepartment(Department department) {
+        this.department = department;
+    }
+
+    public String toString() {
+        return "Employee id=" + getId() + ", firstName=" + getFirstName()
+                + ", lastName=" + getLastName() + ", department="
+                + getDepartment();
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/servlet/JPAResourceInjectionServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/servlet/JPAResourceInjectionServlet.java
new file mode 100644
index 0000000..086729b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/servlet/JPAResourceInjectionServlet.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.transaction.UserTransaction;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+import test.beans.artifacts.TestDatabase;
+import test.util.JpaTest;
+
+@WebServlet(name = "mytest", urlPatterns = { "/myurl" })
+public class JPAResourceInjectionServlet extends HttpServlet {
+
+    @PersistenceUnit(unitName = "pu2")
+    private EntityManagerFactory emf;
+
+    @Inject
+    @TestDatabase
+    private EntityManagerFactory emf1;
+
+    private @Resource
+    UserTransaction utx;
+    
+    @Inject
+    @Preferred
+    TestBeanInterface tbi;
+
+    protected void doGet(HttpServletRequest request,
+            HttpServletResponse response) throws ServletException,
+            IOException {
+        PrintWriter writer = response.getWriter();
+        writer.write("Hello from Servlet 3.0.");
+        String msg = "";
+        System.out.println("JPAResourceInjectionServlet::@PersistenceUnit " +
+        		"CDI EntityManagerFactory=" + emf1);
+
+        EntityManager em = emf1.createEntityManager();
+        System.out.println("JPAResourceInjectionServlet::createEM" +
+        		"EntityManager=" + em);
+        String testcase = request.getParameter("testcase");
+        System.out.println("testcase=" + testcase);
+
+        if (testcase != null) {
+            JpaTest jt = new JpaTest(em, utx);
+            boolean status = false;
+            if ("llinit".equals(testcase)) {
+                status = jt.lazyLoadingInit();
+            } else if ("llfind".equals(testcase)) {
+                status = jt.lazyLoadingByFind(1);
+            } else if ("llquery".equals(testcase)) {
+                status = jt.lazyLoadingByQuery("Carla");
+            } else if ("llinj".equals(testcase)){
+                status = ((tbi != null) && 
+                        (tbi.testDatasourceInjection().trim().length()==0));
+            }
+            if (status) {
+                msg += "";// pass
+            } else {
+                msg += (testcase + ":fail");
+            }
+        }
+
+        writer.write(msg + "\n");
+
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/util/JPAResourceProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/util/JPAResourceProducer.java
new file mode 100644
index 0000000..3623e19
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/util/JPAResourceProducer.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.util;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceUnit;
+
+import test.beans.artifacts.TestDatabase;
+
+@Singleton
+public class JPAResourceProducer {
+    @Produces @PersistenceUnit(unitName="pu2")
+    @TestDatabase 
+    EntityManagerFactory customerDatabasePersistenceUnit;
+
+    @Produces @PersistenceContext(unitName="pu2")
+    @TestDatabase 
+    EntityManager customerDatabasePersistenceContext;
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/util/JpaTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/util/JpaTest.java
new file mode 100644
index 0000000..3d47448
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-non-serializable/servlet/test/util/JpaTest.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.util;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Query;
+import javax.transaction.UserTransaction;
+
+import test.entity.Department;
+import test.entity.Employee;
+
+public class JpaTest {
+
+    private EntityManager em;
+    private UserTransaction utx;
+
+    private static Department deptRef[] = new Department[2];
+    private static Employee empRef[] = new Employee[5];
+
+    public JpaTest() {
+    }
+
+    public JpaTest(EntityManager em, UserTransaction utx) {
+        this.em = em;
+        this.utx = utx;
+    }
+
+    public boolean lazyLoadingInit() {
+        boolean status = false;
+        System.out.println("-----lazeLoadingInit()---------");
+        try {
+            deptRef[0] = new Department(1, "Engineering");
+            deptRef[1] = new Department(2, "Marketing");
+            utx.begin();
+            em.joinTransaction();
+            for (int i = 0; i < 2; i++) {
+                em.persist(deptRef[i]);
+            }
+            utx.commit();
+
+            empRef[0] = new Employee(1, "Alan", "Frechette", deptRef[0]);
+            empRef[1] = new Employee(2, "Arthur", "Wesley", deptRef[0]);
+            empRef[2] = new Employee(3, "Abe", "White", deptRef[0]);
+            empRef[3] = new Employee(4, "Paul", "Hinz", deptRef[1]);
+            empRef[4] = new Employee(5, "Carla", "Calrson", deptRef[1]);
+            utx.begin();
+            em.joinTransaction();
+            for (int i = 0; i < 5; i++) {
+                em.persist(empRef[i]);
+            }
+            utx.commit();
+            status = true;
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+    public boolean lazyLoadingByFind(int employeeID) {
+
+        boolean status = true;
+        System.out.println("------------lazyLoadingAfterFind -----------");
+        System.out.println("employeeID = " + employeeID);
+        Employee emp = em.find(Employee.class, employeeID);
+
+        System.out.println("found: emp.id=" + emp.getId());
+
+        try {
+            // 1. get Department before loading
+            Department deptBL = emp.getDepartmentNoWeaving();
+            System.out.println("1. before loading: deptBL=" + deptBL);
+            String deptNameBL = null;
+            if (deptBL != null) {
+                deptNameBL = deptBL.getName();
+                System.out.println("deptNameBL=" + deptNameBL);
+            }
+            // assert deptBL == null;
+            if (deptBL != null) {
+                status = false;
+            }
+
+            // 2. loading
+            String deptName = emp.getDepartment().getName();
+            System.out.println("2. loading, deptName = " + deptName);
+
+            // 3. get Department after loading
+            Department deptAL = emp.getDepartmentNoWeaving();
+            System.out.println("3. after loading: deptAL=" + deptAL);
+            String deptNameAL = deptAL.getName();
+            System.out.println("deptNameAL=" + deptNameAL);
+            // assert deptAL != null
+            // assert deptAL.getName == deptName;
+            if (deptAL == null || deptNameAL != deptName) {
+                status = false;
+            }
+        } catch (Exception ex) {
+            status = false;
+            ex.printStackTrace();
+        }
+
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+    public boolean lazyLoadingByQuery(String fName) {
+
+        boolean status = true;
+        System.out.println("------------lazyLoadingByQuery -----------");
+        System.out.println("fName = " + fName);
+        Query query = em.createQuery(
+                "SELECT e FROM Employee e WHERE e.firstName like :firstName")
+                .setParameter("firstName", fName);
+        ;
+        Employee emp = (Employee) query.getSingleResult();
+
+        System.out.println("queried: emp.firstName=" + emp.getFirstName());
+
+        try {
+            // 1. get Department before loading
+            Department deptBL = emp.getDepartmentNoWeaving();
+            System.out.println("1. before loading: deptBL=" + deptBL);
+            String deptNameBL = null;
+            if (deptBL != null) {
+                deptNameBL = deptBL.getName();
+                System.out.println("deptNameBL=" + deptNameBL);
+            }
+            // assert deptBL == null;
+            if (deptBL != null) {
+                status = false;
+            }
+
+            // 2. loading
+            String deptName = emp.getDepartment().getName();
+            System.out.println("2. loading, deptName = " + deptName);
+
+            // 3. get Department after loading
+            Department deptAL = emp.getDepartmentNoWeaving();
+            System.out.println("3. after loading: deptAL=" + deptAL);
+            String deptNameAL = deptAL.getName();
+            System.out.println("deptNameAL=" + deptNameAL);
+            // assert deptAL != null
+            // assert deptAL.getName == deptName;
+            if (deptAL == null || deptNameAL != deptName) {
+                status = false;
+            }
+        } catch (Exception ex) {
+            status = false;
+            ex.printStackTrace();
+        }
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/README
new file mode 100644
index 0000000..e90237d
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/README
@@ -0,0 +1,7 @@
+Test
+- Use of Java EE component environment resources 
+Passivating Scopes and passivation capable dependencies
+    - test if a producer method can return a non-serializable resource [EntityManager]. 
+    - test if a Stateful session bean can have non-transient injected field that is a resource  
+
+This test is similar to jpa-resource-injection-non-serializable except that the injection happens into a SFSB [a passivating bean]
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/build.properties
new file mode 100644
index 0000000..87af1eb
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/build.properties
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+ 
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-jpa-resource-injection-passivating-scope"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
+<property name="persistence.xml" value="descriptor/persistence.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/build.xml
new file mode 100644
index 0000000..295d086
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/build.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+    &commonSetup;
+    &commonBuild;
+    &testproperties;
+    &run;
+
+    <target name="all" depends="build,create-resources,deploy,run,undeploy,delete-resources" />
+
+	<target name="clean" depends="init-common">
+		<antcall target="clean-common" />
+		<delete>
+			<fileset dir="." includes="*.class" />
+			<fileset dir="client/test/client" includes="*.class" />
+		</delete>
+	</target>
+
+	<target name="compile" depends="clean">
+		<antcall target="compile-common">
+			<param name="src" value="servlet" />
+		</antcall>
+	</target>
+
+	<target name="build" depends="compile">
+		<property name="hasWebclient" value="yes" />
+		<antcall target="webclient-war-common">
+			<param name="hasWebclient" value="yes" />
+			<param name="webclient.war.classes" value="**/*.class" />
+		</antcall>
+
+		<javac srcdir="client" classpath="${env.APS_HOME}/lib/reportbuilder.jar" includes="test/client/WebTest.java" />
+
+	</target>
+
+	<target name="build-publish-war" depends="build, publish-war-common" />
+
+	<target name="deploy" depends="init-common">
+		<antcall target="deploy-war-common" />
+	</target>
+
+	<target name="create-resources" depends="init-common">
+		<antcall target="create-jdbc-connpool-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+		</antcall>
+		<antcall target="create-jdbc-resource-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+			<param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+		</antcall>
+	</target>
+
+
+	<target name="run" depends="init-common">
+		<java classname="test.client.WebTest">
+			<arg value="${http.host}" />
+			<arg value="${http.port}" />
+			<arg value="${contextroot}" />
+			<classpath>
+				<pathelement location="${env.APS_HOME}/lib/reportbuilder.jar" />
+				<pathelement location="client" />
+			</classpath>
+		</java>
+	</target>
+
+	<target name="undeploy" depends="init-common">
+		<antcall target="undeploy-war-common" />
+	</target>
+
+	<target name="delete-resources" depends="init-common">
+		<antcall target="delete-jdbc-resource-common">
+			<param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+		</antcall>
+
+		<antcall target="delete-jdbc-connpool-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+		</antcall>
+	</target>
+
+	<target name="usage">
+		<antcall target="usage-common" />
+	</target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/client/test/client/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/client/test/client/WebTest.java
new file mode 100644
index 0000000..5b5f610
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/client/test/client/WebTest.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.client;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+    private static SimpleReporterAdapter stat = new SimpleReporterAdapter(
+            "appserv-tests");
+    private static final String TEST_NAME = "jpa-resource-injection-passivating-scope";
+
+    private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0.";
+
+    private String host;
+    private String port;
+    private String contextRoot;
+
+    public WebTest(String[] args) {
+        host = args[0];
+        port = args[1];
+        contextRoot = args[2];
+    }
+
+    public static void main(String[] args) {
+        stat.addDescription("Unit test for Java EE resource injection");
+        WebTest webTest = new WebTest(args);
+        webTest.doTest();
+        stat.printSummary(TEST_NAME);
+    }
+
+    public void doTest() {
+        try {
+            invoke("llinit");
+            invoke("llquery");
+            invoke("llfind");
+            invoke("llinj");
+        } catch (Exception ex) {
+            System.out.println(TEST_NAME + " test failed. Expected error obtained:" + ex);
+            stat.addStatus(TEST_NAME, stat.FAIL);
+            //ex.printStackTrace();
+        }
+    }
+
+    private void invoke(String testCase) throws Exception {
+
+        String url = "http://" + host + ":" + port + contextRoot + "/myurl"
+                + "?testcase=" + testCase;
+        System.out.println("opening connection to " + url);
+        HttpURLConnection conn = (HttpURLConnection) (new URL(url))
+                .openConnection();
+
+        int code = conn.getResponseCode();
+        if (code != 200) {
+            System.out.println("Unexpected return code: " + code);
+            stat.addStatus(TEST_NAME + testCase, stat.FAIL);
+        } else {
+            InputStream is = null;
+            BufferedReader input = null;
+            String line = null;
+            try {
+                is = conn.getInputStream();
+                input = new BufferedReader(new InputStreamReader(is));
+                line = input.readLine();
+                System.out.println("line = " + line);
+            } finally {
+                try {
+                    if (is != null) {
+                        is.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+                try {
+                    if (input != null) {
+                        input.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+            }
+            if (EXPECTED_RESPONSE.equals(line)) {
+                stat.addStatus(TEST_NAME + testCase, stat.PASS);
+            } else {
+                System.out.println("Wrong response. Expected: "
+                        + EXPECTED_RESPONSE + ", received: " + line);
+                stat.addStatus(TEST_NAME + testCase, stat.FAIL);
+            }
+        }
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/descriptor/beans.xml
new file mode 100644
index 0000000..1d355f8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/descriptor/beans.xml
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<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>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/descriptor/persistence.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/descriptor/persistence.xml
new file mode 100644
index 0000000..2a7b5a0
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/descriptor/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+  <persistence-unit name="pu3" transaction-type="JTA">
+    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+    <jta-data-source>jdbc/__default</jta-data-source>
+    <non-jta-data-source>jdbc/__default</non-jta-data-source>
+    <class>myapp.Department</class>
+    <class>myapp.Employee</class>
+    <properties>
+       <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+       <property name="eclipselink.logging.level" value="INFO"/>
+    </properties>
+  </persistence-unit>
+</persistence>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/beans/TestBeanInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/beans/TestBeanInterface.java
new file mode 100644
index 0000000..29e137a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/beans/TestBeanInterface.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans;
+
+public interface TestBeanInterface {
+    public void m1();
+    public void m2();
+    
+    public String testDatasourceInjection();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/beans/artifacts/Preferred.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/beans/artifacts/Preferred.java
new file mode 100644
index 0000000..b7584c8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/beans/artifacts/Preferred.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Preferred {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/beans/artifacts/TestDatabase.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/beans/artifacts/TestDatabase.java
new file mode 100644
index 0000000..b69ab8e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/beans/artifacts/TestDatabase.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TestDatabase {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/ejb/TestEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/ejb/TestEJB.java
new file mode 100644
index 0000000..4065801
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/ejb/TestEJB.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.ejb;
+
+import javax.ejb.Stateful;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+import test.beans.artifacts.TestDatabase;
+
+@Stateful
+public class TestEJB{
+
+    @Inject
+    @TestDatabase
+    transient EntityManager em;
+
+    public String test() {
+        String s = "";
+        em.isOpen();//use the EM
+        if(em == null) s += "EntityManager injection into TestEJB failed";
+        return s;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/entity/Department.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/entity/Department.java
new file mode 100644
index 0000000..14191ec
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/entity/Department.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.entity;
+
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "DEPARTMENT")
+public class Department implements java.io.Serializable {
+
+    // Instance variables
+    private int id;
+    private String name;
+    private Set<Employee> employees;
+
+    public Department() {
+    }
+
+    public Department(int id, String name) {
+        this.id = id;
+        this.name = name;
+    }
+
+    // ===========================================================
+    // getters and setters for the state fields
+
+    @Id
+    @Column(name = "ID")
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    @Column(name = "NAME")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    // ===========================================================
+    // getters and setters for the association fields
+    @OneToMany(cascade = CascadeType.ALL, mappedBy = "department")
+    public Set<Employee> getEmployees() {
+        return employees;
+    }
+
+    public void setEmployees(Set<Employee> employees) {
+        this.employees = employees;
+    }
+
+    public String toString() {
+        return "Department id=" + getId() + ", Department Name=" + getName();
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/entity/Employee.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/entity/Employee.java
new file mode 100644
index 0000000..a1820e8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/entity/Employee.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+@Entity
+@Table(name = "EMPLOYEE")
+public class Employee implements java.io.Serializable {
+
+    private int id;
+    private String firstName;
+    private String lastName;
+    private Department department;
+
+    public Employee() {
+    }
+
+    public Employee(int id, String firstName, String lastName) {
+        this.id = id;
+        this.firstName = firstName;
+        this.lastName = lastName;
+    }
+
+    public Employee(int id, String firstName, String lastName,
+            Department department) {
+        this.id = id;
+        this.firstName = firstName;
+        this.lastName = lastName;
+        this.department = department;
+    }
+
+    // ===========================================================
+    // getters and setters for the state fields
+    @Id
+    @Column(name = "ID")
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    @Column(name = "FIRSTNAME")
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    @Column(name = "LASTNAME")
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    // ===========================================================
+    // getters and setters for the association fields
+    // @ManyToOne
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "DEPARTMENT_ID")
+    public Department getDepartment() {
+        return department;
+    }
+
+    @Transient
+    public Department getDepartmentNoWeaving() {
+        try {
+            java.lang.reflect.Field f = Employee.class
+                    .getDeclaredField("department");
+            return (Department) f.get(this);
+        } catch (NoSuchFieldException e) {
+            throw new RuntimeException(
+                    "Please change argument to getDeclaredField", e);
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public void setDepartment(Department department) {
+        this.department = department;
+    }
+
+    public String toString() {
+        return "Employee id=" + getId() + ", firstName=" + getFirstName()
+                + ", lastName=" + getLastName() + ", department="
+                + getDepartment();
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/servlet/JPAResourceInjectionServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/servlet/JPAResourceInjectionServlet.java
new file mode 100644
index 0000000..afb7a69
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/servlet/JPAResourceInjectionServlet.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.transaction.UserTransaction;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+import test.beans.artifacts.TestDatabase;
+import test.ejb.TestEJB;
+import test.util.JpaTest;
+
+@WebServlet(name = "mytest", urlPatterns = { "/myurl" })
+public class JPAResourceInjectionServlet extends HttpServlet {
+
+    @PersistenceUnit(unitName = "pu3")
+    private EntityManagerFactory emf;
+
+    @Inject
+    @TestDatabase
+    private EntityManagerFactory emf1;
+
+    private @Resource
+    UserTransaction utx;
+    
+    @Inject
+    TestEJB tbi;
+
+    protected void doGet(HttpServletRequest request,
+            HttpServletResponse response) throws ServletException,
+            IOException {
+        PrintWriter writer = response.getWriter();
+        writer.write("Hello from Servlet 3.0.");
+        String msg = "";
+        System.out.println("JPAResourceInjectionServlet::@PersistenceUnit " +
+        		"CDI EntityManagerFactory=" + emf1);
+
+        EntityManager em = emf1.createEntityManager();
+        System.out.println("JPAResourceInjectionServlet::createEM" +
+        		"EntityManager=" + em);
+        String testcase = request.getParameter("testcase");
+        System.out.println("testcase=" + testcase);
+
+        if (testcase != null) {
+            JpaTest jt = new JpaTest(em, utx);
+            boolean status = false;
+            if ("llinit".equals(testcase)) {
+                status = jt.lazyLoadingInit();
+            } else if ("llfind".equals(testcase)) {
+                status = jt.lazyLoadingByFind(1);
+            } else if ("llquery".equals(testcase)) {
+                status = jt.lazyLoadingByQuery("Carla");
+            } else if ("llinj".equals(testcase)){
+                status = ((tbi != null) && 
+                        (tbi.test().length() == 0));
+            }
+            if (status) {
+                msg += "";// pass
+            } else {
+                msg += (testcase + ":fail");
+            }
+        }
+
+        writer.write(msg + "\n");
+
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/util/JPAResourceProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/util/JPAResourceProducer.java
new file mode 100644
index 0000000..4714b5d
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/util/JPAResourceProducer.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.util;
+
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceUnit;
+
+import test.beans.artifacts.TestDatabase;
+
+@Singleton
+public class JPAResourceProducer {
+    @Produces @PersistenceUnit(unitName="pu3")
+    @TestDatabase 
+    EntityManagerFactory customerDatabasePersistenceUnit;
+
+    @Produces @PersistenceContext(unitName="pu3")
+    @TestDatabase 
+    EntityManager customerDatabasePersistenceContext;
+    
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/util/JpaTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/util/JpaTest.java
new file mode 100644
index 0000000..3d47448
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-passivating-scope/servlet/test/util/JpaTest.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.util;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Query;
+import javax.transaction.UserTransaction;
+
+import test.entity.Department;
+import test.entity.Employee;
+
+public class JpaTest {
+
+    private EntityManager em;
+    private UserTransaction utx;
+
+    private static Department deptRef[] = new Department[2];
+    private static Employee empRef[] = new Employee[5];
+
+    public JpaTest() {
+    }
+
+    public JpaTest(EntityManager em, UserTransaction utx) {
+        this.em = em;
+        this.utx = utx;
+    }
+
+    public boolean lazyLoadingInit() {
+        boolean status = false;
+        System.out.println("-----lazeLoadingInit()---------");
+        try {
+            deptRef[0] = new Department(1, "Engineering");
+            deptRef[1] = new Department(2, "Marketing");
+            utx.begin();
+            em.joinTransaction();
+            for (int i = 0; i < 2; i++) {
+                em.persist(deptRef[i]);
+            }
+            utx.commit();
+
+            empRef[0] = new Employee(1, "Alan", "Frechette", deptRef[0]);
+            empRef[1] = new Employee(2, "Arthur", "Wesley", deptRef[0]);
+            empRef[2] = new Employee(3, "Abe", "White", deptRef[0]);
+            empRef[3] = new Employee(4, "Paul", "Hinz", deptRef[1]);
+            empRef[4] = new Employee(5, "Carla", "Calrson", deptRef[1]);
+            utx.begin();
+            em.joinTransaction();
+            for (int i = 0; i < 5; i++) {
+                em.persist(empRef[i]);
+            }
+            utx.commit();
+            status = true;
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+    public boolean lazyLoadingByFind(int employeeID) {
+
+        boolean status = true;
+        System.out.println("------------lazyLoadingAfterFind -----------");
+        System.out.println("employeeID = " + employeeID);
+        Employee emp = em.find(Employee.class, employeeID);
+
+        System.out.println("found: emp.id=" + emp.getId());
+
+        try {
+            // 1. get Department before loading
+            Department deptBL = emp.getDepartmentNoWeaving();
+            System.out.println("1. before loading: deptBL=" + deptBL);
+            String deptNameBL = null;
+            if (deptBL != null) {
+                deptNameBL = deptBL.getName();
+                System.out.println("deptNameBL=" + deptNameBL);
+            }
+            // assert deptBL == null;
+            if (deptBL != null) {
+                status = false;
+            }
+
+            // 2. loading
+            String deptName = emp.getDepartment().getName();
+            System.out.println("2. loading, deptName = " + deptName);
+
+            // 3. get Department after loading
+            Department deptAL = emp.getDepartmentNoWeaving();
+            System.out.println("3. after loading: deptAL=" + deptAL);
+            String deptNameAL = deptAL.getName();
+            System.out.println("deptNameAL=" + deptNameAL);
+            // assert deptAL != null
+            // assert deptAL.getName == deptName;
+            if (deptAL == null || deptNameAL != deptName) {
+                status = false;
+            }
+        } catch (Exception ex) {
+            status = false;
+            ex.printStackTrace();
+        }
+
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+    public boolean lazyLoadingByQuery(String fName) {
+
+        boolean status = true;
+        System.out.println("------------lazyLoadingByQuery -----------");
+        System.out.println("fName = " + fName);
+        Query query = em.createQuery(
+                "SELECT e FROM Employee e WHERE e.firstName like :firstName")
+                .setParameter("firstName", fName);
+        ;
+        Employee emp = (Employee) query.getSingleResult();
+
+        System.out.println("queried: emp.firstName=" + emp.getFirstName());
+
+        try {
+            // 1. get Department before loading
+            Department deptBL = emp.getDepartmentNoWeaving();
+            System.out.println("1. before loading: deptBL=" + deptBL);
+            String deptNameBL = null;
+            if (deptBL != null) {
+                deptNameBL = deptBL.getName();
+                System.out.println("deptNameBL=" + deptNameBL);
+            }
+            // assert deptBL == null;
+            if (deptBL != null) {
+                status = false;
+            }
+
+            // 2. loading
+            String deptName = emp.getDepartment().getName();
+            System.out.println("2. loading, deptName = " + deptName);
+
+            // 3. get Department after loading
+            Department deptAL = emp.getDepartmentNoWeaving();
+            System.out.println("3. after loading: deptAL=" + deptAL);
+            String deptNameAL = deptAL.getName();
+            System.out.println("deptNameAL=" + deptNameAL);
+            // assert deptAL != null
+            // assert deptAL.getName == deptName;
+            if (deptAL == null || deptNameAL != deptName) {
+                status = false;
+            }
+        } catch (Exception ex) {
+            status = false;
+            ex.printStackTrace();
+        }
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/README
new file mode 100644
index 0000000..0a06178
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/README
@@ -0,0 +1,6 @@
+Test
+- Use of Java EE component environment resources 
+    - type safe injection of JPA resources (EntityManagerFactory, EntityManager) 
+    by declaring a resource through
+        - a static field of a singleton EJB acting as a producer field
+        - a business method in a singleton EJB acting as a producer method 
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/build.properties
new file mode 100644
index 0000000..e2f195c
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/build.properties
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+ 
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-jpa-resource-injection-in-singleton-ejb"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
+<property name="persistence.xml" value="descriptor/persistence.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/build.xml
new file mode 100644
index 0000000..295d086
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/build.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+    &commonSetup;
+    &commonBuild;
+    &testproperties;
+    &run;
+
+    <target name="all" depends="build,create-resources,deploy,run,undeploy,delete-resources" />
+
+	<target name="clean" depends="init-common">
+		<antcall target="clean-common" />
+		<delete>
+			<fileset dir="." includes="*.class" />
+			<fileset dir="client/test/client" includes="*.class" />
+		</delete>
+	</target>
+
+	<target name="compile" depends="clean">
+		<antcall target="compile-common">
+			<param name="src" value="servlet" />
+		</antcall>
+	</target>
+
+	<target name="build" depends="compile">
+		<property name="hasWebclient" value="yes" />
+		<antcall target="webclient-war-common">
+			<param name="hasWebclient" value="yes" />
+			<param name="webclient.war.classes" value="**/*.class" />
+		</antcall>
+
+		<javac srcdir="client" classpath="${env.APS_HOME}/lib/reportbuilder.jar" includes="test/client/WebTest.java" />
+
+	</target>
+
+	<target name="build-publish-war" depends="build, publish-war-common" />
+
+	<target name="deploy" depends="init-common">
+		<antcall target="deploy-war-common" />
+	</target>
+
+	<target name="create-resources" depends="init-common">
+		<antcall target="create-jdbc-connpool-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+		</antcall>
+		<antcall target="create-jdbc-resource-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+			<param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+		</antcall>
+	</target>
+
+
+	<target name="run" depends="init-common">
+		<java classname="test.client.WebTest">
+			<arg value="${http.host}" />
+			<arg value="${http.port}" />
+			<arg value="${contextroot}" />
+			<classpath>
+				<pathelement location="${env.APS_HOME}/lib/reportbuilder.jar" />
+				<pathelement location="client" />
+			</classpath>
+		</java>
+	</target>
+
+	<target name="undeploy" depends="init-common">
+		<antcall target="undeploy-war-common" />
+	</target>
+
+	<target name="delete-resources" depends="init-common">
+		<antcall target="delete-jdbc-resource-common">
+			<param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+		</antcall>
+
+		<antcall target="delete-jdbc-connpool-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+		</antcall>
+	</target>
+
+	<target name="usage">
+		<antcall target="usage-common" />
+	</target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/client/test/client/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/client/test/client/WebTest.java
new file mode 100644
index 0000000..b474733
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/client/test/client/WebTest.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.client;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+    private static SimpleReporterAdapter stat = new SimpleReporterAdapter(
+            "appserv-tests");
+    private static final String TEST_NAME = "jpa-resource-injection-from-singleton-EJB";
+
+    private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0.";
+
+    private String host;
+    private String port;
+    private String contextRoot;
+
+    public WebTest(String[] args) {
+        host = args[0];
+        port = args[1];
+        contextRoot = args[2];
+    }
+
+    public static void main(String[] args) {
+        stat.addDescription("Unit test for Java EE resource injection");
+        WebTest webTest = new WebTest(args);
+        webTest.doTest();
+        stat.printSummary(TEST_NAME);
+    }
+
+    public void doTest() {
+        try {
+            runOneCycle("producer");
+            //TODO: This test fails currently
+            //runOneCycle("static");
+        } catch (Exception ex) {
+            System.out.println(TEST_NAME + " test failed");
+            stat.addStatus(TEST_NAME, stat.FAIL);
+            ex.printStackTrace();
+        }
+    }
+    
+    private void runOneCycle(String whichEMF) throws Exception {
+        invoke(whichEMF, "llinit");
+        invoke(whichEMF, "llquery");
+        invoke(whichEMF,"llfind");
+        invoke(whichEMF,"llinj");
+    }
+
+    private void invoke(String whichEMF, String testCase) throws Exception {
+
+        String url = "http://" + host + ":" + port + contextRoot + "/myurl"
+                + "?testcase=" + testCase + "&whichemf=" + whichEMF;
+        System.out.println("opening connection to " + url);
+        HttpURLConnection conn = (HttpURLConnection) (new URL(url))
+                .openConnection();
+
+        int code = conn.getResponseCode();
+        if (code != 200) {
+            System.out.println("Unexpected return code: " + code);
+            stat.addStatus(getTestName(whichEMF, testCase), stat.FAIL);
+        } else {
+            InputStream is = null;
+            BufferedReader input = null;
+            String line = null;
+            try {
+                is = conn.getInputStream();
+                input = new BufferedReader(new InputStreamReader(is));
+                line = input.readLine();
+                System.out.println("line = " + line);
+            } finally {
+                try {
+                    if (is != null) {
+                        is.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+                try {
+                    if (input != null) {
+                        input.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+            }
+            if (EXPECTED_RESPONSE.equals(line)) {
+                stat.addStatus(getTestName(whichEMF, testCase), stat.PASS);
+            } else {
+                System.out.println("Wrong response. Expected: "
+                        + EXPECTED_RESPONSE + ", received: " + line);
+                stat.addStatus(getTestName(whichEMF, testCase), stat.FAIL);
+            }
+        }
+    }
+    
+    private String getTestName(String whichEMF, String testCase){
+        return TEST_NAME + "_" + whichEMF + "_" +testCase;        
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/descriptor/beans.xml
new file mode 100644
index 0000000..1d355f8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/descriptor/beans.xml
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<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>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/descriptor/persistence.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/descriptor/persistence.xml
new file mode 100644
index 0000000..82f2d7b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/descriptor/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+  <persistence-unit name="pu1" transaction-type="JTA">
+    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+    <jta-data-source>jdbc/__default</jta-data-source>
+    <non-jta-data-source>jdbc/__default</non-jta-data-source>
+    <class>myapp.Department</class>
+    <class>myapp.Employee</class>
+    <properties>
+       <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+       <property name="eclipselink.logging.level" value="INFO"/>
+    </properties>
+  </persistence-unit>
+</persistence>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/beans/TestBeanInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/beans/TestBeanInterface.java
new file mode 100644
index 0000000..29e137a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/beans/TestBeanInterface.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans;
+
+public interface TestBeanInterface {
+    public void m1();
+    public void m2();
+    
+    public String testDatasourceInjection();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/beans/artifacts/Preferred.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/beans/artifacts/Preferred.java
new file mode 100644
index 0000000..b7584c8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/beans/artifacts/Preferred.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Preferred {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/beans/artifacts/ProducedViaProducerMethod.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/beans/artifacts/ProducedViaProducerMethod.java
new file mode 100644
index 0000000..5c60345
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/beans/artifacts/ProducedViaProducerMethod.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ProducedViaProducerMethod {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/beans/artifacts/ProducedViaStaticField.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/beans/artifacts/ProducedViaStaticField.java
new file mode 100644
index 0000000..e988e7e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/beans/artifacts/ProducedViaStaticField.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ProducedViaStaticField {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/beans/artifacts/TestDatabase.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/beans/artifacts/TestDatabase.java
new file mode 100644
index 0000000..b69ab8e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/beans/artifacts/TestDatabase.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TestDatabase {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/beans/nonmock/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/beans/nonmock/TestBean.java
new file mode 100644
index 0000000..f61ec1b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/beans/nonmock/TestBean.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManagerFactory;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+import test.beans.artifacts.ProducedViaProducerMethod;
+import test.beans.artifacts.ProducedViaStaticField;
+import test.beans.artifacts.TestDatabase;
+
+
+@RequestScoped
+@Preferred
+public class TestBean implements TestBeanInterface{
+    public static boolean testBeanInvoked = false;
+    
+    @Inject @ProducedViaProducerMethod 
+    EntityManagerFactory emf;
+
+    @Override
+    public void m1() {
+        testBeanInvoked = true;
+        System.out.println("TestBean::m1 called");
+    }
+
+    @Override
+    public void m2() {
+        System.out.println("TestBean::m2 called");
+    }
+
+    @Override
+    public String testDatasourceInjection() {
+        return (emf==null ? "typesafe injection into testbean failed" : "");
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/ejb/JPAResourceProducerSingletonEJB_BusinessMethodProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/ejb/JPAResourceProducerSingletonEJB_BusinessMethodProducer.java
new file mode 100644
index 0000000..b20fae4
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/ejb/JPAResourceProducerSingletonEJB_BusinessMethodProducer.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.ejb;
+
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+
+import test.beans.artifacts.ProducedViaProducerMethod;
+import test.beans.artifacts.ProducedViaStaticField;
+
+@javax.ejb.Singleton
+public class JPAResourceProducerSingletonEJB_BusinessMethodProducer {
+    @PersistenceUnit(unitName="pu1")
+    EntityManagerFactory customerDatabasePersistenceUnit;
+    
+    @Produces @ProducedViaProducerMethod
+    public EntityManagerFactory createEMF(){
+        return customerDatabasePersistenceUnit;
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/ejb/JPAResourceProducerSingletonEJB_StaticField.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/ejb/JPAResourceProducerSingletonEJB_StaticField.java
new file mode 100644
index 0000000..adbca7b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/ejb/JPAResourceProducerSingletonEJB_StaticField.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.ejb;
+
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+
+import test.beans.artifacts.ProducedViaStaticField;
+
+@javax.ejb.Singleton
+public class JPAResourceProducerSingletonEJB_StaticField {
+    @Produces @PersistenceUnit(unitName="pu1") @ProducedViaStaticField 
+    public static EntityManagerFactory customerDatabasePersistenceUnit1;
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/entity/Department.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/entity/Department.java
new file mode 100644
index 0000000..14191ec
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/entity/Department.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.entity;
+
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "DEPARTMENT")
+public class Department implements java.io.Serializable {
+
+    // Instance variables
+    private int id;
+    private String name;
+    private Set<Employee> employees;
+
+    public Department() {
+    }
+
+    public Department(int id, String name) {
+        this.id = id;
+        this.name = name;
+    }
+
+    // ===========================================================
+    // getters and setters for the state fields
+
+    @Id
+    @Column(name = "ID")
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    @Column(name = "NAME")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    // ===========================================================
+    // getters and setters for the association fields
+    @OneToMany(cascade = CascadeType.ALL, mappedBy = "department")
+    public Set<Employee> getEmployees() {
+        return employees;
+    }
+
+    public void setEmployees(Set<Employee> employees) {
+        this.employees = employees;
+    }
+
+    public String toString() {
+        return "Department id=" + getId() + ", Department Name=" + getName();
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/entity/Employee.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/entity/Employee.java
new file mode 100644
index 0000000..a1820e8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/entity/Employee.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+@Entity
+@Table(name = "EMPLOYEE")
+public class Employee implements java.io.Serializable {
+
+    private int id;
+    private String firstName;
+    private String lastName;
+    private Department department;
+
+    public Employee() {
+    }
+
+    public Employee(int id, String firstName, String lastName) {
+        this.id = id;
+        this.firstName = firstName;
+        this.lastName = lastName;
+    }
+
+    public Employee(int id, String firstName, String lastName,
+            Department department) {
+        this.id = id;
+        this.firstName = firstName;
+        this.lastName = lastName;
+        this.department = department;
+    }
+
+    // ===========================================================
+    // getters and setters for the state fields
+    @Id
+    @Column(name = "ID")
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    @Column(name = "FIRSTNAME")
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    @Column(name = "LASTNAME")
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    // ===========================================================
+    // getters and setters for the association fields
+    // @ManyToOne
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "DEPARTMENT_ID")
+    public Department getDepartment() {
+        return department;
+    }
+
+    @Transient
+    public Department getDepartmentNoWeaving() {
+        try {
+            java.lang.reflect.Field f = Employee.class
+                    .getDeclaredField("department");
+            return (Department) f.get(this);
+        } catch (NoSuchFieldException e) {
+            throw new RuntimeException(
+                    "Please change argument to getDeclaredField", e);
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public void setDepartment(Department department) {
+        this.department = department;
+    }
+
+    public String toString() {
+        return "Employee id=" + getId() + ", firstName=" + getFirstName()
+                + ", lastName=" + getLastName() + ", department="
+                + getDepartment();
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/servlet/JPAResourceInjectionServletFromSingletonEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/servlet/JPAResourceInjectionServletFromSingletonEJB.java
new file mode 100644
index 0000000..96167f7
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/servlet/JPAResourceInjectionServletFromSingletonEJB.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.transaction.UserTransaction;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+import test.beans.artifacts.ProducedViaProducerMethod;
+import test.beans.artifacts.ProducedViaStaticField;
+import test.util.JpaTest;
+
+@WebServlet(name = "mytest", urlPatterns = { "/myurl" })
+public class JPAResourceInjectionServletFromSingletonEJB extends HttpServlet {
+
+    @PersistenceUnit(unitName = "pu1")
+    private EntityManagerFactory emf;
+
+    @Inject
+    @ProducedViaProducerMethod
+    private EntityManagerFactory emf_producer;
+    
+    @Inject
+    @ProducedViaStaticField
+    private EntityManagerFactory emf_static;
+    
+
+    private @Resource
+    UserTransaction utx;
+    
+    @Inject
+    @Preferred
+    TestBeanInterface tbi;
+
+    protected void doGet(HttpServletRequest request,
+            HttpServletResponse response) throws ServletException,
+            IOException {
+        PrintWriter writer = response.getWriter();
+        writer.write("Hello from Servlet 3.0.");
+        String msg = "";
+        
+        if (emf == null)
+            msg += "Simple injection of EntityManagerFactory through " +
+            		"@PersistenceUnit failed";
+        String testcase = request.getParameter("testcase");
+        System.out.println("testcase=" + testcase);
+        
+        String whichEMF = request.getParameter("whichemf");
+        System.out.println("whichEMF=" + whichEMF);
+
+        EntityManager em = null;
+        if (whichEMF != null){
+            EntityManagerFactory emf = null;
+            if (whichEMF.equals("producer")){
+                emf = emf_producer;
+            } else if (whichEMF.equals("static")) {
+                emf = emf_static;
+            }
+            //System.out.println("JPAResourceInjectionServlet::@PersistenceUnit " +
+            //        "CDI EntityManagerFactory to run against=" + emf);
+            em = emf.createEntityManager();
+            System.out.println("JPAResourceInjectionServlet::createEM" +
+                    "EntityManager=" + em);
+        }
+        
+        if (testcase != null) {
+            
+            JpaTest jt = new JpaTest(em, utx);
+            boolean status = false;
+            if ("llinit".equals(testcase)) {
+                status = jt.lazyLoadingInit();
+            } else if ("llfind".equals(testcase)) {
+                status = jt.lazyLoadingByFind(1);
+            } else if ("llquery".equals(testcase)) {
+                status = jt.lazyLoadingByQuery("Carla");
+            } else if ("llinj".equals(testcase)){
+                status = ((tbi != null) && 
+                        (tbi.testDatasourceInjection().trim().length()==0));
+            }
+            
+            if (status) {
+                msg += "";// pass
+            } else {
+                msg += (testcase + ":fail");
+            }
+        }
+
+        writer.write(msg + "\n");
+
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/util/JpaTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/util/JpaTest.java
new file mode 100644
index 0000000..3d47448
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/servlet/test/util/JpaTest.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.util;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Query;
+import javax.transaction.UserTransaction;
+
+import test.entity.Department;
+import test.entity.Employee;
+
+public class JpaTest {
+
+    private EntityManager em;
+    private UserTransaction utx;
+
+    private static Department deptRef[] = new Department[2];
+    private static Employee empRef[] = new Employee[5];
+
+    public JpaTest() {
+    }
+
+    public JpaTest(EntityManager em, UserTransaction utx) {
+        this.em = em;
+        this.utx = utx;
+    }
+
+    public boolean lazyLoadingInit() {
+        boolean status = false;
+        System.out.println("-----lazeLoadingInit()---------");
+        try {
+            deptRef[0] = new Department(1, "Engineering");
+            deptRef[1] = new Department(2, "Marketing");
+            utx.begin();
+            em.joinTransaction();
+            for (int i = 0; i < 2; i++) {
+                em.persist(deptRef[i]);
+            }
+            utx.commit();
+
+            empRef[0] = new Employee(1, "Alan", "Frechette", deptRef[0]);
+            empRef[1] = new Employee(2, "Arthur", "Wesley", deptRef[0]);
+            empRef[2] = new Employee(3, "Abe", "White", deptRef[0]);
+            empRef[3] = new Employee(4, "Paul", "Hinz", deptRef[1]);
+            empRef[4] = new Employee(5, "Carla", "Calrson", deptRef[1]);
+            utx.begin();
+            em.joinTransaction();
+            for (int i = 0; i < 5; i++) {
+                em.persist(empRef[i]);
+            }
+            utx.commit();
+            status = true;
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+    public boolean lazyLoadingByFind(int employeeID) {
+
+        boolean status = true;
+        System.out.println("------------lazyLoadingAfterFind -----------");
+        System.out.println("employeeID = " + employeeID);
+        Employee emp = em.find(Employee.class, employeeID);
+
+        System.out.println("found: emp.id=" + emp.getId());
+
+        try {
+            // 1. get Department before loading
+            Department deptBL = emp.getDepartmentNoWeaving();
+            System.out.println("1. before loading: deptBL=" + deptBL);
+            String deptNameBL = null;
+            if (deptBL != null) {
+                deptNameBL = deptBL.getName();
+                System.out.println("deptNameBL=" + deptNameBL);
+            }
+            // assert deptBL == null;
+            if (deptBL != null) {
+                status = false;
+            }
+
+            // 2. loading
+            String deptName = emp.getDepartment().getName();
+            System.out.println("2. loading, deptName = " + deptName);
+
+            // 3. get Department after loading
+            Department deptAL = emp.getDepartmentNoWeaving();
+            System.out.println("3. after loading: deptAL=" + deptAL);
+            String deptNameAL = deptAL.getName();
+            System.out.println("deptNameAL=" + deptNameAL);
+            // assert deptAL != null
+            // assert deptAL.getName == deptName;
+            if (deptAL == null || deptNameAL != deptName) {
+                status = false;
+            }
+        } catch (Exception ex) {
+            status = false;
+            ex.printStackTrace();
+        }
+
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+    public boolean lazyLoadingByQuery(String fName) {
+
+        boolean status = true;
+        System.out.println("------------lazyLoadingByQuery -----------");
+        System.out.println("fName = " + fName);
+        Query query = em.createQuery(
+                "SELECT e FROM Employee e WHERE e.firstName like :firstName")
+                .setParameter("firstName", fName);
+        ;
+        Employee emp = (Employee) query.getSingleResult();
+
+        System.out.println("queried: emp.firstName=" + emp.getFirstName());
+
+        try {
+            // 1. get Department before loading
+            Department deptBL = emp.getDepartmentNoWeaving();
+            System.out.println("1. before loading: deptBL=" + deptBL);
+            String deptNameBL = null;
+            if (deptBL != null) {
+                deptNameBL = deptBL.getName();
+                System.out.println("deptNameBL=" + deptNameBL);
+            }
+            // assert deptBL == null;
+            if (deptBL != null) {
+                status = false;
+            }
+
+            // 2. loading
+            String deptName = emp.getDepartment().getName();
+            System.out.println("2. loading, deptName = " + deptName);
+
+            // 3. get Department after loading
+            Department deptAL = emp.getDepartmentNoWeaving();
+            System.out.println("3. after loading: deptAL=" + deptAL);
+            String deptNameAL = deptAL.getName();
+            System.out.println("deptNameAL=" + deptNameAL);
+            // assert deptAL != null
+            // assert deptAL.getName == deptName;
+            if (deptAL == null || deptNameAL != deptName) {
+                status = false;
+            }
+        } catch (Exception ex) {
+            status = false;
+            ex.printStackTrace();
+        }
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/README
new file mode 100644
index 0000000..d620428
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/README
@@ -0,0 +1,5 @@
+Test
+- Use of Java EE component environment resources 
+    - type safe injection of JPA resources (EntityManagerFactory, EntityManager) 
+    by declaring a resource by annotating a producer field wuth a 
+    component environment injection annotation
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/build.properties
new file mode 100644
index 0000000..168fae7
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/build.properties
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+ 
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-jpa-resource-injection"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
+<property name="persistence.xml" value="descriptor/persistence.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/build.xml
new file mode 100644
index 0000000..295d086
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/build.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+    &commonSetup;
+    &commonBuild;
+    &testproperties;
+    &run;
+
+    <target name="all" depends="build,create-resources,deploy,run,undeploy,delete-resources" />
+
+	<target name="clean" depends="init-common">
+		<antcall target="clean-common" />
+		<delete>
+			<fileset dir="." includes="*.class" />
+			<fileset dir="client/test/client" includes="*.class" />
+		</delete>
+	</target>
+
+	<target name="compile" depends="clean">
+		<antcall target="compile-common">
+			<param name="src" value="servlet" />
+		</antcall>
+	</target>
+
+	<target name="build" depends="compile">
+		<property name="hasWebclient" value="yes" />
+		<antcall target="webclient-war-common">
+			<param name="hasWebclient" value="yes" />
+			<param name="webclient.war.classes" value="**/*.class" />
+		</antcall>
+
+		<javac srcdir="client" classpath="${env.APS_HOME}/lib/reportbuilder.jar" includes="test/client/WebTest.java" />
+
+	</target>
+
+	<target name="build-publish-war" depends="build, publish-war-common" />
+
+	<target name="deploy" depends="init-common">
+		<antcall target="deploy-war-common" />
+	</target>
+
+	<target name="create-resources" depends="init-common">
+		<antcall target="create-jdbc-connpool-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+		</antcall>
+		<antcall target="create-jdbc-resource-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+			<param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+		</antcall>
+	</target>
+
+
+	<target name="run" depends="init-common">
+		<java classname="test.client.WebTest">
+			<arg value="${http.host}" />
+			<arg value="${http.port}" />
+			<arg value="${contextroot}" />
+			<classpath>
+				<pathelement location="${env.APS_HOME}/lib/reportbuilder.jar" />
+				<pathelement location="client" />
+			</classpath>
+		</java>
+	</target>
+
+	<target name="undeploy" depends="init-common">
+		<antcall target="undeploy-war-common" />
+	</target>
+
+	<target name="delete-resources" depends="init-common">
+		<antcall target="delete-jdbc-resource-common">
+			<param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+		</antcall>
+
+		<antcall target="delete-jdbc-connpool-common">
+			<param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+		</antcall>
+	</target>
+
+	<target name="usage">
+		<antcall target="usage-common" />
+	</target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/client/test/client/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/client/test/client/WebTest.java
new file mode 100644
index 0000000..1cde8c0
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/client/test/client/WebTest.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.client;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+    private static SimpleReporterAdapter stat = new SimpleReporterAdapter(
+            "appserv-tests");
+    private static final String TEST_NAME = "jpa-resource-injection";
+
+    private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0.";
+
+    private String host;
+    private String port;
+    private String contextRoot;
+
+    public WebTest(String[] args) {
+        host = args[0];
+        port = args[1];
+        contextRoot = args[2];
+    }
+
+    public static void main(String[] args) {
+        stat.addDescription("Unit test for Java EE resource injection");
+        WebTest webTest = new WebTest(args);
+        webTest.doTest();
+        stat.printSummary(TEST_NAME);
+    }
+
+    public void doTest() {
+        try {
+            invoke("llinit");
+            invoke("llquery");
+            invoke("llfind");
+            invoke("llinj");
+        } catch (Exception ex) {
+            System.out.println(TEST_NAME + " test failed");
+            stat.addStatus(TEST_NAME, stat.FAIL);
+            ex.printStackTrace();
+        }
+    }
+
+    private void invoke(String testCase) throws Exception {
+
+        String url = "http://" + host + ":" + port + contextRoot + "/myurl"
+                + "?testcase=" + testCase;
+        System.out.println("opening connection to " + url);
+        HttpURLConnection conn = (HttpURLConnection) (new URL(url))
+                .openConnection();
+
+        int code = conn.getResponseCode();
+        if (code != 200) {
+            System.out.println("Unexpected return code: " + code);
+            stat.addStatus(TEST_NAME + testCase, stat.FAIL);
+        } else {
+            InputStream is = null;
+            BufferedReader input = null;
+            String line = null;
+            try {
+                is = conn.getInputStream();
+                input = new BufferedReader(new InputStreamReader(is));
+                line = input.readLine();
+                System.out.println("line = " + line);
+            } finally {
+                try {
+                    if (is != null) {
+                        is.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+                try {
+                    if (input != null) {
+                        input.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+            }
+            if (EXPECTED_RESPONSE.equals(line)) {
+                stat.addStatus(TEST_NAME + testCase, stat.PASS);
+            } else {
+                System.out.println("Wrong response. Expected: "
+                        + EXPECTED_RESPONSE + ", received: " + line);
+                stat.addStatus(TEST_NAME + testCase, stat.FAIL);
+            }
+        }
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/descriptor/beans.xml
new file mode 100644
index 0000000..1d355f8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/descriptor/beans.xml
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<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>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/descriptor/persistence.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/descriptor/persistence.xml
new file mode 100644
index 0000000..82f2d7b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/descriptor/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+  <persistence-unit name="pu1" transaction-type="JTA">
+    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+    <jta-data-source>jdbc/__default</jta-data-source>
+    <non-jta-data-source>jdbc/__default</non-jta-data-source>
+    <class>myapp.Department</class>
+    <class>myapp.Employee</class>
+    <properties>
+       <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+       <property name="eclipselink.logging.level" value="INFO"/>
+    </properties>
+  </persistence-unit>
+</persistence>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/beans/TestBeanInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/beans/TestBeanInterface.java
new file mode 100644
index 0000000..29e137a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/beans/TestBeanInterface.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans;
+
+public interface TestBeanInterface {
+    public void m1();
+    public void m2();
+    
+    public String testDatasourceInjection();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/beans/artifacts/Preferred.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/beans/artifacts/Preferred.java
new file mode 100644
index 0000000..b7584c8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/beans/artifacts/Preferred.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Preferred {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/beans/artifacts/TestDatabase.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/beans/artifacts/TestDatabase.java
new file mode 100644
index 0000000..b69ab8e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/beans/artifacts/TestDatabase.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TestDatabase {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/beans/nonmock/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/beans/nonmock/TestBean.java
new file mode 100644
index 0000000..4fe1ded
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/beans/nonmock/TestBean.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManagerFactory;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+import test.beans.artifacts.TestDatabase;
+
+
+@RequestScoped
+@Preferred
+public class TestBean implements TestBeanInterface{
+    public static boolean testBeanInvoked = false;
+    
+    @Inject @TestDatabase 
+    EntityManagerFactory emf;
+
+    @Override
+    public void m1() {
+        testBeanInvoked = true;
+        System.out.println("TestBean::m1 called");
+    }
+
+    @Override
+    public void m2() {
+        System.out.println("TestBean::m2 called");
+    }
+
+    @Override
+    public String testDatasourceInjection() {
+        return (emf==null ? "typesafe injection into testbean failed" : "");
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/entity/Department.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/entity/Department.java
new file mode 100644
index 0000000..14191ec
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/entity/Department.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.entity;
+
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "DEPARTMENT")
+public class Department implements java.io.Serializable {
+
+    // Instance variables
+    private int id;
+    private String name;
+    private Set<Employee> employees;
+
+    public Department() {
+    }
+
+    public Department(int id, String name) {
+        this.id = id;
+        this.name = name;
+    }
+
+    // ===========================================================
+    // getters and setters for the state fields
+
+    @Id
+    @Column(name = "ID")
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    @Column(name = "NAME")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    // ===========================================================
+    // getters and setters for the association fields
+    @OneToMany(cascade = CascadeType.ALL, mappedBy = "department")
+    public Set<Employee> getEmployees() {
+        return employees;
+    }
+
+    public void setEmployees(Set<Employee> employees) {
+        this.employees = employees;
+    }
+
+    public String toString() {
+        return "Department id=" + getId() + ", Department Name=" + getName();
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/entity/Employee.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/entity/Employee.java
new file mode 100644
index 0000000..a1820e8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/entity/Employee.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+@Entity
+@Table(name = "EMPLOYEE")
+public class Employee implements java.io.Serializable {
+
+    private int id;
+    private String firstName;
+    private String lastName;
+    private Department department;
+
+    public Employee() {
+    }
+
+    public Employee(int id, String firstName, String lastName) {
+        this.id = id;
+        this.firstName = firstName;
+        this.lastName = lastName;
+    }
+
+    public Employee(int id, String firstName, String lastName,
+            Department department) {
+        this.id = id;
+        this.firstName = firstName;
+        this.lastName = lastName;
+        this.department = department;
+    }
+
+    // ===========================================================
+    // getters and setters for the state fields
+    @Id
+    @Column(name = "ID")
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    @Column(name = "FIRSTNAME")
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    @Column(name = "LASTNAME")
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    // ===========================================================
+    // getters and setters for the association fields
+    // @ManyToOne
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "DEPARTMENT_ID")
+    public Department getDepartment() {
+        return department;
+    }
+
+    @Transient
+    public Department getDepartmentNoWeaving() {
+        try {
+            java.lang.reflect.Field f = Employee.class
+                    .getDeclaredField("department");
+            return (Department) f.get(this);
+        } catch (NoSuchFieldException e) {
+            throw new RuntimeException(
+                    "Please change argument to getDeclaredField", e);
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public void setDepartment(Department department) {
+        this.department = department;
+    }
+
+    public String toString() {
+        return "Employee id=" + getId() + ", firstName=" + getFirstName()
+                + ", lastName=" + getLastName() + ", department="
+                + getDepartment();
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/servlet/JPAResourceInjectionServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/servlet/JPAResourceInjectionServlet.java
new file mode 100644
index 0000000..e00446b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/servlet/JPAResourceInjectionServlet.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.transaction.UserTransaction;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+import test.beans.artifacts.TestDatabase;
+import test.util.JpaTest;
+
+@WebServlet(name = "mytest", urlPatterns = { "/myurl" })
+public class JPAResourceInjectionServlet extends HttpServlet {
+
+    @PersistenceUnit(unitName = "pu1")
+    private EntityManagerFactory emf;
+
+    @Inject
+    @TestDatabase
+    private EntityManagerFactory emf1;
+
+    private @Resource
+    UserTransaction utx;
+    
+    @Inject
+    @Preferred
+    TestBeanInterface tbi;
+
+    protected void doGet(HttpServletRequest request,
+            HttpServletResponse response) throws ServletException,
+            IOException {
+        PrintWriter writer = response.getWriter();
+        writer.write("Hello from Servlet 3.0.");
+        String msg = "";
+        System.out.println("JPAResourceInjectionServlet::@PersistenceUnit " +
+        		"CDI EntityManagerFactory=" + emf1);
+
+        EntityManager em = emf1.createEntityManager();
+        System.out.println("JPAResourceInjectionServlet::createEM" +
+        		"EntityManager=" + em);
+        String testcase = request.getParameter("testcase");
+        System.out.println("testcase=" + testcase);
+
+        if (testcase != null) {
+            JpaTest jt = new JpaTest(em, utx);
+            boolean status = false;
+            if ("llinit".equals(testcase)) {
+                status = jt.lazyLoadingInit();
+            } else if ("llfind".equals(testcase)) {
+                status = jt.lazyLoadingByFind(1);
+            } else if ("llquery".equals(testcase)) {
+                status = jt.lazyLoadingByQuery("Carla");
+            } else if ("llinj".equals(testcase)){
+                status = ((tbi != null) && 
+                        (tbi.testDatasourceInjection().trim().length()==0));
+            }
+            if (status) {
+                msg += "";// pass
+            } else {
+                msg += (testcase + ":fail");
+            }
+        }
+
+        writer.write(msg + "\n");
+
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/util/JPAResourceProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/util/JPAResourceProducer.java
new file mode 100644
index 0000000..cf38fab
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/util/JPAResourceProducer.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.util;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Singleton;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+
+import test.beans.artifacts.TestDatabase;
+
+@Singleton
+public class JPAResourceProducer {
+    @Produces @PersistenceUnit(unitName="pu1")
+    @TestDatabase 
+    EntityManagerFactory customerDatabasePersistenceUnit;
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/util/JpaTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/util/JpaTest.java
new file mode 100644
index 0000000..3d47448
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection/servlet/test/util/JpaTest.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.util;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Query;
+import javax.transaction.UserTransaction;
+
+import test.entity.Department;
+import test.entity.Employee;
+
+public class JpaTest {
+
+    private EntityManager em;
+    private UserTransaction utx;
+
+    private static Department deptRef[] = new Department[2];
+    private static Employee empRef[] = new Employee[5];
+
+    public JpaTest() {
+    }
+
+    public JpaTest(EntityManager em, UserTransaction utx) {
+        this.em = em;
+        this.utx = utx;
+    }
+
+    public boolean lazyLoadingInit() {
+        boolean status = false;
+        System.out.println("-----lazeLoadingInit()---------");
+        try {
+            deptRef[0] = new Department(1, "Engineering");
+            deptRef[1] = new Department(2, "Marketing");
+            utx.begin();
+            em.joinTransaction();
+            for (int i = 0; i < 2; i++) {
+                em.persist(deptRef[i]);
+            }
+            utx.commit();
+
+            empRef[0] = new Employee(1, "Alan", "Frechette", deptRef[0]);
+            empRef[1] = new Employee(2, "Arthur", "Wesley", deptRef[0]);
+            empRef[2] = new Employee(3, "Abe", "White", deptRef[0]);
+            empRef[3] = new Employee(4, "Paul", "Hinz", deptRef[1]);
+            empRef[4] = new Employee(5, "Carla", "Calrson", deptRef[1]);
+            utx.begin();
+            em.joinTransaction();
+            for (int i = 0; i < 5; i++) {
+                em.persist(empRef[i]);
+            }
+            utx.commit();
+            status = true;
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+    public boolean lazyLoadingByFind(int employeeID) {
+
+        boolean status = true;
+        System.out.println("------------lazyLoadingAfterFind -----------");
+        System.out.println("employeeID = " + employeeID);
+        Employee emp = em.find(Employee.class, employeeID);
+
+        System.out.println("found: emp.id=" + emp.getId());
+
+        try {
+            // 1. get Department before loading
+            Department deptBL = emp.getDepartmentNoWeaving();
+            System.out.println("1. before loading: deptBL=" + deptBL);
+            String deptNameBL = null;
+            if (deptBL != null) {
+                deptNameBL = deptBL.getName();
+                System.out.println("deptNameBL=" + deptNameBL);
+            }
+            // assert deptBL == null;
+            if (deptBL != null) {
+                status = false;
+            }
+
+            // 2. loading
+            String deptName = emp.getDepartment().getName();
+            System.out.println("2. loading, deptName = " + deptName);
+
+            // 3. get Department after loading
+            Department deptAL = emp.getDepartmentNoWeaving();
+            System.out.println("3. after loading: deptAL=" + deptAL);
+            String deptNameAL = deptAL.getName();
+            System.out.println("deptNameAL=" + deptNameAL);
+            // assert deptAL != null
+            // assert deptAL.getName == deptName;
+            if (deptAL == null || deptNameAL != deptName) {
+                status = false;
+            }
+        } catch (Exception ex) {
+            status = false;
+            ex.printStackTrace();
+        }
+
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+    public boolean lazyLoadingByQuery(String fName) {
+
+        boolean status = true;
+        System.out.println("------------lazyLoadingByQuery -----------");
+        System.out.println("fName = " + fName);
+        Query query = em.createQuery(
+                "SELECT e FROM Employee e WHERE e.firstName like :firstName")
+                .setParameter("firstName", fName);
+        ;
+        Employee emp = (Employee) query.getSingleResult();
+
+        System.out.println("queried: emp.firstName=" + emp.getFirstName());
+
+        try {
+            // 1. get Department before loading
+            Department deptBL = emp.getDepartmentNoWeaving();
+            System.out.println("1. before loading: deptBL=" + deptBL);
+            String deptNameBL = null;
+            if (deptBL != null) {
+                deptNameBL = deptBL.getName();
+                System.out.println("deptNameBL=" + deptNameBL);
+            }
+            // assert deptBL == null;
+            if (deptBL != null) {
+                status = false;
+            }
+
+            // 2. loading
+            String deptName = emp.getDepartment().getName();
+            System.out.println("2. loading, deptName = " + deptName);
+
+            // 3. get Department after loading
+            Department deptAL = emp.getDepartmentNoWeaving();
+            System.out.println("3. after loading: deptAL=" + deptAL);
+            String deptNameAL = deptAL.getName();
+            System.out.println("deptNameAL=" + deptNameAL);
+            // assert deptAL != null
+            // assert deptAL.getName == deptName;
+            if (deptAL == null || deptNameAL != deptName) {
+                status = false;
+            }
+        } catch (Exception ex) {
+            status = false;
+            ex.printStackTrace();
+        }
+        System.out.println("-----status = " + status + "---------");
+        return status;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/README
new file mode 100644
index 0000000..098e4ae
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/README
@@ -0,0 +1,5 @@
+Test
+- Injection of a no-interface bean in a request-scoped model via @Inject 
+and @EJB and invocation of methods defined in the EJB class and 
+in a super-class of the EJB
+- glassfish issue 13040
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/build.properties
new file mode 100644
index 0000000..5b8ba11
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/build.properties
@@ -0,0 +1,24 @@
+<!--
+
+    Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+ 
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-no-interface-ejb"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/build.xml
new file mode 100644
index 0000000..a0e6a9d
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/build.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+    &commonSetup;
+    &commonBuild;
+    &testproperties;
+    &run;
+
+    <target name="all" depends="build,deploy,run,undeploy" />
+
+	<target name="clean" depends="init-common">
+		<antcall target="clean-common" />
+		<delete>
+			<fileset dir="." includes="*.class" />
+			<fileset dir="client/test/client" includes="*.class" />
+		</delete>
+	</target>
+
+	<target name="compile" depends="clean">
+		<antcall target="compile-common">
+			<param name="src" value="servlet" />
+		</antcall>
+	</target>
+
+	<target name="build" depends="compile">
+		<property name="hasWebclient" value="yes" />
+		<antcall target="webclient-war-common">
+			<param name="hasWebclient" value="yes" />
+			<param name="webclient.war.classes" value="**/*.class" />
+		</antcall>
+
+		<javac srcdir="client" classpath="${env.APS_HOME}/lib/reportbuilder.jar" includes="test/client/WebTest.java" />
+
+	</target>
+
+	<target name="build-publish-war" depends="build, publish-war-common" />
+
+	<target name="deploy" depends="init-common">
+		<antcall target="deploy-war-common" />
+	</target>
+
+	<target name="run" depends="init-common">
+		<java classname="test.client.WebTest">
+			<arg value="${http.host}" />
+			<arg value="${http.port}" />
+			<arg value="${contextroot}" />
+			<classpath>
+				<pathelement location="${env.APS_HOME}/lib/reportbuilder.jar" />
+				<pathelement location="client" />
+			</classpath>
+		</java>
+	</target>
+
+	<target name="undeploy" depends="init-common">
+		<antcall target="undeploy-war-common" />
+	</target>
+
+	<target name="usage">
+		<antcall target="usage-common" />
+	</target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/client/test/client/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/client/test/client/WebTest.java
new file mode 100644
index 0000000..e775694
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/client/test/client/WebTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.client;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+    private static SimpleReporterAdapter stat = new SimpleReporterAdapter(
+            "appserv-tests");
+    private static final String TEST_NAME = "injection-of-no-interface-bean-view-and-EJB-with-local-view";
+
+    private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0.";
+
+    private String host;
+    private String port;
+    private String contextRoot;
+
+    public WebTest(String[] args) {
+        host = args[0];
+        port = args[1];
+        contextRoot = args[2];
+    }
+
+    public static void main(String[] args) {
+        stat.addDescription("Unit test for Java EE resource injection");
+        WebTest webTest = new WebTest(args);
+        webTest.doTest();
+        stat.printSummary(TEST_NAME);
+    }
+
+    public void doTest() {
+        try {
+            invoke();
+        } catch (Exception ex) {
+            System.out.println(TEST_NAME + " test failed");
+            stat.addStatus(TEST_NAME, stat.FAIL);
+            ex.printStackTrace();
+        }
+    }
+
+    private void invoke() throws Exception {
+
+        String url = "http://" + host + ":" + port + contextRoot + "/myurl";
+        System.out.println("opening connection to " + url);
+        HttpURLConnection conn = (HttpURLConnection) (new URL(url))
+                .openConnection();
+
+        int code = conn.getResponseCode();
+        if (code != 200) {
+            System.out.println("Unexpected return code: " + code);
+            stat.addStatus(TEST_NAME, stat.FAIL);
+        } else {
+            InputStream is = null;
+            BufferedReader input = null;
+            String line = null;
+            try {
+                is = conn.getInputStream();
+                input = new BufferedReader(new InputStreamReader(is));
+                line = input.readLine();
+                System.out.println("line = " + line);
+            } finally {
+                try {
+                    if (is != null) {
+                        is.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+                try {
+                    if (input != null) {
+                        input.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+            }
+            if (EXPECTED_RESPONSE.equals(line)) {
+                stat.addStatus(TEST_NAME, stat.PASS);
+            } else {
+                System.out.println("Wrong response. Expected: "
+                        + EXPECTED_RESPONSE + ", received: " + line);
+                stat.addStatus(TEST_NAME, stat.FAIL);
+            }
+        }
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/descriptor/beans.xml
new file mode 100644
index 0000000..1d355f8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/descriptor/beans.xml
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<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>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/descriptor/persistence.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/descriptor/persistence.xml
new file mode 100644
index 0000000..82f2d7b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/descriptor/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+  <persistence-unit name="pu1" transaction-type="JTA">
+    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+    <jta-data-source>jdbc/__default</jta-data-source>
+    <non-jta-data-source>jdbc/__default</non-jta-data-source>
+    <class>myapp.Department</class>
+    <class>myapp.Employee</class>
+    <properties>
+       <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+       <property name="eclipselink.logging.level" value="INFO"/>
+    </properties>
+  </persistence-unit>
+</persistence>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/TestBeanInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/TestBeanInterface.java
new file mode 100644
index 0000000..cf49083
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/TestBeanInterface.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans;
+
+public interface TestBeanInterface {
+    public String runTests();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/InjectViaAtEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/InjectViaAtEJB.java
new file mode 100644
index 0000000..594448d
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/InjectViaAtEJB.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface InjectViaAtEJB {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/InjectViaAtInject.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/InjectViaAtInject.java
new file mode 100644
index 0000000..8e11c88
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/InjectViaAtInject.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface InjectViaAtInject {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/LocalEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/LocalEJB.java
new file mode 100644
index 0000000..04bb97c
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/LocalEJB.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface LocalEJB {
+}
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/NoInterfaceBeanView.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/NoInterfaceBeanView.java
new file mode 100644
index 0000000..6e95330
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/NoInterfaceBeanView.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface NoInterfaceBeanView {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/local/TestBeanSuper.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/local/TestBeanSuper.java
new file mode 100644
index 0000000..a95c06e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/local/TestBeanSuper.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock.local;
+
+import test.beans.TestBeanInterface;
+import test.ejb.local.TestInterface;
+import test.ejb.local.TestLocalEJB;
+
+abstract class TestBeanSuper implements TestBeanInterface {
+
+    abstract TestInterface getTestEJB();
+
+    @Override
+    public String runTests() {
+        String s = "";
+        if (!getTestEJB().m1DefinedInInterface())
+            s += "Cannot call method defined in the local EJB's interface";
+        return s;
+
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/local/TestEJBInjectionViaAtEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/local/TestEJBInjectionViaAtEJB.java
new file mode 100644
index 0000000..edadb04
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/local/TestEJBInjectionViaAtEJB.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock.local;
+
+import javax.ejb.EJB;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Named;
+
+import test.beans.artifacts.InjectViaAtEJB;
+import test.beans.artifacts.LocalEJB;
+import test.ejb.local.TestInterface;
+
+
+
+@RequestScoped
+@InjectViaAtEJB
+@LocalEJB
+
+public class TestEJBInjectionViaAtEJB extends TestBeanSuper{
+    @EJB TestInterface tnie;
+
+    @Override
+    TestInterface getTestEJB() {
+        return tnie;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/local/TestEJBInjectionViaInject.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/local/TestEJBInjectionViaInject.java
new file mode 100644
index 0000000..c4dec72
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/local/TestEJBInjectionViaInject.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock.local;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import test.beans.artifacts.InjectViaAtInject;
+import test.beans.artifacts.LocalEJB;
+import test.ejb.local.TestInterface;
+
+
+@RequestScoped
+@InjectViaAtInject
+@LocalEJB
+
+public class TestEJBInjectionViaInject extends TestBeanSuper {
+    @Inject TestInterface tnie;
+
+    @Override
+    TestInterface getTestEJB() {
+        return tnie;
+    }
+
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/nointerfacebeanview/TestBeanSuper.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/nointerfacebeanview/TestBeanSuper.java
new file mode 100644
index 0000000..5a38f90
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/nointerfacebeanview/TestBeanSuper.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock.nointerfacebeanview;
+
+import test.beans.TestBeanInterface;
+import test.ejb.nointerfacebeanview.TestNoInterfaceEJB;
+
+abstract class TestBeanSuper implements TestBeanInterface {
+    
+    abstract TestNoInterfaceEJB getTestEJB();
+
+    @Override
+    public String runTests() {
+        String s = "";
+        if (!getTestEJB().m2DefinedInSuperClass())
+            s += "Cannot call method defined in super class";
+        if (!getTestEJB().m3DefinedInEJB())
+            s += "Cannot call method defined in EJB";
+        return s;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/nointerfacebeanview/TestEJBInjectionViaAtEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/nointerfacebeanview/TestEJBInjectionViaAtEJB.java
new file mode 100644
index 0000000..a6eaacd
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/nointerfacebeanview/TestEJBInjectionViaAtEJB.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock.nointerfacebeanview;
+
+import javax.ejb.EJB;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Named;
+
+import test.beans.artifacts.InjectViaAtEJB;
+import test.beans.artifacts.NoInterfaceBeanView;
+import test.ejb.nointerfacebeanview.TestNoInterfaceEJB;
+
+
+@RequestScoped
+@InjectViaAtEJB
+@NoInterfaceBeanView
+
+public class TestEJBInjectionViaAtEJB extends TestBeanSuper{
+    @EJB TestNoInterfaceEJB tnie;
+
+    public TestEJBInjectionViaAtEJB() {
+        new Throwable().printStackTrace();
+    }
+    @Override
+    TestNoInterfaceEJB getTestEJB() {
+        return tnie;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/nointerfacebeanview/TestEJBInjectionViaInject.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/nointerfacebeanview/TestEJBInjectionViaInject.java
new file mode 100644
index 0000000..62b1b11
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/nointerfacebeanview/TestEJBInjectionViaInject.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock.nointerfacebeanview;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import test.beans.artifacts.InjectViaAtInject;
+import test.beans.artifacts.NoInterfaceBeanView;
+import test.ejb.nointerfacebeanview.TestNoInterfaceEJB;
+
+
+@RequestScoped
+@InjectViaAtInject
+@NoInterfaceBeanView
+
+public class TestEJBInjectionViaInject extends TestBeanSuper {
+    @Inject TestNoInterfaceEJB tnie;
+
+    @Override
+    TestNoInterfaceEJB getTestEJB() {
+        return tnie;
+    }
+
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/local/TestInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/local/TestInterface.java
new file mode 100644
index 0000000..fefb9ad
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/local/TestInterface.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.ejb.local;
+
+public interface TestInterface {
+    public boolean m1DefinedInInterface();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/local/TestLocalEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/local/TestLocalEJB.java
new file mode 100644
index 0000000..18054b1
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/local/TestLocalEJB.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.ejb.local;
+
+import javax.ejb.Local;
+import javax.ejb.Stateless;
+
+@Stateless
+@Local(TestInterface.class)
+public class TestLocalEJB extends TestSuperClass implements TestInterface {
+    public boolean m3DefinedInEJB(){
+        System.out.println("local ejb: m3");
+        return true;
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/local/TestSuperClass.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/local/TestSuperClass.java
new file mode 100644
index 0000000..53ad721
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/local/TestSuperClass.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.ejb.local;
+
+import javax.enterprise.inject.Alternative;
+
+ 
+//marked as Alternative, otherwise there would
+//an ambiguous definition for TestLocalInterface between this
+//super class and the TestLocalEJB
+public @Alternative class TestSuperClass implements TestInterface{
+
+    @Override
+    public boolean m1DefinedInInterface() {
+        System.out.println("local bean: m1");
+        return true;
+    }
+    
+    public boolean m2DefinedInSuperClass(){
+        System.out.println("local: m2");
+        return true;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/nointerfacebeanview/TestInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/nointerfacebeanview/TestInterface.java
new file mode 100644
index 0000000..dcb7186
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/nointerfacebeanview/TestInterface.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.ejb.nointerfacebeanview;
+
+public interface TestInterface {
+    public boolean m1DefinedInInterface();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/nointerfacebeanview/TestNoInterfaceEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/nointerfacebeanview/TestNoInterfaceEJB.java
new file mode 100644
index 0000000..ec60e4d
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/nointerfacebeanview/TestNoInterfaceEJB.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.ejb.nointerfacebeanview;
+
+import javax.ejb.Stateless;
+
+
+@Stateless
+public class TestNoInterfaceEJB {
+  public boolean m1DefinedInInterface() {
+    System.out.println("no interface bean: m1");
+    return true;
+  }
+
+  public boolean m2DefinedInSuperClass(){
+    System.out.println("no interface bean: m2");
+    return true;
+  }
+    public boolean m3DefinedInEJB() {
+        System.out.println("no interface ejb: m3");
+        return true;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/nointerfacebeanview/TestSuperClass.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/nointerfacebeanview/TestSuperClass.java
new file mode 100644
index 0000000..b4fbe8e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/nointerfacebeanview/TestSuperClass.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.ejb.nointerfacebeanview;
+
+import javax.enterprise.inject.Alternative;
+
+ 
+public class TestSuperClass implements TestInterface{
+
+    @Override
+    public boolean m1DefinedInInterface() {
+        System.out.println("no interface bean: m1");
+        return true;
+    }
+    
+    public boolean m2DefinedInSuperClass(){
+        System.out.println("no interface bean: m2");
+        return true;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/servlet/FooBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/servlet/FooBean.java
new file mode 100644
index 0000000..1e102af
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/servlet/FooBean.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.servlet;
+
+import javax.inject.Inject;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.InjectViaAtEJB;
+import test.beans.artifacts.NoInterfaceBeanView;
+
+public class FooBean {
+
+    @Inject
+    @InjectViaAtEJB
+    @NoInterfaceBeanView
+    TestBeanInterface testBeanEJB;
+    
+    public TestBeanInterface getBean(){
+        return testBeanEJB;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/servlet/NoInterfaceEJBTestServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/servlet/NoInterfaceEJBTestServlet.java
new file mode 100644
index 0000000..d878ef3
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/servlet/NoInterfaceEJBTestServlet.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.inject.Inject;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.InjectViaAtEJB;
+import test.beans.artifacts.InjectViaAtInject;
+import test.beans.artifacts.LocalEJB;
+import test.beans.artifacts.NoInterfaceBeanView;
+import test.ejb.nointerfacebeanview.TestInterface;
+import test.ejb.nointerfacebeanview.TestSuperClass;
+
+@WebServlet(name = "mytest", urlPatterns = { "/myurl" })
+public class NoInterfaceEJBTestServlet extends HttpServlet {
+
+//    @Inject
+//    @InjectViaAtInject
+//    @NoInterfaceBeanView
+//    TestBeanInterface testBeanInject;
+
+
+    @Inject
+    FooBean fb;
+//    @Inject
+//    @InjectViaAtInject
+//    @LocalEJB
+//    TestBeanInterface testLocalBeanInject;
+
+//    @Inject
+//    @InjectViaAtEJB
+//    @LocalEJB
+//    TestBeanInterface testLocalBeanEJB;
+    
+    @Inject
+    TestInterface ti;
+    
+    @Inject
+    TestSuperClass ti1;
+    
+    protected void doGet(HttpServletRequest request,
+            HttpServletResponse response) throws ServletException,
+            IOException {
+        PrintWriter writer = response.getWriter();
+        writer.write("Hello from Servlet 3.0.");
+        
+        String msg = "";
+        //test EJB injection via @EJB
+        String m = fb.getBean().runTests();
+        if (!m.equals(""))
+            msg += "Invocation on no-interface EJB -- obtained through @EJB -- failed. Failed tests" + m;
+        
+        //test EJB injection via @Inject
+//        m = testBeanInject.runTests();
+//        if (!m.equals(""))
+//            msg += "Invocation on no-interface EJB -- obtained through @Inject -- failed. Failed tests" + m;
+
+        //test No-Interface EJB injection via @Inject of an interface the 
+        //no-interface bean is implementing
+        if (ti != null && !(ti.m1DefinedInInterface()))
+            msg += "Invocation on no-interface EJB -- obtained through @Inject -- (method defined in super interface) failed";
+        
+        //test No-Interface EJB injection via @Inject of an interface the 
+        //no-interface bean is implementing
+        if (ti1 != null && !(ti1.m2DefinedInSuperClass()))
+            msg += "Invocation on no-interface EJB -- obtained through @Inject -- (method defined in super class) failed";
+        
+        //test local EJB injection via @EJB
+//        m = testLocalBeanEJB.runTests();
+//        if (!m.equals(""))
+//            msg += "Invocation on local EJB -- obtained through @EJB -- failed. Failed tests" + m;
+        
+        //test EJB injection via @Inject
+//        m = testLocalBeanInject.runTests();
+//        if (!m.equals(""))
+//            msg += "Invocation on local EJB -- obtained through @Inject -- failed. Failed tests" + m;
+
+        writer.write(msg + "\n");
+
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/README
new file mode 100644
index 0000000..431262e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/README
@@ -0,0 +1,3 @@
+Test
+- glassfish issue 11607
+- test to reproduce injection of SLSB into a session scoped bean
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/build.properties
new file mode 100644
index 0000000..5b8ba11
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/build.properties
@@ -0,0 +1,24 @@
+<!--
+
+    Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+ 
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-no-interface-ejb"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/build.xml
new file mode 100644
index 0000000..a0e6a9d
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/build.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+    &commonSetup;
+    &commonBuild;
+    &testproperties;
+    &run;
+
+    <target name="all" depends="build,deploy,run,undeploy" />
+
+	<target name="clean" depends="init-common">
+		<antcall target="clean-common" />
+		<delete>
+			<fileset dir="." includes="*.class" />
+			<fileset dir="client/test/client" includes="*.class" />
+		</delete>
+	</target>
+
+	<target name="compile" depends="clean">
+		<antcall target="compile-common">
+			<param name="src" value="servlet" />
+		</antcall>
+	</target>
+
+	<target name="build" depends="compile">
+		<property name="hasWebclient" value="yes" />
+		<antcall target="webclient-war-common">
+			<param name="hasWebclient" value="yes" />
+			<param name="webclient.war.classes" value="**/*.class" />
+		</antcall>
+
+		<javac srcdir="client" classpath="${env.APS_HOME}/lib/reportbuilder.jar" includes="test/client/WebTest.java" />
+
+	</target>
+
+	<target name="build-publish-war" depends="build, publish-war-common" />
+
+	<target name="deploy" depends="init-common">
+		<antcall target="deploy-war-common" />
+	</target>
+
+	<target name="run" depends="init-common">
+		<java classname="test.client.WebTest">
+			<arg value="${http.host}" />
+			<arg value="${http.port}" />
+			<arg value="${contextroot}" />
+			<classpath>
+				<pathelement location="${env.APS_HOME}/lib/reportbuilder.jar" />
+				<pathelement location="client" />
+			</classpath>
+		</java>
+	</target>
+
+	<target name="undeploy" depends="init-common">
+		<antcall target="undeploy-war-common" />
+	</target>
+
+	<target name="usage">
+		<antcall target="usage-common" />
+	</target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/client/test/client/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/client/test/client/WebTest.java
new file mode 100644
index 0000000..05b4076
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/client/test/client/WebTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.client;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+    private static SimpleReporterAdapter stat = new SimpleReporterAdapter(
+            "appserv-tests");
+    private static final String TEST_NAME = "slsb-injection-into-sessionscopedbean";
+
+    private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0.";
+
+    private String host;
+    private String port;
+    private String contextRoot;
+
+    public WebTest(String[] args) {
+        host = args[0];
+        port = args[1];
+        contextRoot = args[2];
+    }
+
+    public static void main(String[] args) {
+        stat.addDescription("Unit test for Java EE resource injection");
+        WebTest webTest = new WebTest(args);
+        webTest.doTest();
+        stat.printSummary(TEST_NAME);
+    }
+
+    public void doTest() {
+        try {
+            invoke();
+        } catch (Exception ex) {
+            System.out.println(TEST_NAME + " test failed");
+            stat.addStatus(TEST_NAME, stat.FAIL);
+            ex.printStackTrace();
+        }
+    }
+
+    private void invoke() throws Exception {
+
+        String url = "http://" + host + ":" + port + contextRoot + "/myurl";
+        System.out.println("opening connection to " + url);
+        HttpURLConnection conn = (HttpURLConnection) (new URL(url))
+                .openConnection();
+
+        int code = conn.getResponseCode();
+        if (code != 200) {
+            System.out.println("Unexpected return code: " + code);
+            stat.addStatus(TEST_NAME, stat.FAIL);
+        } else {
+            InputStream is = null;
+            BufferedReader input = null;
+            String line = null;
+            try {
+                is = conn.getInputStream();
+                input = new BufferedReader(new InputStreamReader(is));
+                line = input.readLine();
+                System.out.println("line = " + line);
+            } finally {
+                try {
+                    if (is != null) {
+                        is.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+                try {
+                    if (input != null) {
+                        input.close();
+                    }
+                } catch (IOException ioe) {
+                    // ignore
+                }
+            }
+            if (EXPECTED_RESPONSE.equals(line)) {
+                stat.addStatus(TEST_NAME, stat.PASS);
+            } else {
+                System.out.println("Wrong response. Expected: "
+                        + EXPECTED_RESPONSE + ", received: " + line);
+                stat.addStatus(TEST_NAME, stat.FAIL);
+            }
+        }
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/descriptor/beans.xml
new file mode 100644
index 0000000..1d355f8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/descriptor/beans.xml
@@ -0,0 +1,25 @@
+<!--
+
+    Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<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>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/descriptor/persistence.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/descriptor/persistence.xml
new file mode 100644
index 0000000..82f2d7b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/descriptor/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+  <persistence-unit name="pu1" transaction-type="JTA">
+    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+    <jta-data-source>jdbc/__default</jta-data-source>
+    <non-jta-data-source>jdbc/__default</non-jta-data-source>
+    <class>myapp.Department</class>
+    <class>myapp.Employee</class>
+    <properties>
+       <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+       <property name="eclipselink.logging.level" value="INFO"/>
+    </properties>
+  </persistence-unit>
+</persistence>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/TestBeanInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/TestBeanInterface.java
new file mode 100644
index 0000000..cf49083
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/TestBeanInterface.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans;
+
+public interface TestBeanInterface {
+    public String runTests();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/TestSessionScopedBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/TestSessionScopedBean.java
new file mode 100644
index 0000000..a9fc170
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/TestSessionScopedBean.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans;
+
+import java.io.Serializable;
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import test.ejb.slsb.TestSLSB;
+
+@Named
+@SessionScoped
+public class TestSessionScopedBean implements Serializable{
+
+    @Inject
+    TestSLSB statelessSessionBean;
+
+    public TestSessionScopedBean() {
+    }
+    
+    public boolean testSLSBAccess(){
+        if (statelessSessionBean != null)
+            return statelessSessionBean.statelessMethod1();
+        else return false;
+    }
+    
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/artifacts/InjectViaAtEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/artifacts/InjectViaAtEJB.java
new file mode 100644
index 0000000..594448d
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/artifacts/InjectViaAtEJB.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface InjectViaAtEJB {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/artifacts/InjectViaAtInject.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/artifacts/InjectViaAtInject.java
new file mode 100644
index 0000000..8e11c88
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/artifacts/InjectViaAtInject.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface InjectViaAtInject {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/artifacts/LocalEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/artifacts/LocalEJB.java
new file mode 100644
index 0000000..04bb97c
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/artifacts/LocalEJB.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface LocalEJB {
+}
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/artifacts/NoInterfaceBeanView.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/artifacts/NoInterfaceBeanView.java
new file mode 100644
index 0000000..6e95330
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/artifacts/NoInterfaceBeanView.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface NoInterfaceBeanView {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/nonmock/local/TestBeanSuper.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/nonmock/local/TestBeanSuper.java
new file mode 100644
index 0000000..a95c06e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/nonmock/local/TestBeanSuper.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock.local;
+
+import test.beans.TestBeanInterface;
+import test.ejb.local.TestInterface;
+import test.ejb.local.TestLocalEJB;
+
+abstract class TestBeanSuper implements TestBeanInterface {
+
+    abstract TestInterface getTestEJB();
+
+    @Override
+    public String runTests() {
+        String s = "";
+        if (!getTestEJB().m1DefinedInInterface())
+            s += "Cannot call method defined in the local EJB's interface";
+        return s;
+
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/nonmock/local/TestEJBInjectionViaAtEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/nonmock/local/TestEJBInjectionViaAtEJB.java
new file mode 100644
index 0000000..edadb04
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/nonmock/local/TestEJBInjectionViaAtEJB.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock.local;
+
+import javax.ejb.EJB;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Named;
+
+import test.beans.artifacts.InjectViaAtEJB;
+import test.beans.artifacts.LocalEJB;
+import test.ejb.local.TestInterface;
+
+
+
+@RequestScoped
+@InjectViaAtEJB
+@LocalEJB
+
+public class TestEJBInjectionViaAtEJB extends TestBeanSuper{
+    @EJB TestInterface tnie;
+
+    @Override
+    TestInterface getTestEJB() {
+        return tnie;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/nonmock/local/TestEJBInjectionViaInject.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/nonmock/local/TestEJBInjectionViaInject.java
new file mode 100644
index 0000000..c4dec72
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/nonmock/local/TestEJBInjectionViaInject.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock.local;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import test.beans.artifacts.InjectViaAtInject;
+import test.beans.artifacts.LocalEJB;
+import test.ejb.local.TestInterface;
+
+
+@RequestScoped
+@InjectViaAtInject
+@LocalEJB
+
+public class TestEJBInjectionViaInject extends TestBeanSuper {
+    @Inject TestInterface tnie;
+
+    @Override
+    TestInterface getTestEJB() {
+        return tnie;
+    }
+
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/nonmock/nointerfacebeanview/TestBeanSuper.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/nonmock/nointerfacebeanview/TestBeanSuper.java
new file mode 100644
index 0000000..5a38f90
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/nonmock/nointerfacebeanview/TestBeanSuper.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock.nointerfacebeanview;
+
+import test.beans.TestBeanInterface;
+import test.ejb.nointerfacebeanview.TestNoInterfaceEJB;
+
+abstract class TestBeanSuper implements TestBeanInterface {
+    
+    abstract TestNoInterfaceEJB getTestEJB();
+
+    @Override
+    public String runTests() {
+        String s = "";
+        if (!getTestEJB().m2DefinedInSuperClass())
+            s += "Cannot call method defined in super class";
+        if (!getTestEJB().m3DefinedInEJB())
+            s += "Cannot call method defined in EJB";
+        return s;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/nonmock/nointerfacebeanview/TestEJBInjectionViaAtEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/nonmock/nointerfacebeanview/TestEJBInjectionViaAtEJB.java
new file mode 100644
index 0000000..ccd055e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/nonmock/nointerfacebeanview/TestEJBInjectionViaAtEJB.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock.nointerfacebeanview;
+
+import javax.ejb.EJB;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Named;
+
+import test.beans.artifacts.InjectViaAtEJB;
+import test.beans.artifacts.NoInterfaceBeanView;
+import test.ejb.nointerfacebeanview.TestNoInterfaceEJB;
+
+
+@RequestScoped
+@InjectViaAtEJB
+@NoInterfaceBeanView
+
+public class TestEJBInjectionViaAtEJB extends TestBeanSuper{
+    @EJB TestNoInterfaceEJB tnie;
+
+    @Override
+    TestNoInterfaceEJB getTestEJB() {
+        return tnie;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/nonmock/nointerfacebeanview/TestEJBInjectionViaInject.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/nonmock/nointerfacebeanview/TestEJBInjectionViaInject.java
new file mode 100644
index 0000000..62b1b11
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/beans/nonmock/nointerfacebeanview/TestEJBInjectionViaInject.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.beans.nonmock.nointerfacebeanview;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import test.beans.artifacts.InjectViaAtInject;
+import test.beans.artifacts.NoInterfaceBeanView;
+import test.ejb.nointerfacebeanview.TestNoInterfaceEJB;
+
+
+@RequestScoped
+@InjectViaAtInject
+@NoInterfaceBeanView
+
+public class TestEJBInjectionViaInject extends TestBeanSuper {
+    @Inject TestNoInterfaceEJB tnie;
+
+    @Override
+    TestNoInterfaceEJB getTestEJB() {
+        return tnie;
+    }
+
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/local/TestInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/local/TestInterface.java
new file mode 100644
index 0000000..fefb9ad
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/local/TestInterface.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.ejb.local;
+
+public interface TestInterface {
+    public boolean m1DefinedInInterface();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/local/TestLocalEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/local/TestLocalEJB.java
new file mode 100644
index 0000000..ce06ab6
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/local/TestLocalEJB.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.ejb.local;
+
+import javax.ejb.Local;
+import javax.ejb.Stateless;
+
+@Stateless
+@Local(TestInterface.class)
+public class TestLocalEJB extends TestSuperClass{
+    public boolean m3DefinedInEJB(){
+        System.out.println("local ejb: m3");
+        return true;
+    }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/local/TestSuperClass.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/local/TestSuperClass.java
new file mode 100644
index 0000000..53ad721
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/local/TestSuperClass.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.ejb.local;
+
+import javax.enterprise.inject.Alternative;
+
+ 
+//marked as Alternative, otherwise there would
+//an ambiguous definition for TestLocalInterface between this
+//super class and the TestLocalEJB
+public @Alternative class TestSuperClass implements TestInterface{
+
+    @Override
+    public boolean m1DefinedInInterface() {
+        System.out.println("local bean: m1");
+        return true;
+    }
+    
+    public boolean m2DefinedInSuperClass(){
+        System.out.println("local: m2");
+        return true;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/nointerfacebeanview/TestInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/nointerfacebeanview/TestInterface.java
new file mode 100644
index 0000000..dcb7186
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/nointerfacebeanview/TestInterface.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.ejb.nointerfacebeanview;
+
+public interface TestInterface {
+    public boolean m1DefinedInInterface();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/nointerfacebeanview/TestNoInterfaceEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/nointerfacebeanview/TestNoInterfaceEJB.java
new file mode 100644
index 0000000..64ebd63
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/nointerfacebeanview/TestNoInterfaceEJB.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.ejb.nointerfacebeanview;
+
+import javax.ejb.Stateless;
+
+
+@Stateless
+public class TestNoInterfaceEJB  {
+  public boolean m1DefinedInInterface() {
+    System.out.println("no interface bean: m1");
+    return true;
+  }
+
+  public boolean m2DefinedInSuperClass(){
+    System.out.println("no interface bean: m2");
+    return true;
+  }
+    public boolean m3DefinedInEJB() {
+        System.out.println("no interface ejb: m3");
+        return true;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/nointerfacebeanview/TestSuperClass.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/nointerfacebeanview/TestSuperClass.java
new file mode 100644
index 0000000..ef5e220
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/nointerfacebeanview/TestSuperClass.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.ejb.nointerfacebeanview;
+
+import javax.enterprise.inject.Alternative;
+
+ 
+//marked as Alternative, otherwise there would
+//an ambiguous definition for TestLocalInterface between this
+//super class and the TestLocalEJB
+public class TestSuperClass implements TestInterface{
+
+    @Override
+    public boolean m1DefinedInInterface() {
+        System.out.println("no interface bean: m1");
+        return true;
+    }
+    
+    public boolean m2DefinedInSuperClass(){
+        System.out.println("no interface bean: m2");
+        return true;
+    }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/slsb/TestSLSB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/slsb/TestSLSB.java
new file mode 100644
index 0000000..96b85d8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/ejb/slsb/TestSLSB.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.ejb.slsb;
+import javax.ejb.Stateless;
+import javax.enterprise.context.Dependent;
+import javax.inject.Named;
+
+@Named
+@Stateless
+@Dependent
+public class TestSLSB {
+
+    public TestSLSB() {
+    }
+    
+    public boolean statelessMethod1(){
+        return true;
+    }
+ 
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/servlet/SLSBInjectionIntoSessionScopedBeanTestServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/servlet/SLSBInjectionIntoSessionScopedBeanTestServlet.java
new file mode 100644
index 0000000..c5f0232
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/slsb-injection-into-sessionscoped/servlet/test/servlet/SLSBInjectionIntoSessionScopedBeanTestServlet.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.inject.Inject;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import test.beans.TestBeanInterface;
+import test.beans.TestSessionScopedBean;
+import test.beans.artifacts.InjectViaAtEJB;
+import test.beans.artifacts.InjectViaAtInject;
+import test.beans.artifacts.LocalEJB;
+import test.beans.artifacts.NoInterfaceBeanView;
+import test.ejb.nointerfacebeanview.TestInterface;
+import test.ejb.nointerfacebeanview.TestSuperClass;
+
+@WebServlet(name = "mytest", urlPatterns = { "/myurl" })
+public class SLSBInjectionIntoSessionScopedBeanTestServlet extends HttpServlet {
+
+    @Inject
+    @InjectViaAtInject
+    @NoInterfaceBeanView
+    TestBeanInterface testBeanInject;
+
+    @Inject
+    @InjectViaAtEJB
+    @NoInterfaceBeanView
+    TestBeanInterface testBeanEJB;
+
+    @Inject
+    @InjectViaAtInject
+    @LocalEJB
+    TestBeanInterface testLocalBeanInject;
+
+    @Inject
+    @InjectViaAtEJB
+    @LocalEJB
+    TestBeanInterface testLocalBeanEJB;
+    
+    @Inject
+    TestInterface ti;
+    
+    @Inject
+    TestSuperClass ti1;
+    
+    @Inject
+    TestSessionScopedBean tssb;
+    
+    protected void doGet(HttpServletRequest request,
+            HttpServletResponse response) throws ServletException,
+            IOException {
+        PrintWriter writer = response.getWriter();
+        writer.write("Hello from Servlet 3.0.");
+        
+        String msg = "";
+        //test EJB injection via @EJB
+        String m = testBeanEJB.runTests();
+        if (!m.equals(""))
+            msg += "Invocation on no-interface EJB -- obtained through @EJB -- failed. Failed tests" + m;
+        
+        //test EJB injection via @Inject
+        m = testBeanInject.runTests();
+        if (!m.equals(""))
+            msg += "Invocation on no-interface EJB -- obtained through @Inject -- failed. Failed tests" + m;
+
+        //test No-Interface EJB injection via @Inject of an interface the 
+        //no-interface bean is implementing
+        if (ti != null && !(ti.m1DefinedInInterface()))
+            msg += "Invocation on no-interface EJB -- obtained through @Inject -- (method defined in super interface) failed";
+        
+        //test No-Interface EJB injection via @Inject of an interface the 
+        //no-interface bean is implementing
+        if (ti1 != null && !(ti1.m2DefinedInSuperClass()))
+            msg += "Invocation on no-interface EJB -- obtained through @Inject -- (method defined in super class) failed";
+        
+        //test local EJB injection via @EJB
+        m = testLocalBeanEJB.runTests();
+        if (!m.equals(""))
+            msg += "Invocation on local EJB -- obtained through @EJB -- failed. Failed tests" + m;
+        
+        //test EJB injection via @Inject
+        m = testLocalBeanInject.runTests();
+        if (!m.equals(""))
+            msg += "Invocation on local EJB -- obtained through @Inject -- failed. Failed tests" + m;
+        
+        if (!tssb.testSLSBAccess())
+            msg += "Stateless Session Bean into session scoped bean failed";
+
+        writer.write(msg + "\n");
+
+    }
+}