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
Related
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
>
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>
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 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.
I'm trying to deploy a CAS web application on JBOSS 7. The package name is cas-server-webapp-3.4.11.war.
I'm facing the following error during install:
09:37:06,951 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/cas-server-webapp-3.4.11]] (MSC service thread 1-5)
Exception sending context initialized event to listener instance of class org.springframework.web.util.Log4jConfigListener: java.lang.IllegalArgumentException: Invalid 'log4jConfigLocation' parameter: class path resource [log4j.xml] cannot be resolved to absolute file path because it does not reside in the file system: vfs:/D:/Programming/jboss7/bin/content/cas-server-webapp-3.4.11.war/WEB-INF/classes/log4j.xml
Deployment package is located in D:\Programming\jboss7\standalone\deployments\cas-server-webapp-3.4.11.war, but obviously JBOSS tries to resolve paths to D:/Programming/jboss7/bin/content/cas-server-webapp-3.4.11.war.
How I can change this path?
For CAS 1.5 log4j configuration is defined in WEB-INF/cas.properties file where you define the location.
I used this configuration:
log4j.config.location=${jboss.server.base.dir}/deployments/cas-server-webapp.war/WEB-INF/classes/log4j.xml
However, when application server doesn't unpack war during deployment it doesn't work anyway because this file is not on filesystem. So the easiest way is to disable initialization of this bean at all by deleting src/main/webapp/WEB-INF/spring-configuration/log4jConfiguration.xml file.
Also this issue is relevant to this topic.
Solution is the following:
In persistence.xml put the following content:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="CasPersistence" transaction-type="RESOURCE_LOCAL">
<class>org.jasig.cas.services.RegisteredServiceImpl</class>
<class>org.jasig.cas.ticket.TicketGrantingTicketImpl</class>
<class>org.jasig.cas.ticket.ServiceTicketImpl</class>
<class>org.jasig.cas.ticket.registry.support.JpaLockingStrategy$Lock</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
</properties>
</persistence-unit>
In web.xml instead of:
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.xml</param-value>
</context-param>
put
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>WEB-INF\classes\log4j.xml</param-value>
</context-param>
Hope this will help & save time to others.