I am trying to create a simple java program to implement batch operations, such as deleting all users in the system. However, I am getting NullPointerException on most operations. My program is as shown on the link above.
I am going through the wildfire API, but with not much success. Here are the results of such a program.
wonderlight wildfire # time java -cp “/opt/wildfire/lib/wildfire.jar:.” Test
Constructor has been called.
Getting read-only status…false
Exception in thread “main” java.lang.NullPointerException
at org.jivesoftware.wildfire.user.DefaultUserProvider.getUsernames(DefaultUserProv ider.java:224)
at Test.getUsernames(Test.java:47)
at Test.main(Test.java:63)
real 0m30.452s
user 0m0.360s
sys 0m0.024s
Thanks for your time and help. If you have any working examples, feel free to point me in the right direction.
with Wildfire 3.1.1 your example fails with “The method getUsernames() is undefined for the type DefaultUserProvider” while using “Collection c = conn.getUsers();” works fine.
Nevermind… I am getting another error now, which I will investigate. question though… why are the other methods not working and they are documented in the javadoc?
wonderlight wildfire # time java -cp “/opt/wildfire/lib/wildfire.jar:/opt/wildfire/lib/hsqldb.jar:.” Test
Constructor has been called.
Getting read-only status…false
Missing database schema for wildfire. Attempting to install…
java.sql.SQLException: Table not found in statement
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
at org.jivesoftware.database.AbstractConnection.prepareStatement(AbstractConnectio n.java:36)
at org.jivesoftware.wildfire.user.DefaultUserProvider.getUsernames(DefaultUserProv ider.java:224)
at org.jivesoftware.wildfire.user.DefaultUserProvider.getUsers(DefaultUserProvider .java:213)
I am at a loss… I didn’'t do anything and I am getting these errors now (which might be making more sense?), even with the methods that were not working before… All I did was enable debug logs…
Well, my installation dissapeared … I ran a wildfire restart, and all of a sudden, when accessing the admin interface, it showed me the setup routine… Indeed my DB file was gone.
I am in the process of reinstalling… Maybe these errors will go away. Will keep this thread updated.
I reinstalled wildfire, this time with 3.2 beta2, just for fun. Embedded DB (for 100 users, i guess it’'s still ok?), reran that program, and still get
wonderlight wildfire_java # time java -cp “/opt/wildfire/lib/wildfire.jar:/opt/wildfire/lib/hsqldb.jar:.” Test
Constructor has been called.
Getting user count…Missing database schema for wildfire. Attempting to install…
java.sql.SQLException: Table not found in statement
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
at org.jivesoftware.database.AbstractConnection.prepareStatement(AbstractConnectio n.java:36)
at org.jivesoftware.wildfire.user.DefaultUserProvider.getUserCount(DefaultUserProv ider.java:197)
at Test.getCount(Test.java:32)
at Test.main(Test.java:54)
and so on. I have some users created, I am even currently logged in to wildfire.
is there something I am missing that I should do to point the program to the DB? Constructors do not accept argument, so I don’'t know.
But now, another error, héhé… I guess a config value to set? I however have Supports multiple connections
open at once: Yes in the database section of the admin console.
wonderlight wildfire_java # time java -cp “/opt/wildfire/lib/wildfire.jar:/opt/wildfire/lib/hsqldb.jar:.” Test
Constructor has been called.
Getting user count…Failed to create new connections on startup. Attempt 0 of 3
java.sql.SQLException: The database is already in use by another process: org.hsqldb.persist.NIOLockFile@20462e09[file =/opt/wildfire/embedded-db/wildfire.lck, exists=true, locked=false, valid=false, fl =null]: java.lang.Exception: checkHeartbeat(): lock file /opt/wildfire/embedded-db/wildfire.lck is presumably locked by another process.
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.(ConnectionPool.java:88)
at org.jivesoftware.database.EmbeddedConnectionProvider.start(EmbeddedConnectionPr ovider.java:75)
at org.jivesoftware.database.DbConnectionManager.setConnectionProvider(DbConnectio nManager.java:459)
at org.jivesoftware.database.DbConnectionManager.getConnection(DbConnectionManager .java:77)
at org.jivesoftware.wildfire.user.DefaultUserProvider.getUserCount(DefaultUserProv ider.java:196)
I am marking this question as answered, thanks for all
I guess then that I would need to migrate to an external database for added flexibility, and maybe performance? Would a 100 users be a high number enough to justify the use of mysql for example?
if you know how to run, backup and restore MySQL you may want to use it also for 3 users. If you like the HSQLDB you can run it in standalone mode and use JDBC connections (one for Wildfire, one of your application) to access it.
With 100 users it should be possible to stop the server at night and run the scripts you want to run.
Warning: As Wildfire uses a database cache it’'s never a good idea to modify database content via SQL while it is running.