How to disable WELD on WildFly - java

How to fully disable WELD on WildFly. I don't need it, because I use another DI framework.
Exception 0 :
javax.enterprise.inject.UnsatisfiedResolutionException: Unable to resolve a bean for 'org.springframework.data.mongodb.core.MongoOperations' with qualifiers [#javax.enterprise.inject.Any(), #javax.enterprise.inject.Default()].
at org.springframework.data.mongodb.repository.cdi.MongoRepositoryExtension.createRepositoryBean(MongoRepositoryExtension.java:104)
at org.springframework.data.mongodb.repository.cdi.MongoRepositoryExtension.afterBeanDiscovery(MongoRepositoryExtension.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:266)
at org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:125)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253)
at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:232)
at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:169)
I tried
<?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"
xmlns:weld="http://jboss.org/schema/weld/beans"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd
http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd
http://jboss.org/schema/weld/beans ">
<weld:scan>
<weld:exclude name="com.google.**"/>
<weld:exclude name="org.springframework.data.mongodb.**"/>
</weld:scan>
But it did not resolve my problem.

There's the standard way:
<?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"
version="1.1" bean-discovery-mode="none">
</beans>

Option 1: jboss-all.xml in the war
This is Weld-specific, but it disables Weld's automatic bean scanning for an entire deployment (eg a war file and all the jars inside it). This is handy when you can't easily add beans.xml to a third-party jar, such as jboss-seam-resteasy.jar.
Save as WEB-INF/jboss-all.xml for wars, META-INF/jboss-all.xml otherwise:
<jboss xmlns="urn:jboss:1.0">
<weld xmlns="urn:jboss:weld:1.0" require-bean-descriptor="true"/>
</jboss>
See Per-deployment configuration.
Option 2: standalone.xml in WildFly
Another option, which doesn't require changing the application itself, is to configure the weld subsystem not to treat random jars as CDI libraries. Just edit the configuration for weld in WildFly's standalone.xml to look like this:
<subsystem xmlns="urn:jboss:domain:weld:2.0" require-bean-descriptor="true"/>

Try deleting or commenting out the org.jboss.as.weld extension in the extensions list on the beginning of $JBOSS_HOME/standalone/configuration/standalone.xml. You may also want to delete <subsystem xmlns="urn:jboss:domain:weld:1.0"/> from <profile>. This should cause disabling Weld for all applications deployed on the server.

Related

WebLogic 10.3.6 Upgrade to 12c, Migration from JSF 1.1 to 1.2 results in errors specifically when trying to find the JSF 1.2 library

As the title states we recently upgraded from WebLogic 10.3.6 to 12c. Our application was using JSF 1.1 but with 12c you have to use 1.2 or 2.0. The issue I'm running into is when updating the application to 1.2, deploying 1.2 in WebLogic, and then also updating the weblogic.xml the errors do not go away and a 500 error is returned on the front end.
Updating the application and weblogic.xml:
First removed jsf-api.jar and jsf-impl.jar from WEB-INF/lib.
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/ejb-jar_3_0.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<wls:container-descriptor>
<wls:show-archived-real-path-enabled>true</wls:show-archived-real-path-enabled>
</wls:container-descriptor>
<wls:library-ref>
<wls:library-name>jsf</wls:library-name>
<wls:specification-version>1.2</wls:specification-version>
<wls:implementation-version>1.2.9.0</wls:implementation-version>
<wls:exact-match>false</wls:exact-match>
</wls:library-ref>
</wls:weblogic-web-app>
JSF Deployed to server
Errors received:
Unresolved Webapp Library references for "WebAppModule(ExampleDeployment)", defined in weblogic.xml [Extension-Name: jsf, Specification-Version: 1.2, Implementation-Version: 1.2.9.0, exact-match: false]
The TagExtraInfo class : "com.sun.faces.taglib.FacesTagExtraInfo" specified by this tag could not be instantiated.
This may or may not be a unique scenario but the weblogic.xml is only located in one of my ear files and is not used in the others. The first error came from the ear with the weblogic.xml in it and the second came from one without. I'm assuming this was due to the jsf jars being used in the WEB-INF/lib prior to me taking over.
Thank you for any responses!
Edit 2/3:
Commented out com.sun.faces.taglib.FacesTagExtraInfo in html_basic.tld and jsf_core.tld. This removed the com.sun.faces.taglib.FacesTagExtraInfo error I was receiving. Now I'm getting:
java.lang.ClassCastException: Unable to convert "display: inline;" to type "javax.el.ValueExpression" for attribute "style"
Edit 2/4:
Found that even though my libraries are deployed my J2EE applications are not popping up in the "Applications that reference this library" section under any of the libraries.
This issue ended up being fixed by adding a weblogic.xml to each of the projects that did not have them and add in filtering into them to use project local libraries instead of what is provided by the server. This is not best practice probably but is also what was advised by Oracle. The project that did already have the weblogic.xml was just updated to include the filtering.
<?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:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>javax.faces.*</wls:package-name>
<wls:package-name>com.sun.faces.*</wls:package-name>
<wls:package-name>com.bea.faces.*</wls:package-name>
</wls:prefer-application-packages>
<wls:prefer-application-resources>
<wls:resource-name>javax.faces.*</wls:resource-name>
<wls:resource-name>com.sun.faces.*</wls:resource-name>
<wls:resource-name>com.bea.faces.*</wls:resource-name>
<wls:resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</wls:resource-name>
<wls:resource-name>META-INF/services/com.sun.faces.*</wls:resource-name>
</wls:prefer-application-resources>
</wls:container-descriptor>
</wls:weblogic-web-app
>

Eclipse error. valve The content of element type "jboss-web" must match ... jboss-web.xml

I use eclipse mars.2
I'm trying to import existing ecplipse project and i'm getting an error:
The content of element type "jboss-web" must match "(class-loading?,security-domain?,context-root?,virtual-host*,use-session-cookies?,replication-config?,resource-env-ref*,resource-ref*,security-role*,ejb-ref*,ejb-local-ref*,message-destination-ref*,message-destination*,webservice-description*,service-ref*,depends*,servlet*,authenticators*)".
jboss-web.xml file
<!DOCTYPE jboss-web PUBLIC
"-//JBoss//DTD Web Application 2.4//EN"
"http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
<jboss-web>
<security-domain>java:/jaas/SPNEGO</security-domain>
<valve>
<class-name>org.jboss.security.negotiation.NegotiationAuthenticator</class-name>
</valve>
</jboss-web>
I don't understand why jboss-web_4_0.dtd doesn't contain vavlve.
When i delete valve - the error disapears. But i need it.
Please help me.
Alan,
you should use different xml declaration for jboss-web.xml as this element was introduced first in JBoss AS 7. Your file uses dtd file for JBoss AS 4.0.x. ;)
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.org/schema/jbossas
http://www.jboss.org/schema/jbossas/jboss-web_7_0.xsd">
...
</jboss-web>

Maven Websphere JNDI Resource Binding

I have a small issue in which my maven project does not have a Target Resource JNDI Name.
A brief overview of this project. I have three java projects:
The Maven Ear, the back end (base livraries) project and the UI project. All of which are maven, have dependencies I need, compile and run with a main app which emulates the WAS.
So far the most relevant help I could find was to make sure I have a ibm-web-bnd.xml
I do have this file as I converted an existing UI project to a maven project. The project looks like this.
In my web.xml I also have
<resource-ref>
<description>
</description>
<res-ref-name>jdbc/DataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
In my ibm-web-bnd.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-bnd
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd"
version="1.0">
<virtual-host name="default_host" />
<resource-ref name="jdbc/DataSource" binding-name="jdbc/DataSource"/>
As it has been pointed out, I did not ask a question.
My question is how do I set a JNDI Resource Reference for my Maven UI project in WebSphere. I have all the required files and bindings for the project yet I can not run the maven EAR with the UI project in it.
I always get the error:
A resource reference binding could not be found for the jdbc/DataSource resource reference, defined for the codecoverageUI component.

How to load an external property file to Spring Boot in Wildfly

I wonder how can I load an external property of my application running inside Wildfly 9 as WAR, I tried to add a java parameter to Wildfly execution but it seems the application did not recognize the properties.
-Dspring.config.location=file:///C:\Temp\config\application.properties,classpath:application.properties
Is there any way how Spring Boot could read the external property file? I am trying to load and run one Spring Boot application as WAR inside Wildfly.
I'd appreciate any help.
Thanks.
In my linux system i have an entry in the standalone.xml:
<system-properties>
<property name="spring.config.location" value="file:/opt/jboss/wildfly/standalone/configuration/"/>
</system-properties>
I just defined the directory here, so it has to end with an "/".
In the directory "/opt/jboss/wildfly/standalone/configuration/" there is my application.yml.
If your springboot application is running inside Wildfly you don't need to read standalone.xml as an external file.
Get the property value directly with System.getProperty(PROPERTY_NAME);
I know it's a bit late for the answer, but maybe this helps:
Within your deployment-descriptor (web.xml), create environment-variables pointing to the spring config location file, i.e.
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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-app_3_0.xsd"
version="3.0">
<env-entry>
<env-entry-name>spring.config.location</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>file:[path-to-file]/[your-properties-file]
</env-entry-value>
</env-entry>
</web-app>
Working on Wildfly 25.0.0

Error: Projects containing version <unknown> deployment descriptors require XMI-format bindings or extensions files. ibm-web-bnd.xml

I have upgraded editor from Rad 7.5 to 8 and maven 2 to 3.
This happens just after importing existing maven projects in RAD 8, but I have no errors on any pom files.
The issue is with two xml files :
Projects containing version deployment descriptors require XMI-format bindings or extensions files. ibm-web-bnd.xml
/DocViewerWeb/WebContent/WEB-INF Unknown Validation Message
Projects containing version deployment descriptors require XMI-format bindings or extensions files. ibm-web-ext.xml
/DocViewerWeb/WebContent/WEB-INF Unknown Validation Message
Contents of those two files are:
<?xml version="1.0" encoding="UTF-8"?>
<web-bnd
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd"
version="1.0">
<virtual-host name="default_host" />
<ejb-ref name="ejb/MaintenanceServices" binding-name="ejblocal:com.tscdv.document.b.MaintenanceServices" />
<ejb-ref name="ejb/ServiceTipsDocumentServices" binding-name="ejblocal:com.tscdv.document.b.ServiceTipsDocumentServices" />
<ejb-ref name="ejb/ActivityDocumentServices" binding-name="ejblocal:com.tscdv.document.b.ActivityDocumentServices" />
<ejb-ref name="ejb/BulletinDocumentServices" binding-name="ejblocal:com.tscdv.document.b.BulletinDocumentServices" />
<ejb-ref name="ejb/CommonService" binding-name="ejblocal:com.tscdv.document.b.CommonService" />
<ejb-ref name="ejb/AdminServices" binding-name="ejblocal:com.tscdv.document.b.AdminServices" />
</web-bnd>
and
<?xml version="1.0" encoding="UTF-8"?>
<web-ext
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd"
version="1.0">
<reload-interval value="3"/>
<context-root uri="DocViewerWeb" />
<enable-directory-browsing value="true"/>
<enable-file-serving value="true"/>
<enable-reloading value="true"/>
<enable-serving-servlets-by-class-name value="true" />
</web-ext>
What could be the problem here?
I have posted another possibly related issue:
JSR250: CommonAnnotations for Java, 2.3: #Resource methods must be setters that follow the standard JavaBeans convention
Projects containing web.xml with version="2.4" or lower require ibm-web-bnd.xmi and ibm-web-ext.xmi.
Projects containing web.xml with version="2.5" or higher require ibm-web-bnd.xml and ibm-web-ext.xml.
Perhaps the change in tool versions has upgraded your web.xml version to 2.5, and now RAD is warning that this is incompatible with your web.xml?
In extension to the comment on bkail's answer (which is helpful) if you want to use web.xml version 2.5 you should use the following prolog and parent node. Technically the comment is inaccurate as the namespaces are missing http:// and will cause additional errors if you do not use this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
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-app_2_5.xsd"
version="2.5">

Categories