modifying Jboss classpath - jboss

I have a jar file named "xyz.jar" that have the file "abc.xml" and I have one more file with same name "abc.xml" not bundled with "xyz.jar" . I would like to have the JBoss to see the "abc.xml" which isnt bundled with "xyz.jar" in the first place before it sees the one that is bundled with "xyz.jar". The reason is , the file "abc.xml" that placed externally can be exposed for modification and that way Jboss can see that modification without restarting the server.
How can I achieve this .. I mean how can I set the classpath for Jboss to see the "abc.xml" that isnt bundled with "xyz.jar" in the first place ?

If you know the location of abc.xml on your filesytem you can just load it using a fully qualified path. For example
final InputStream is = new FileInputStream("/foo/bar/abc.xml");

It isn't about the JBoss classpath. It depends on the way you chose to open your resource abc.xml into your jar xyz.jar

You can set classpath to load resource by editing JBOSS\bin\run.bat
This line allow you to add:
if "x%JBOSS_CLASSPATH%" == "x" (
set "RUN_CLASSPATH=%RUNJAR%;your\link\here;"
) else (set "RUN_CLASSPATH=%JBOSS_CLASSPATH%;%RUNJAR%;your\link\here;"
)
then execute run.bat

I have added these entries in run.bat 'if "x%JBOSS_CLASSPATH%" == "x" (
set "RUN_CLASSPATH=%RUNJAR%;JBOSS_CLASSPATH.configuration;"
) else (set "RUN_CLASSPATH=%JBOSS_CLASSPATH%;%RUNJAR%;JBOSS_CLASSPATH.configuration;"
)
Log in got the below ERROR
FOUNDATION_CONFIG_MGR_INIT: com.exception.SystemException: Cannot find the config.xml file in the classpath
Application: Foundation ...

Related

Debugging OfBiz in Eclipse gives MissingResourceException

I downloaded the OfBiz Java application and the following line throws an MissingResourceException:
ResourceBundle res = ResourceBundle.getBundle(settingsResourceName);
The value of settingsResourceName is "cache", but I cannot find any file called cache.properties or cache_en.properties.
Where should I be looking? I'm new to Java. All my research on SO says there should be such a file.
I imported OfBiz in Eclipse using the Import menu option and selecting Existing Project from File System (I'm not in front of my dev machine so I don't remember the exact wording). But I chose the root folder of the downloaded OfBiz.
I then added the appropriate VM Arguments in the Run Configuration to get it to run properly at least. And that's it, on the first Run I got the above error. I think it has to do with a missing class path but I don't know what to add to class path.
Here is the stack trace:
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.apache.ofbiz.base.util.Debug.<clinit>(Debug.java:68)
at org.apache.ofbiz.base.container.ContainerLoader.load(ContainerLoader.java:61)
at org.apache.ofbiz.base.start.StartupControlPanel.loadStartupLoaders(StartupControlPanel.java:202)
at org.apache.ofbiz.base.start.StartupControlPanel.start(StartupControlPanel.java:69)
at org.apache.ofbiz.base.start.Start.main(Start.java:84)
Caused by: java.util.MissingResourceException: Can't find bundle for base name cache, locale en
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:773)
at org.apache.ofbiz.base.util.cache.UtilCache.setPropertiesParams(UtilCache.java:174)
at org.apache.ofbiz.base.util.cache.UtilCache.setPropertiesParams(UtilCache.java:170)
at org.apache.ofbiz.base.util.cache.UtilCache.setPropertiesParams(UtilCache.java:166)
at org.apache.ofbiz.base.util.cache.UtilCache.<init>(UtilCache.java:124)
at org.apache.ofbiz.base.util.cache.UtilCache.createUtilCache(UtilCache.java:769)
at org.apache.ofbiz.base.util.UtilProperties.<clinit>(UtilProperties.java:75)
... 5 more
UPDATE:
My mistake, I found two files both called cache.properties in the following folders:
ofbiz-trunk/build/resources/main
ofbiz-trunk/framework/base/config
But these are folders, not packages. I tried putting them in the .classpath but that did not work, I still kept getting the same error.
As suspected, I knew it was because of a missing reference to a class path. After looking at a section on this page: http://www.opensourcestrategies.com/ofbiz/ofbiz_eclipse.php, I learned that I was supposed to go to the Java Build Path and in the Libraries tab, click on Add Class Folder, then point that to ofbiz-trunk/framework/base/config. Which is where I have one of the cache.properties files.

How to set CLASSPATH for Apache Derby DB

I tried to set the Path environment variable of entering the path: "C: \ Program Files \ Java \ jdk1.8.0_101 \ db \ lib" (.jar file path) but nothing ...
I created a new variable called CLASSPATH by entering the same path and still nothing ...
How can I link this path to the compiler?
compile error
You can't set CLASSPATH to the directory where the jar files are stored; you have to specify the actual jar file by its full name.
This is a difference between a directory full of java .class files, versus a directory full of java .jar files.
So set your CLASSPATH to:
c:\Program Files\Java\jdk1.8.0_101\db\lib\derby.jar;c:\Program Files\Java\jdk1.8.0_101\db\lib\derbyclient.jar
In your particular case, since the only class you're trying to reference is ClientDriver, which is in derbyclient.jar, you could just set CLASSPATH to c:\Program Files\Java\jdk1.8.0_101\db\lib\derbyclient.jar and leave derby.jar out, but at some point in the future you might want to reference other Derby classes, such as EmbeddedDriver, so you might as well put both derby.jar and derbyclient.jar into your CLASSPATH now.

NetBeans and JBoss

I am reading this tutorial http://www.tutorialspoint.com/ejb/index.htm. I have installed NetBeans IDE 8.0.2 and JBoss 5 server. And I have a problem with this part of the tutorial http://www.tutorialspoint.com/ejb/ejb_create_application.htm with jndi.properties file. I don't understand where should i put it? I have put it here C:\Users\Mimo\Documents\NetBeansProjects\EjbTester\jndi.properties in my EjbTester project and I get the following exceptions.
run:
java.io.FileNotFoundException: C:\Users\Mimo\Documents\NetBeansProjects\EjbTester\jndi.properties (The system cannot find the file specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.(FileInputStream.java:138)
at java.io.FileInputStream.(FileInputStream.java:93)
at com.tutorialspoint.test.EJBTester.(EJBTester.java:25)
at com.tutorialspoint.test.EJBTester.main(EJBTester.java:39)
Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:350)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at com.tutorialspoint.test.EJBTester.testStatelessEjb(EJBTester.java:53)
at com.tutorialspoint.test.EJBTester.main(EJBTester.java:41)
Thanks for all your help!
Right click on project name in Project explorer window and select empty file name is jndi.properties and add info it... its work

netbeans manifest.mf is read-only because it is inside

I want to change contains of file Meta-inf/Manifest.mf . I try this:
org.openide.filesystems.FileObject projectDirectory = project.getProjectDirectory();
FileObject modulesFileObject = projectDirectory.getFileObject("build/cluster/modules/");
properties.store(propertiesFile.getOutputStream(), null);
but I got this Exeption:
manifest.mf is read-only because it is inside.
Jar file is not read-only. So can you help me, please?
PS: I use NetBeans Platform RCP 7.11 , java 1.7_07
Thank Jirka
The problem is, that the JarSystem is read-only.
Jirka

RxTx installation on windows java.lang.NoClassDefFoundError: gnu/io/CommPort

I put rxtxcomm.jar into jre/lib/ext folder, but I still get NoClassDefFoundError Isn't this folder automatically taken into the global classpath?
Thanks
yes it is taken automatically to classpath, but RXTXcomm uses JNI /native external libraries (.so and .dll files), you must provide the path to them when running your program in command line:
java -jar yourprogram.jar -Djava.library.path="PATH_TO_EXTERNAL_LIBRARIES"
for linux:
suppose you unpacked the rxtx.zip to
/home/user/
if you have 32bit x86 platofrm:
PATH_TO_EXTERNAL_LIBRARIES = /home/user/Linux/i686-unknown-linux-gnu/
if you have 64bit x86 platform the it would be:
PATH_TO_EXTERNAL_LIBRARIES = /home/user/Linux/x86_64-unknown-linux-gnu/
for windows:
suppose you downloaded and unpacked it to C:\rxtxt
PATH_TO_EXTERNAL_LIBRARIES = C:\rxtxt\Windows\i368-mingw32\
If you find it cumbersome to do it from command line you can do it from yout code (before opening port via RXTXcomm):
System.setProperty("java.library.path","PATH_TO_EXTERNAL_LIBRARIES");
EDIT:
of course, you must put RXTXcomm.jar in your classpath in addition to all of the above. If running from command line as jar packaged program - yourprogram.jar - inside the jar you must have a META-INF folder that contains MANIFEST.MF with the following entries:
Class-Path: lib/RXTXcomm.jar
Main-Class: pkg.Main
and yourprogram.jar must be in folder which has folder lib in which is RXTXcomm.jar, also
the class with
public static void main(String[] args)
method must be called Main and reside in package named pkg (just replace pkg.Main with whatever you have).
Then you can run your program succesfully and open a serial port if you have one. This approach also eliminates the need to copy anything in jre/lib/ext folder
EDIT^2:
or, if you don't want to pack your program in jar, position yourself in folder which contains the folder pkg and write:
java -cp PATH_TO_RXTX/RXTXcomm.jar -Djava.library.path="PATH_TO_EXTERNAL_LIBRARIES" pkg.Main
(all paths can be relative or absolute)
EDIT^3:
but I would recommend Java Simple Serial Connector instead of RXTXcomm:
it handles heavy load from multiple threads as opposed to RXTXcomm (tested in production)
external libraries are packed in jar so there is no need for setting java.library.path