Jboss 4.2 Class loading exception - java

I have a jar in server/lib/sample.jar.
sample.jar file consists .class files related to application
so how should access server/lib instated of application.war/web-inf/classes .
jboss-web.xml
<class-loading java2ClassLoadingCompliance="false">
<loader-repository>
com.example:loader=sample.jar
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</class-loading >
keeping sample.jar in application.war/web-inf/lib got exception is
2013-05-16 10:28:58,388 INFO [STDOUT] [Mobee]- INFO 2013-05-16 10:28:58,388 [] LoadSystemDataCommand - ....................LoadSystemDataCommand.......................
2013-05-16 10:35:25,747 DEBUG [org.jboss.deployment.scanner.URLDeploymentScanner] Added url: file:/D:/Mobee Admin-ManamDB/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_4.2_Runtime_1_Server1368615125350/deploy/
2013-05-16 10:36:02,472 DEBUG [org.jboss.resource.connectionmanager.IdleRemover] run: IdleRemover notifying pools, interval: 450000
2013-05-16 10:38:40,215 WARN [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_58] - Abort of action id 7f000001:e258:51948a81:33 invoked while multiple threads active within it.
2013-05-16 10:38:40,215 WARN [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.CheckedAction_2] - CheckedAction::check - atomic action 7f000001:e258:51948a81:33 aborting with 1 threads active!
2013-05-16 10:38:40,242 INFO [STDOUT] [Mobee]-ERROR 2013-05-16 10:38:40,242 [] SystemStartupObserver - Error While Loading System Propertiesorg.hibernate.PersistentObjectException: detached entity passed to persist: com.manam.mobee.persist.entity.MobeeVariable

Please refer below answer by skaffman
jboss-4-2-class-loading
Have a look at JBossClassLoadingUseCases. Your situation seems to be Use Case 4 (i.e. the class will be loaded from server/lib in preference to WEB-INF/classes.
What you seem to want is Use Case 3 (i.e. WEB-INF/classes preferred to server/lib), in which case you should omit the java2ParentDelegation=true config option from jboss-web.xml (or set it to false, which is the default).
ClassLoading Configuration
Other reference worth evaluating :
JBoss classloading problem
How do I tell JBoss 4.2.3.GA to load jars in my war file lib directory first?
JBoss classloading problem

Related

OrientDB Server partly ignores ORIENTDB_HOME

I'm trying to start an embedded OrientDB server. I set the ORIENTDB_HOME to a folder that contains the config/ and plugins/ folders. I also included my config file in the classpath, because the server didn't seem to load my config file even though it has the default name.
Now it does start and apply my config, however apparently the application directory is used as ORIENTDB_HOME, because my plugins aren't loaded and the database is created there instead of where I want it to.
This is my code:
public void startServer() {
try {
System.setProperty("ORIENTDB_HOME", "C:\\my\\orientdb_home\\path");
server = OServerMain.create(true);
// server.startup(); // this doesn't load the correct config
server.startup(getClass().getResourceAsStream("/config/orientdb-server-config.xml")); // workaround
server.activate();
OServerNetworkListener httpListener = server.getListenerByProtocol(server.getNetworkProtocols().get("binary"));
binaryPort = httpListener.getInboundAddr().getPort();
httpListener = server.getListenerByProtocol(server.getNetworkProtocols().get("http"));
httpPort = httpListener.getInboundAddr().getPort();
System.out.println("Started OrientDB Server.\nBinary Port is " + binaryPort + "\nHTTP Port is " + httpPort);
} catch (Exception e) {
e.printStackTrace();
}
}
The fascinating thing is that the log output clearly says it's using the correct directory for the databases, but it doesn't do so.
2019-06-14 09:32:23:556 INFO Loading configuration from input stream [OServerConfigurationLoaderXml]
2019-06-14 09:32:23:731 INFO OrientDB Server v2.2.37 (build a7541e7ceeabf592dd9a7b2928b6c023cbc73193, branch 2.2.x) is starting up... [OServer]
2019-06-14 09:32:23:741 INFO Databases directory: C:\my\orientdb_home\path\databases [OServer]
2019-06-14 09:32:23:830 INFO Configuration of usage of soft references inside of containers of results of SQL execution [OMemoryAndLocalPaginatedEnginesInitializer]
2019-06-14 09:32:23:831 INFO Initial or maximum values of heap memory usage are NOT set, containers of results of SQL executors will NOT use soft references by default [OMemoryAndLocalPaginatedEnginesInitializer]
2019-06-14 09:32:23:832 INFO Auto configuration of disk cache size. [OMemoryAndLocalPaginatedEnginesInitializer]
2019-06-14 09:32:23:919 INFO 17066577920 B/16275 MB/15 GB of physical memory were detected on machine [ONative]
2019-06-14 09:32:23:919 INFO Detected memory limit for current process is 17066577920 B/16275 MB/15 GB [ONative]
2019-06-14 09:32:23:921 INFO OrientDB auto-config DISKCACHE=3,618MB (heap=3,618MB direct=3,618MB os=16,275MB) [OMemoryAndLocalPaginatedEnginesInitializer]
2019-06-14 09:32:23:922 INFO Lowering disk cache size from 3,618MB to 3,616MB. [OGlobalConfiguration]
2019-06-14 09:32:24:117 INFO Listening binary connections on 127.0.0.1:2424 (protocol v.36, socket=default) [OServerNetworkListener]
2019-06-14 09:32:24:120 INFO Listening http connections on 127.0.0.1:2480 (protocol v.10, socket=default) [OServerNetworkListener]
2019-06-14 09:32:25:081 INFO Storage 'plocal:databases/pvRelations' is created under OrientDB distribution : 2.2.37 (build a7541e7ceeabf592dd9a7b2928b6c023cbc73193, branch 2.2.x) [OLocalPaginatedStorage]
2019-06-14 09:32:27:607 INFO {db=pvRelations} -> Loaded plocal database 'pvRelations' [OServer]
2019-06-14 09:32:27:609 INFO Found ORIENTDB_ROOT_PASSWORD variable, using this value as root's password [OServer]
2019-06-14 09:32:27:621 INFO ODefaultPasswordAuthenticator is active [ODefaultPasswordAuthenticator]
2019-06-14 09:32:27:623 INFO OServerConfigAuthenticator is active [OServerConfigAuthenticator]
2019-06-14 09:32:27:625 INFO OSystemUserAuthenticator is active [OSystemUserAuthenticator]
2019-06-14 09:32:27:634 INFO Installed GREMLIN language v.2.6.0 - graph.pool.max=50 [OGraphServerHandler]
2019-06-14 09:32:27:638 WARNI Authenticated clients can execute any kind of code into the server by using the following allowed languages: [sql] [OServerSideScriptInterpreter]
2019-06-14 09:32:27:638 INFO OrientDB Studio available at http://127.0.0.1:2480/studio/index.html [OServer]
2019-06-14 09:32:27:638 INFO OrientDB Server is active v2.2.37 (build a7541e7ceeabf592dd9a7b2928b6c023cbc73193, branch 2.2.x). [OServer]
To clarify again: The directory C:\my\orientdb_home\path\databases isn't used, instead it's path\to\my\application\databases.
What am I doing wrong? How do I tell the server to use the directory of my choice to search for config and plugins as well as store the databases?
EDIT:
I just noticed that in fact the databases directory is used, but only for the OSystem database. My own database is stored at the wrong location. I defined it in my config file:
...
<storages>
<storage name="myDB" path="plocal:databases/myDB" userName="admin" userPassword="admin" loaded-at-startup="true" />
</storages>
...
EDIT2:
So I noticed, the wrong database location is due to the manually configured storage path in the config file. However, this still doesn't explain why I need to directly provide my config file and why my plugins (OrientDB Studio) aren't loaded.
Turns out, I should have read the server.bat more carefully. While setting ORIENTDB_HOME apparently does set the default database directory, the default config file isn't located under %ORIENTDB_HOME%\config\orientdb-server-config.xml. I had to set the environment variable orientdb.config.file.
My plugin wasn't loaded because it didn't reside in the plugins folder, but was included to my classpath, which apparently isn't enough.

Spring boot application has a delay loading enviroment variables as an init.d service

We have a spring boot (version 1.3.3) application running as an init.d service. It's configurated as it's stated in the spring boot documentation for deployment here.
We use a ".conf" file to define the RUN_ARGS, the JVM arguments and the environment variables in the scope of the app.
We have no problem with the app functionality, but when we start the service (service myapp start) it creates a folder called "LOGS_PATH_IS_UNDEFINED" and it starts to log inside it. After a few lines, the app continues to log in the folder defined in the environment variable defined in the ".conf" file.
This is the myapp.conf content:
LOGS_PATH="/usr/logs"
JAVA_HOME="/usr/java/jdk1.8.0_77"
JAVA_OPTS="-Xms256m -Xmx512m"
RUN_ARGS="--spring.profiles.active=staging --server.port=8090"
This is the log content in the "LOGS_PATH_IS_UNDEFINED" (without sensible info):
2018-10-08 09:43:42,549 INFO [main] Application:? : Starting Application v1.0 on server with PID xxxx (/opt/myapp/myapp.jar started by server in /opt/myapp)
2018-10-08 09:43:42,552 INFO [main] Application:? : The following profiles are active: staging
2018-10-08 09:43:51,106 INFO [localhost-startStop-1] WebConfigurer:? : Web application configuration, using profiles: [staging]
2018-10-08 09:43:51,133 INFO [localhost-startStop-1] WebConfigurer:? : Web application fully configured
2018-10-08 09:43:59,435 INFO [localhost-startStop-1] Application:? : Running with Spring profile(s) : [staging]
2018-10-08 09:44:01,215 INFO [main] ThymeleafConfiguration:? : loading non-reloadable mail messages resources
2018-10-08 09:44:14,223 INFO [main] Application:? : Started Application in 33.926 seconds (JVM running for 35.172)
2018-10-08 09:44:14,223 INFO [main] Application:? : Access URLs:
----------------------------------------------------------
Local: http://127.0.0.1:8090
External: http://127.0.1.1:8090
----------------------------------------------------------
2018-10-08 09:44:27,844 INFO [http-nio-8090-exec-1] CustomPersistentRememberMeServices:? : presentedToken=xxxxx / tokenValue=xxxxx
The DevOps have no idea why and they are demanding us to fix it.
We do not have this problem running the app in the command line as an executable jar.
We use Logback for logging.
Thanks in advance for the help!
We fixed it!
The environment variable was not set in the server. A simple "export" before the LOGS_PATH="/usr/logs" line in the ".conf" fixed the problem.

Apache Commons Configuration -- Cannot load/use config files

I've been trying to configure a Java application (specifically my integration tests) with absolutely no success. I originally had a single XMLConfiguration which I could load and use without issue. My directory setup looks like:
src
test
java
mypackage
resources
Before, I had a file myconfig.xml in the resources directory. I was loading it it like so:
private static XMLConfiguration configuration = null;
public static void configure() {
try {
configuration = new XMLConfiguration("myconfig.xml");
}
catch (ConfigurationException e) {
System.err.println(e);
}
}
Now I'm trying to make it so that users can configure the application themselves by writing a configuration file in /etc or /home or whatever, so I made a new file in the same location called config-test.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<configuration>
<!-- Attempt to load configuration provided on the system -->
<xml fileName="/etc/myconf/myconfig.xml" config-optional="true" />
<!-- Load default configuration from the classpath -->
<xml fileName="myconfig.xml" />
</configuration>
The file /etc/myconf/myconfig.xml does not exist, but that's the whole point of making it optional. I've tried a few different approaches to loading my configuration, including how the documentation does it: http://commons.apache.org/configuration/userguide/howto_configurationbuilder.html. What I have currently is the following:
private static CombinedConfiguration configuration = null;
public static void configure() {
try {
DefaultConfigurationBuilder builder =
new DefaultConfigurationBuilder("config-test.xml");
configuration = builder.getConfiguration(true);
System.err.println("Yay");
}
catch (ConfigurationException e) {
System.err.println("Herp");
}
catch (Exception e) {
System.err.println("Derp");
}
}
When I run my integration tests, I see no Yay, I see no Herp and I see no Derp. If I place a println before I try to load things, it does print so configure is being called. The output I get from commons configuration amounts to:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
13:36:57.752 [main] DEBUG o.a.c.c.ConfigurationUtils - ConfigurationUtils.locate(): base is null, name is config-test.xml
13:36:57.753 [main] DEBUG o.a.c.c.DefaultFileSystem - Could not locate file config-test.xml at null: no protocol: config-test.xml
13:36:57.756 [main] DEBUG o.a.c.c.ConfigurationUtils - Loading configuration from the context classpath (config-test.xml)
13:36:57.766 [main] DEBUG o.a.c.c.DefaultConfigurationBuilder - Creating configuration null with name null
13:36:57.795 [main] DEBUG o.a.c.c.ConfigurationUtils - ConfigurationUtils.locate(): base is null, name is config-test.xml
13:36:57.795 [main] DEBUG o.a.c.c.DefaultFileSystem - Could not locate file config-test.xml at null: no protocol: config-test.xml
13:36:57.796 [main] DEBUG o.a.c.c.ConfigurationUtils - Loading configuration from the context classpath (config-test.xml)
13:36:57.800 [main] DEBUG o.a.c.c.DefaultConfigurationBuilder - Creating configuration null with name null
Tests run: 56, Failures: 2, Errors: 0, Skipped: 16, Time elapsed: 2.589 sec <<< FAILURE!
Results :
Failed tests: initialize(mypackage.ImportTestIT): org/apache/commons/beanutils/PropertyUtils
initialize(mypackage.TransferTestIT): org/apache/commons/beanutils/PropertyUtils
Tests run: 56, Failures: 2, Errors: 0, Skipped: 16
Those initialize methods are just calling configure and then trying to get data from the configuration that is loaded. I've been working with this for a couple hours now and could really use another pair of eyes. Any ideas? Is there anything I could have changed that I'm not mentioning that would affect this? Thanks.
Edit #1 (1:58pm): After making sure beanutils were on the classpath, I now get a brutal explosion of stack trace that starts with
Running TestSuite
14:00:16.088 [main] DEBUG o.a.c.c.ConfigurationUtils - ConfigurationUtils.locate(): base is null, name is config-test.xml
14:00:16.089 [main] DEBUG o.a.c.c.DefaultFileSystem - Could not locate file config-test.xml at null: no protocol: config-test.xml
14:00:16.093 [main] DEBUG o.a.c.c.ConfigurationUtils - Loading configuration from the context classpath (config-test.xml)
14:00:16.103 [main] DEBUG o.a.c.c.DefaultConfigurationBuilder - Creating configuration null with name null
14:00:16.178 [main] DEBUG o.a.c.c.ConfigurationUtils - ConfigurationUtils.locate(): base is file:///home/pgarrity/projects/myproject/target/test-classes/config-test.xml, name is /etc/myconf/myproject/myconfig.xml
14:00:16.179 [main] DEBUG o.a.c.c.DefaultFileSystem - Could not locate file /etc/myconf/myproject/myconfig.xml at file:///home/pgarrity/projects/myproject/target/test-classes/config-test.xml: /etc/myconf/myproject/myconfig.xml (No such file or directory)
14:00:16.181 [main] DEBUG o.a.c.c.DefaultConfigurationBuilder - Load failed for optional configuration xml: Cannot locate configuration source /etc/myconf/myproject/myconfig.xml
14:00:16.185 [main] WARN o.a.c.c.DefaultConfigurationBuilder - Internal error
org.apache.commons.configuration.ConfigurationException: Cannot locate configuration source /etc/myconf/myproject/myconfig.xml
at org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfiguration.java:259) ~[commons-configuration-1.8.jar:1.8]
at org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfiguration.java:238) ~[commons-configuration-1.8.jar:1.8]
And so on and so on... but I do see 'Yay' now. Now what I don't get is that it doesn't seem to be looking for my non-optional configuration source, or assuming it's in a location I never told it to look.
Edit #2:
I looked through my output a bit more and buried in the complaints from commons I found that it seemed to load the correct file eventually. I think I may have it working? Maybe my path to the properties change when I load it like this... I've got some stuff to try. Anyway, the problem that I asked about has been fixed. Thanks for the help.
You seem to be missing commons-beanutils on your classpath. Make sure that jar is there.
Pfft. A multi-page document talks about how to load a configuration file. But did they forget to implement detection of file URLs in absolute Windows paths such as c:\Users\USER\FOO\bar.xml? Commons 1.9 will show this scrupulous message,
DEBUG DefaultFileSystem - Could not locate file C:\Users\USER\FOO\bar.xml at null: unknown protocol: c
https://github.com/apache/commons-configuration/blob/CONFIGURATION_1_9/src/main/java/org/apache/commons/configuration/DefaultFileSystem.java#L281

WTP(eclipse3.7) can not start tomcat6 in a debug mode under Windows7

WTP(eclipse3.7) can not start tomcat6 in a debug mode under Windows7,Here is the error log:
!ENTRY org.eclipse.wst.server.core 4 0 2011-11-23 22:26:33.001
!MESSAGE Server Tomcat v6.0 Server at localhost failed to start.
As there is not enough information to find the root cause, here are some things which you can try:
- Is Tomcat starting from outside i.e. not from eclipse but by launching stratup.bat file of Tomcat? Make sure your tomcat is working properly.
- did you configure resource(your project) while configuring the WTP.
- As you have very specifically said that it's not working in debug mode, is it working on normal mode? If yes, then you have to copy the start configuration to debug configuration.
Do share if you have some more information on this.

How to configure commons-logging for JUnit testing of Hibernate

I'm trying to debug some hibernate functionality in a spring app with a junit test and commons logging, but I can't seem to get anything other than the default INFO messages to appear. I'm also running these junit tests from Eclipse.
I've had no luck from the spring forums either.
I'm particularly interested in the debug logging output by Hibernate (to try and figure out why it takes 23 seconds to run this test).
Current output shows the default setting of INFO:
Mar 29, 2011 4:44:35 PM org.springframework.test.AbstractTransactionalSpringContextTests onSetUp
INFO: Began transaction: transaction manager [org.springframework.orm.hibernate3.HibernateTransactionManager#5f873eb2]; defaultRollback true
testGetSubjectsForSite time: [00:00:00:068]
Mar 29, 2011 4:44:58 PM org.springframework.test.AbstractTransactionalSpringContextTests endTransaction
INFO: Rolled back transaction after test execution
I've tried to add a commons-logging.properties file to the classpath (the same location as the hibernate.properties and test-components.xml) but still only the default INFO messages appear.
Here's the commons-logging.properties file:
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger
# handlers
handlers=java.util.logging.ConsoleHandler
# default log level
.level=FINE
org.springframework.level=FINE
org.hibernate.level=FINE
# level for the console logger
java.util.logging.ConsoleHandler.level=FINE
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
Is anyone able to shed any light on why I can't get the DEBUG messages to print out? Is there a logging setting I'm missing?
Edit: I've tried FINEST and DEBUG to no avail.
Unfortunately, it seems the logging configuration file used by Jdk14Logger should be specified at runtime.
See the following file in your JDK directory: JDK_HOME/jre/lib/logging.properties (it's the default one used if no config file is found)
Moreover, the file path should be absolute, otherwise it's relative to the folder where the JRE is executed - see the code of java.util.logging.LogManager.readConfiguration()
Also see:
http://www.javapractices.com/topic/TopicAction.do?Id=143
http://cyntech.wordpress.com/2009/01/09/how-to-use-commons-logging/
Your default and hibernate logging is at Level "FINE" which is more of a "INFO" in log4j terms.
You need set DEBUG level for org.hibernate which in JDK logging is equal to 'FINEST'
Set
org.hibernate.level=FINEST (in the above log which should enable debug logs)

Categories

Resources