Following matter is JBossAS 7.1 Developer Guider:
Change ResourceBundle location In previous versions of AS, the
JBOSS_HOME/server//conf/ was available in the classpath.
Hence the properties files in that location were available in the
classpath of the application.
In AS7, to get those properties available in the classpath, package
them within your application. For example, if you are deploying a .war
then package those properties in WAR WEB-INF/classes/ folder. If you
want those properties accessible to all components in a .ear, then
package them at the root of some .jar and place that jar in EAR lib/
folder.
But this method is not so good if there are too many resource files, we can't package all resource file to jar or ear.
For the new class loading method - module. I try following method:
create module.xml file .. you will chose module name... for instnace
custom.myconfig
<resources>
<resource-root path="."/>
<!-- Insert resources here -->
</resources>
<dependencies>
</dependencies> </module> In your jboss-deployment-structure.xml include this module to your app
<jboss-deployment-structure>
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<dependencies>
<module name="custom.myconfig/>
</dependencies>
<resources>
</resources>
</deployment>
<sub-deployment name="My_WAR.war">
<dependencies>
<module name="custom.myconfig" />
</dependencies>
</sub-deployment>
https://community.jboss.org/message/723631
But I found you can't set absolute path to path, like: [resource-root path=""C:\resourcefolder"].
That's means you also need include all resource files on JBossAS 7.
It is very simple on JBossAS 5.x-6.x, only need add folder path like "C:\resourcefolder" to classpath is OK. But its like an impossible mission on JBossAS7.
Finally, I soft link resource folder to JBossAS 7.....
Linux:
In -s
Windows:
MKLINK /D
or
Junction.exe
Related
I have a property file named abc.properties in my WAR's WEB-INF/classes. Also, I have placed it inside a (correctly registered) module. When I then call:
ResourceBundle.getBundle("abc")
which file would be picked?
In our production environment, the file placed inside the WAR is being picked (consistently) but in the UAT environment (with the same version of JBoss), its the property file in the module that is getting picked (consistently)
Is there a defined order in which resources are loaded into classpath by JBoss, or does this happen randomly? (We haven't observed any randomness though.)
(The module is correctly registered in the production server, as other resources, namely the ojdbc jar placed in the module are getting loaded correctly)
This is our module.xml in the registered module
<module xmlns="urn:jboss:module:1.0" name="com.oracle">
<resources>
<resource-root path="ojdbc6.jar"/>
<resource-root path="properties"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
abc.properties is placed inside the properties folder as defined in the above module
P.S: I understand that its a wrong practice to have two property files of the same name placed in such a manner, but I want to know why am I seeing such a behaviour.
You can check the official documentation regarding the classloading precedence for EAP 6.4
I want to have this sort of jboss-deployment-structure.xml :
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<deployment>
<resources>
<resource-root path="{PROPERTY_FILE_LOCATION}" />
</resources>
</deployment>
</jboss-deployment-structure>
By this, I want property files placed at the location defined by the environment variable PROPERTY_FILE_LOCATION to be loaded in the classpath. Is it possible to do this? I'm using JBoss 6.4
My entire purpose here is to get my property files placed in an external location, to be loaded into the classpath by JBoss (the files are being used in a jar that I cannot modify). I don't want to hardcode the location either.
I have developed a maven-based project (maven-3.3.9) using jboss-eap-6.4 in IntelliJIDEA 14.0. I am using bouncy castle libraries and I have to set them as provided scope in maven dependency.
Where exactly should I put the bouncy castle jar files?
What configuration should I set?
I have tried two options for the 1st question as follows:
I put jar files here: jboss-eap-6.4\modules\org\bouncycastle\main\
and
I put jar files here: jboss-eap-6.4\modules\system\layers\base\org\bouncycastle\main\
Also, I have provided the following configuration in module.xml beside the jar files:
<?xml version=1.0" encoding=UTF-8"?>
<module xmlns="run:jboss:module:1.1" name="org.bouncycastle">
<resources>
<resource-root path="bcpkix-jdk15on-1.54.jar"/>
<resource-root path="bcprov-jdk15on-1.54.jar"/>
</resources>
<dependencies>
<module name="javax.api" slot="main" export="true"/>
</dependencies>
</module>
However, when I clean and install maven I get the following error:
error during artifact deploment
caused by java.lang.RunTimeException:...
caused by java.lang.NoClassDefFoundError:...
caused by java.lang.ClassNotFoundException:...
The errors you mentioned are deployment errors those are not related to maven.
To add a JBoss module to your application create a file named WEB-INF\jboss-deployment-structure.xml and add the module in dependency. In your case the file content should be as follows.
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.bouncycastle"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
The while deployment jboss will load the module in to classpath.
I'm trying to load a properties file using Spring's #PropertySource annotation. The properties file is stored in a Wildfly 8 module. The error message that I'm getting is:
class path resource [campaigner.properties] cannot be opened because it does not exist
Here's the Java code, which is used by the application's services.
#Configuration
#PropertySource("classpath:campaigner.properties")
class ServiceConfigImpl implements ServiceConfig
{
#Autowired
private Environment env;
#Bean(name = "serviceConfig")
public ServiceConfig getServiceConfig()
{
return new ServiceConfigImpl(this.env);
}
}
Here's my jboss-deployment-structure.xml, which I'm putting in the META-INF directory of my .ear file.
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="com.dr_dee_sw.campaigner" />
</dependencies>
</deployment>
</jboss-deployment-structure>
I've also put a MANIFEST.MF file in the META-INF directory
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.9.4
Created-By: 1.7.0_71-b14 (Oracle Corporation)
Dependencies: com.dr_dee_sw.campaigner
Here's my module file, which I've put in WILDFLY_HOME\modules\com\dr_dee_sw\campaigner\main directory, along with the campaigner.properties file
<module xmlns="urn:jboss:module:1.1" name="com.dr_dee_sw.campaigner">
<resources>
<resource-root path="."/>
</resources>
</module>
What am I missing?
This page led me to the answer: https://www.javacodegeeks.com/2012/09/jboss-as-7-classloading-explained.html. My jboss-deployment-structure.xml was wrong. I have an EJB-JAR file inside the EAR file and that needs to be the focus of that file. So, I had to switch from using <deployment> to <sub-deployment> as shown below.
<jboss-deployment-structure>
<sub-deployment name="campaigner-service.jar">
<dependencies>
<module name="com.dr_dee_sw.campaigner" />
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
I'm trying to setup a CORBA enabled application on JBoss 7.1.1 Final. It seems that I'm missing something because everything I try results in another exception. So, what I tried:
standalone -c standalone-ha.xml -Djboss.node.name=nodeA or
standalone -c standalone-full-ha.xml -Djboss.node.name=nodeA
then the 2nd line here
GlobalData.orb = org.omg.CORBA.ORB.init(args, p);
orb.resolve_initial_references("NameService");
throws the exception:
(MSC service thread 1-9) IDL:omg.org/CORBA/ORB/InvalidName:1.0: org.omg.CORBA.ORBPackage.InvalidName: IDL:omg.org/CORBA/ORB/InvalidName:1.0
at org.jacorb.orb.ORB.resolve_initial_references(ORB.java:1343) [jacorb-2.3.1.jbossorg-1.jar:]
at MyApp.startServer(MyApp.java:145) [server.jar:]
My /conf folder contains a jacorb.properties with the entry
ORBInitRef.NameService=corbaloc::localhost:3828/JBoss/Naming/root
Can anyone bring some light into the dark?
Thanks, Peter
I found solution for that problem, Jacorb require mandatory configuration (jacorb.propeity)
you can get that file from JBoss 4.2.2
Then
you need to include that file in your class path, to do that we create custom module
for instance go to jboss modules directory
create sub directory custom/myconfig/main for example
there add your property files
create module.xml file .. you will chose module name... for instnace custom.myconfig
<module xmlns="urn:jboss:module:1.1" name="custom.myconfig">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="."/>
<!-- Insert resources here -->
</resources>
<dependencies>
</dependencies>
</module>
In your jboss-deployment-structure.xml include this module to your app
<jboss-deployment-structure>
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<dependencies>
<module name="custom.myconfig/>
</dependencies>
<resources>
</resources>
</deployment>
<sub-deployment name="My_WAR.war">
<dependencies>
<module name="custom.myconfig" />
</dependencies>
</sub-deployment>
Hope that help as it work with me