WebLogic 12.1.3 error WELD-001408 Unsatisfied dependencies - eclipse

WebLogic 12.1.3 fails when deploying a web application with a simple CDI injection. The following exception is thrown:
weblogic.application.ModuleException: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Interface2] with qualifiers [#Default] at injection point [[field] #Inject public pruebas1.Clase1.clase2]
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:211)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
Truncated. see log file for complete stacktrace
Caused By: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Interface2] with qualifiers [#Default] at injection point [[field] #Inject public pruebas1.Clase1.clase2]
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:315)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:284)
at org.jboss.weld.bootstrap.Validator.validateInjectionTarget(Validator.java:342)
at org.jboss.weld.manager.InjectionTargetValidator.addInjectionTarget(InjectionTargetValidator.java:29)
at org.jboss.weld.manager.BeanManagerImpl.createInjectionTarget(BeanManagerImpl.java:943)
Truncated. see log file for complete stacktrace
>
When i deploy the war in WebLogic 12.1.3 (Zip Distribution and Installers for Developers) inside OEPE 12.1.3.2 i get the error described. But, whith WebLogic 12.1.1 (Zip Distribution and Installers for Developers) inside the same OEPE 12.1.3.2 there is no problem. Neither there isn't problem if i export thye war file and deploy with the web console without OEPE integration. Additionally, when i deploy the war in WebLogic 12.1.3. standalone ("full" release) there is no problem.
I encountered too, that the MANIFEST.MF file (inside wlserver/server/lib/api.jar) references "javax.inject_1.jar" that doesn't exist in wlserver/modules folder. Instead there is the file "javax.inject-1.jar". To make my project working (import the class javax.inject.Inject class) i copied a file named javax.inject_1.jar from the javax.inject-1.jar file in the same folder.
The war java source structure is:
src
pruebas1
Clase1.java
pruebas2
Clase2.java
Interface2.java
The war WebContent structure is:
WebContent
WEB-INF
beans.xml
weblogix.xml
Classes and interface:
#WebService
public class Clase1 {
#Inject
public Interface2 clase2;
#WebMethod
public String aMayusculas(#WebParam(name = "palabra") String palabra) {
long tm = System.currentTimeMillis();
System.out.println(tm + " - clase2: " + (clase2 == null ? "null" : clase2.toString()));
return palabra == null ? "null" : tm + " - " + palabra.toUpperCase();
}
}
public interface Interface2 {
void doIt(String a);
}
public class Clase2 implements Interface2 {
#Override
public void doIt(String a) {
System.out.println(a);
}
}
XML files:
beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
weblogic.xml
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<wls:weblogic-version>12.1.3</wls:weblogic-version>
<wls:context-root>prueba05weblogic</wls:context-root>
</wls:weblogic-web-app>
Thanks in advance.
Efren V.

The problem was resolved.
I created a SR in Oracle support site. Oracle built an internal patch.
Efren.

After three days searching, we found that the project only worked if deployed through the weblogic console, if we deployed through oracle plugin in eclipse it wont work.
So, if you are using eclipse, in the "servers" view, right click weblogic server, click "Properties -> Weblogic -> Publishing", change the radio "Pubish as a virtual application" to "Publish as exploded archive"

you can replace #Inject annotation with #Produces as workaround

Related

Gettting WELD Exception on server startup of weblogic where as using Google Guice for DI in Jersey based application

I am using Weblogic 12b as App server. My application uses Jersey 2.5.1 with Guice3 in my project. I have a class called Application derived from org.glassfish.jersey.server.ResourceConfig. On server startup I am getting error as below:
Caused By: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type ServiceLocator with qualifiers #Default
at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] #Inject public Application(ServiceLocator)
at Application.<init>(Application.java:22)
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:359)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:281)
at org.jboss.weld.bootstrap.Validator.validateProducer(Validator.java:417)
at org.jboss.weld.injection.producer.InjectionTargetService.validateProducer(InjectionTargetService.java:36)
at org.jboss.weld.manager.InjectionTargetFactoryImpl.validate(InjectionTargetFactoryImpl.java:135)
It seems it is taking WELD in place of google Guice for DI.
Same issue I am getting in business Tier where EJB classes are composed of Java Classes and they are injected using #Inject.
I have even tried to change he import #Inject to google inject but the exception changed but not resolved.
I tried to use beans.xml in web-inf
#ApplicationPath("/")
public class Application extends ResourceConfig {
#Inject
public Application(final ServiceLocator serviceLocator) {
}
}
You need to effectively disable CDI.
You can do this by adding a WEB-INF/beans.xml file to your application that contains:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="none">
</beans>
Note the bean-discovery-mode="none".
If your project contains additional jars with classes that might look CDI beans then you will also need to add a similar META-INF/beans.xml file to those as well.
However, I suspect that this may lead to other unrelated issues. Normally application servers like to control the lifecycle of your classes and this includes those related to JAX-RS.

Glassfish v3: Web application not finding JAR in the same EAR

I created a EAR application in Eclipse to run in Glassfish 3.1. The used projects are: BibliotecaEAR2 (the main EAR. 'Biblioteca' means 'Library'), BibliotecaEJB (with EJBs), BibliotecaModel (with entities and DAOs) and BibliotecaWeb (The Web application). The application.xml has this structure:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" id="Application_ID" version="6">
<display-name>BibliotecaEAR2</display-name>
<module>
<web>
<web-uri>BibliotecaWeb.war</web-uri>
<context-root>biblioteca</context-root>
</web>
</module>
<module>
<ejb>BibliotecaEJB.jar</ejb>
</module>
</application>
In BibliotecaWeb, the META-INF/MANIFEST.MF is written this:
Manifest-Version: 1.0
Class-Path: lib/google/guava-18.0.jar
// other JARs in BibliotecaEAR2 project
BibliotecaEJB.jar
When I start the glassfish I get this warning message:
2014-10-20T14:34:31.691-0200|WARNING: PWC6351: In TLD scanning, the supplied resource file:/C:/dev/glassfish3/glassfish/domains/biblioteca-glass3/eclipseApps/BibliotecaEAR2/BibliotecaEJB.jar does not exist
java.io.FileNotFoundException: C:\dev\glassfish3\glassfish\domains\biblioteca-glass3\eclipseApps\BibliotecaEAR2\BibliotecaEJB.jar (O sistema nao pode encontrar o arquivo especificado)
Although it does not stop me from running the application, I would like to eliminate it.
Googling for PWC6351 warning, I perceived that it happens when a used JAR is not found in the Manifest File. However the request JAR is not simply a external library, but a sub-project in same EAR. Is there any additional configuration that should I do?
Thanks,
Rafael Afonso
From Packaging libraries with EARs:
When packaging applications in an EAR file, the library JARs need to
be placed in the archive lib directory (jars at the archive root level
are not added to the classpath and thus available from other EAR
artifacts.)
The library jars placed in the "/lib" directory of the EAR (the
directory name can be overridden in application.xml) will be visible
to all sub-modules (JARs, WARs, and RARs) with no further
configuration. No need to add Class-Path entries in the EAR manifest.
In fact you don't need to reference the jars in the lib folder, and it looks like it will not work if you reference a jar on the EAR root level, like your BibliotecaEJB.jar.
If you don't have a real dependency from your WAR module classes to your EJB module classes you can just remove all the entries from the MANIFEST.MF and it should work.
If you instead have a real dependency from WAR to EJB, you may have to think about your project structure and if you really need an EAR. You can also package all the stuff into a single WAR.
The right way to use an EAR with WAR and EJB modules requires a little bit of work if your current WAR classes directly depend on classes from the EJB module:
1. Step
You have to create interfaces for all your "service" classes which should be available to classes in the web application (WAR).
Here is a simple example:
public interface FileService {
public void showFileInformation(File file);
}
and
#Stateless
#Local(FileService.class)
#Remote(FileService.class)
public class FileServiceImpl implements FileService {
#Override
public void showFileInformation(File file) {
// here
// is
// the
// real
// stuff
}
}
2. Step
The next step is to package all your new interfaces into a new jar. Your model jar looks similar to this approach. If this can't be used for this purpose, create a simple java application project which gets packaged as jar and put all the interfaces into this project. This jar has to be in the lib folder of the EAR.
BibliotecaEAR2
-- BibliotecaEJB
-- BibliotecaWeb
-- /lib/interfaces.jar
Then you have to add a dependency to this new jar in your WAR and EJB modules, so that they can find the interface classes.
3. Step
The services can be injected into the managed classes of your web applications (and into other service classes) like this:
#RequestScoped
public class FileHandler {
// make sure to use the interface
#EJB
FileService fileService;
}
Maybe you already have something similar to this, but then it should work without any entries in the MANIFEST.MF.
See also:
Maven2: Best practice for Enterprise Project (EAR file)
Java EE - EAR vs separate EJB+WAR
Packaging EJB in JavaEE 6 WAR vs EAR
I had a similar issue and solved by customizing module location, like this
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" id="Application_ID" version="6">
<display-name>BibliotecaEAR2</display-name>
<module>
<web>
<web-uri>BibliotecaWeb.war</web-uri>
<context-root>biblioteca</context-root>
</web>
</module>
<module>
<ejb>BibliotecaEJB.jar</ejb>
<bundleDir>/lib</bundleDir> <!-- ADD THIS OPTION TO THE MODULE -->
</module>
</application>
This solution is taken from the Maven EAR plugin documentation, which uses Maven 3 syntax, but I think you can use it too (or you can migrate to Maven 3).
Hope that helps.

How to fix "Can not find the tag library descriptor" in eclipse 4.3 for my custom EL function

setup:
eclipse 4.3 with tomcat7 (running on localhost port 8080) configured as my test server.
my EL class (folder structure: http://i.imgur.com/ogOsCZM.jpg) created using New => Java project in eclipse
package org.flinders.mycustomutilities;
//import java.lang.StringBuilder;
public class MyCustomUtilities {
public static String Hello(String name) {
return "Heya " + name;
}
}
The class was then exported into a JAR file and imported into my maven repository. It was then imported to my spring mvc project using this entry in pom.xml:
<dependency>
<groupId>org.flinders.mycustomutilities</groupId>
<artifactId>MyCustomUtilities</artifactId>
<version>0.0.1</version>
</dependency>
I'm not getting any errors in Eclipse's Maven POM editor.
my TLD file (stored in D:\work\eclipse\java.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\ROOT\WEB-INF which seems to be the working folder for tomcat)
<?xml version="1.0" encoding="UTF-8" ?>
<taglib
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
version="2.1">
<tlib-version>1.0</tlib-version>
<short-name>mytaglib</short-name>
<uri>org.flinders.mycustomutilities</uri>
<function>
<name>Hello</name>
<function-class>org.flinders.mycustomutilities.MyCustomUtilities</function-class>
<function-signature>java.util.String Hello(java.util.String)</function-signature>
</function>
</taglib>
not really sure what to put in the URI tag for my setup.
This is how I'm importing my custom EL function in my JSP file
<%# taglib uri="WEB-INF/mytaglib.tld" prefix="mine" %>
I've also tried
<%# taglib uri="/WEB-INF/mytaglib.tld" prefix="mine" %>
but eclipse just can't see it. I have started tomcat via eclipse just in case that is required without any positive outcome. Still getting the error mentioned above.
Any ideas? I've been searching for examples on the net but they don't really give complete/working examples.
thanks!
My problem is that I was placing the tld file in the wrong place. I am importing the class/jar into my spring web mvc project. But I was putting the TLD file in the "ROOT" WEB-INF. I should've placed it in the WEB-INF for my web project. All working now thanks to all those who looked at it.

Deployment Error Weld-001408 with WLS12c and OEPE

I created the following projects in OEPE:
weld001408 (Java EE - Enterprise Application Project)
weld001408utility (Java EE - Uitility Project), belongs to the ear weld001408
weld001408web (Web - Dynamic Web Project), belongs to the ear weld001408
When I created the project, I didn't change the defaults (onley ear-membership) and the target-runtime is Oracle WebLogic Server 12.1.1. And the clean domain, created with the wizard, is added to the workspace.
The Code is the following:
utility-project
class 'weld001408utility/ValueProducer.java'
package weld001408utility;
import javax.enterprise.inject.Produces;
public class ValueProducer {
#Produces
public String stringValue() {
return "someStringValue";
}
}
META-INF/beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
web-project
weld001408web/ValueConsumerServlet.java
package weld001408web;
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;
/**
* Servlet implementation class ValueConsumerServlet
*/
#WebServlet("/ValueConsumerServlet")
public class ValueConsumerServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
#Inject
private String injectedValue;
/**
* #see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter pw = response.getWriter();
pw.write("injectedValue: " + injectedValue);
pw.flush();
}
}
WEB-INF/beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
The issue
Now when I try to deploy the application in Eclipse, I get always a WELD-001408 error:
<01.03.2013 10:07 Uhr MEZ> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.management.DeploymentException:
at weblogic.application.internal.BaseDeployment.throwAppException(BaseDeployment.java:123)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:239)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:61)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
Truncated. see log file for complete stacktrace
Caused By: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [String] with qualifiers [#Default] at injection point [[field] #Inject private weld001408web.ValueConsumerServlet.injectedValue]
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:258)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:105)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:125)
at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:324)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:309)
Truncated. see log file for complete stacktrace
>
But when I export the ear from eclipse and deploy that file over the weblogic administration console, then everything's working fine and the value is correctly injected to the servlet. No problems on deployment, nothing.
There are some patches for weblogic around and I have the latest installed (I checked a lot bugs which could belongs to my problem, and they should all included with 12.1.1.0.2):
WebLogic Server 12.1.1.0.2 PSU Patch for BUG14331523 Thu Oct 11 15:08:09 IST 2012
WebLogic Server 12.1.1.0 Wed Dec 7 08:40:57 PST 2011 1445491 >
I tried the same application on Windows Vista and on a Linux based System with the latest OEPE Versions (all-in-one package), no success...
The question
Has somone the exact same issue? Is it possible for someone to reproduce the problem? And when not, on which configuration with what patches is it working?
I don't know if it's a Oracle Enterprise Pack for Eclipse or an WebLogic-Issue.
Thanks for helping!
I solved the problem as stated below. Added pictures to make it easier.
Goto Eclipse Servers (View), right click on the weblogic server 12.1.3 and click on properties.
In Weblogic --> Publishing, select 'Publish as an exploded archive'

Arquillian test with real EAR from build on JBoss 7.1

I want to test an Java EE application with Arquillian. A simple setup is working to put some test classes onto the server managed by Arquillian to test them.
Now, I want to use a EAR file which was build during the build process. With
#Deployment
public static EnterpriseArchive createDeployment() {
File earFile = ...
EnterpriseArchive archive = ShrinkWrap.createFromZipFile(EnterpriseArchive.class, earFile);
return archive;
}
I am able to put the EAR via Arquillian to JBoss. I see the deployment and there are no errors during deployment. Only Arquillian returns with an error that it can not find the test class, which is obviously ok.
Now is the question where to put the test class to. I can put the test class into the test.war put into the EAR by Arquillian, but I get an ArquillianServletRunner not found exception. When I put the test classes into JAR files as module or library the test classes are not found when put as module or the injects do not work when put as libraries due to dependency issues.
Where to I have to put the test classes to???
My arquillian.xml:
<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://jboss.org/schema/arquillian"
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<defaultProtocol type="Servlet 3.0" />
<container qualifier="jboss7" default="true">
<configuration>
<property name="jbossHome">${cargo.dir}/jboss-as-dist-7.1.1.Final/jboss-as-7.1.1.Final</property>
</configuration>
</container>
<engine>
<property name="deploymentExportPath">target/deployments</property>
</engine>
</arquillian>
You can run your test class on the client side using #Deployment(testable = false), but this has the downside that you cannot use the persistence extention (and maybe others) at the moment.
My example code:
#RunWith(Arquillian.class)
public class PersonWebServiceIT {
private PersonWebService service;
#Deployment(testable = false)
public static Archive<?> createDeployment() {
return ShrinkWrap
.create(ZipImporter.class, "test.war")
.importFrom(
new File("simple-webservice-1.0.0-SNAPSHOT.war"))
.as(WebArchive.class);
}
#Test
public void testFindPersons(#ArquillianResource URL deploymentUrl) {
....
}
}
Putting the test classes to the war inside the ear did work for me
WebArchive war = ear.getAsType(WebArchive.class, "/mywarname.war");
war.addClass(MyTestClass.class);
When I am dealing with existing EAR, I prefer to separate the WAR that runs the tests, from the actual tests that I put in special JAR along with other testing EJBs. I have posted an example how do I do it with the necessary application.xml manipulation under similar question: https://stackoverflow.com/a/17036383/1667977