Binding CORBA object to Weblogic 11g not working - java

I have written server side code to bind CORBA object to Weblogic 11g.
Have created context factory and binding ORB reference from servant.
Its getting bound to JNDI tree , but while doing lookup from client its giving error as
"java.rmi.NoSuchObjectException: The object identified by: '257' could not be found"

vaibhav singh has solved the issue by following procedure:
Root Cause Analysis:
The startup options was containing JVM arguments "-Dweblogic.management.server=t3://10.188.103.55:7002". The admin server should not contain this, as it makes the server to run in managed server mode. So the thing was admin server was starting as managed server, and trying to contact itself, creating a deadlock kind scenario.
Usually ${ADMIN_URL} sets up the variable "weblogic.management.server". I tried to find out that who set this varible in this condition, as setDomain.sh script stricts that this variable is null for admin server startup. On little debugging on environment it was clear ${JAVA_OPTS} was exported in the UNIX session, as one can also see in startup the variables are repeated. So the crux of matter was I restarted one managed server which exported JAVA_OPTS variable in the session and when I restarted admin server, it appended its options in already exported JAVA_OPTS but not clearing it.
Solution:
Either manually purge the startup variables from UNIX, Linux session if you are stubborn and don't want to close your session.
Kill the UNIX Linux session. Start a new session, it will automatically purge the exported variables. Now start your admin server.
Resource Link:
Full Details is described here: Caused by: java.rmi.NoSuchObjectException: The object identified by: '31' could not be found. Either it was has not been exported or it has been collected by the distributed garbage collector.

Related

Error when trying to connect to H2 database

Did any of you had this below error when trying to connect to H2?
The release I'm using is 1.4.199, on windows, with TAFJFuctions.
First I run this command:
java -server -cp h2-1.4.199.jar;C:\Users\...\H2\TAFJFunctions.jar org.h2.tools.Server -web -tcp -tcpPort 9092 -tcpAllowOthers -baseDir C:\Users\...\H2\bin
and I've got connected with TCP server running and Web Console server running as well.
Then I've run this command:
SET H2URL=jdbc:h2:tcp://locaLhost/t24db;DB_CLOSE_ON_EXIT=FALSE;MODE=Oracle;TRACE_LEVEL_FILE=0;TRACE_LEVEL_SYSTEM_OUT=0;FILE_LOCK=NO;IFEXISTS=TRUE;CACHE_SIZE=8192;MVCC=TRUE;LOCK_TIMEOUT=60000
And then this command:
java -server -cp h2-1.4.199.jar;C:\Users\...\H2\TAFJFunctions.jar org.h2.tools.Shell -url %H2URL% -driver org.h2.Driver -user t24 -password t24
And here I've got the below error:
"Exception in thread "main" org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database "C:/Users/.../H2/bin/t24db" not found, and IFEXISTS=true, so we cant auto-create it [90146-199]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:617)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:427)
at org.h2.message.DbException.get(DbException.java:205)
at org.h2.message.DbException.get(DbException.java:181)
at org.h2.engine.Engine.openSession(Engine.java:67)
at org.h2.engine.Engine.openSession(Engine.java:201)
at org.h2.engine.Engine.createSessionAndValidate(Engine.java:178)
at org.h2.engine.Engine.createSession(Engine.java:161)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:160)
at java.lang.Thread.run(Unknown Source)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:617)
at org.h2.engine.SessionRemote.done(SessionRemote.java:607)
at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:143)
at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:431)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:317)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:169)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:148)
at org.h2.Driver.connect(Driver.java:69)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.h2.tools.Shell.runTool(Shell.java:148)
at org.h2.tools.Shell.main(Shell.java:81)"
Any idea how to get this working?
Thank you,
Carina
With IFEXISTS=TRUE the problem is oblivious, but without this parameter or with attempt to set it to FALSE situation is not going to be changed.
All recent versions of H2 database don't allow remote (including local TCP connections) database creation by default any more due to security reasons. When it is allowed, everyone who can connect to your port can create a new database, get ADMIN privileges in it and therefore get the same access to your system as your JVM and your user account allows.
Unfortunately, H2 1.4.199 throws a confusing error message, it was improved only in 1.4.200 and in this version (when IFEXISTS=TRUE wasn't used) the error message is “Database … not found, either pre-create it or allow remote database creation (not recommended in secure environments)”.
If you use a TCP (or Pg/ODBC) server you need to create your databases in some other way before you try to connect to them with networked protocol.
For example, you can open the JDBC connection (DriverManager.getConnection()) with embedded URL and close it immediately.
You can replace org.h2.tools.Server with org.h2.tools.Console and you'll see another http connection URL (if you start it from the command line), something like http://127.0.0.2:8082?key=12c58e1c5f9ce1ae88a2921f74e7655ed91a80746730cc6bfa8d4bbb464f69ee; with this URL you will be able to create the database from the web interface (only if remove web interface is not enabled).
You can also add the -tool parameter (only to Console, the Server doesn't support it) to get H2 Console icon in the system tray, its context menu has a command to create a new database and this icon can also open the web interface with the same security key. Don't share this key with anyone. It will be different on each restart, however.
You can also use the command-line Shell tool.
https://h2database.com/html/tutorial.html#creating_new_databases
In the worst case you can enable the remove database creation, but it is not really secure even with local connections and it is completely insecure when remote connections are enabled as in your case. You will have a well-known remote security hole in your system, I don't think that it is your intention.
The problem here is that there is no database called t24db already.
In the property spring.datasource.url property which you use to connect to h2, remove the parameter IFEXISTS=TRUE.
This will ensure that the database is created if it does not exist.

Derby authentication error from Glassfish console but same credentials work from ij

I am trying, for the first time, to run a java EE 7 web app without an IDE and struggling through the learning curve. To keep things simple I have started with Glassfish 4.1 and Derby 10.11.1.2 which is what I used for development.
My current problem is an error configuring the connection pool on the Glassfish web interface. The error is 'Connection authentication failure occurred. Reason: Userid or password invalid'. However I have ij runing in a dos prompt and the Glashfish web console in Chrome.
from ij I can type 'connect 'jdbc:derby:localhost:1527/databasename;user=username;password=password'; and I connect fine and can look at tables, etc. In the Glassfish web console I have name/value pairs with the same 'user' and 'password' values and it fails (exact same letters & case). I've tried changing the 'databaseName' property to make sure the error wasn't misleading and confirmed it has found the database correctly.
At face value, the error message seems wrong as I have proven from the DOS window. I am sure I am doing something wrong but am lost at how to diagnose it. Any suggestions?
More details of the steps taken: (Although I am sure some of these steps superceed others my lack of success has me in the mindset that redundancy is better than omission - all-in-all it seems much more complicated than it needs to be for a basic setup). My target is Wildfly but Glassfish documentation is better so I figured I would start there.
relevant Windows environment variables:
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_40
DERBY_HOME=%JAVA_HOME%\db
DERBY_INSTALL=%DERBY_HOME%
JAVADB_HOME=%DERBY_HOME%
GLASSFISH=C:\Program Files\Java\GlassFish-4.1
Path=%JAVA_HOME%\bin;%DERBY_HOME%\bin;%GLASSFISH%\bin;%GLASSFISH%\glassfish
CLASSPATH=%DERBY_HOME%\lib\derbynet.jar;%DERBY_HOME%\lib\derbytools.jar;%DERBY_HOME%\derbyclient.jar;%DERBY_HOME%\lib\derbyrun.jar
WILDFLY_HOME=C:\program files\java\wildfly\8.2.0.Final
sysinfo shows all the right paths and versions
Copied many of the derby jars from %derby_home%\lib to %glassfish%\glassfish\domains\domain1\lib\ext per a post by BalusC. I think classpath duplicates this it but can't hurt
Started Domain 'asadmin start-domain' defaulting to domain 1
Started DB by changing directories and using java. Wanted to use 'asadmin start-database --dbhome DB path' but this always started the wrong version. Glassfish and JDK both package derby/javadb and I couldn't figure out how to upgrade Glassfish or start the correct version any other way
cd \users\john\.netbeans-derby (root of the DB created by Netbeans)
Java –jar “%derby_home%\lib\derbyrun.jar" server start
connect browser to 'localhost:4848' to create JDBC connection pool and resource
connection pool: pool name=connectionPool, resource type=javax.sql.DataSource, DB driver Vendor=Derby, introspect was not enabled (found very little documentation to explain what it is) - step 2 was left as defaults
editing connectionPool - enabled Ping on General tab to identify errors, Additional Properties tab: changed User to DB username, left other attributes as default, added... password=db password, databaseName=ClubScoring
errors were presented along the way which prompted setting each attribute. No error was presented for lack of URL but tested steps below with and without URL=jdbc:derby://localhost:1527/ClubScoring
jdbc resources. Added jdbc/ClubScoring, pool=connectionPool => selected and enabled
starting db from correct directory using 'asadmin start-database' does let the application find the correct DB but it crashes since the DB was created with version 10.11.1.2 and this command starts the Glassfish version of 10.10.2.0
Sorry for making this so long but I haven't found anywhere that lays out all of the steps in a simple fashion and figured the details would save time in the long run.
I was dealing with this issue today and found a solution:
https://db.apache.org/derby/docs/10.14/ref/rrefattribsecmech.html
Basically the only security options allowable (as far as 10.14 is concerned) is 3, 4 and 9.
4 is the default and means "Just UserID". You would think this means that as long as a UserID is given, you could connect. But having both set appears to be an issue.
In order to use a (clear text) password and userID, you have to specify 3. It works also if the attribute is deleted or 0 as well but I don't think you get any security that way.

Monitor Websphere Liberty Profile with JConsole

I'm trying to monitor my WLP v8.5.5 with JConsole.
My Liberty profile is up and running and has SSL properlly configured.
I also have configured as features the monitor-1.0 and restConnector-1.0.
After that I sftp'ed from my WLP the restConnector.jar to my machine and created a keystore on my machine as described here
After that I'm trying to start JConsole with this command:
jconsole -J-Djava.class.path="C:\Program Files\Java\jdk1.7.0_67\lib\jconsole.jar;
C:\Program Files\Java\jdk1.7.0_67\lib\tools.jar;
<whereIDownloaded>\restConnector.jar"
-J-Djavax.net.ssl.keyStore="<locationToCreated>\keystore.jks"
-J-Djavax.net.ssl.keyStorePassword=<password>
-J-Djavax.net.ssl.keyStoreType=jks
-J-Dcom.ibm.ws.jmx.connector.client.disableURLHostnameVerification=true
However, when I try to connect to my WLP via remote with the string:
service:jmx:rest://<ip>:<httpsPort>/IBMJMXConnectorREST
As a credential I'm passing a user configured on <administrator-role>.
I get a JConsole error saying:
Secure connection failed. Retry insecurely?
I don't get why I'm seeing this error, and I don't see any logs to see why it failed.
My next step if getting the keystore from WLP and try that on my machine but I don't think that makes much sense.
Does anyone have any suggestion on where should I look for logs or on that I'm doing wrong?
Thanks in advance!
Reference:
http://www-01.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.wlp.nd.doc/ae/twlp_mon.html?cp=SSAW57_8.5.5%2F1-3-11-0-6&lang=en
Ensure you don't have localConnector-1.0 feature. If you have that, please remove it. You can find more details here Remote monitoring of Liberty with Health Center. Although it discusses Health Center connection, I was testing using JConsole also.
UPDATE
You might be invoking console with incorrect params - it should be trustStore not keystore see below. And for start use key.jks copied from Liberty (as you need Liberty certificate as trusted)
jconsole -J-Djava.class.path=%JAVA_HOME%/lib/jconsole.jar;
%JAVA_HOME%/lib/tools.jar;
%WLP_HOME%/clients/restConnector.jar
-J-Djavax.net.ssl.trustStore=key.jks
-J-Djavax.net.ssl.trustStorePassword=Liberty
-J-Djavax.net.ssl.trustStoreType=jks
For details check Configuring secure JMX connection to the Liberty
As an additional note - you must not have a webAppSecurity entry with loginFormURL set in your server.xml as this will cause the JMX login to fail (e.g., <webAppSecurity loginFormURL="login.html"/> is problematic). Each individual WAR needs to set their own login-config and not rely on any global method of configuring logins.
`

org.omg.CORBA.TRANSIENT: initial and forwarded IOR inaccessible vmcid: IBM minor code: E07 from stand-alone app

I'm connecting to the WebSphere instance from the stand-alone Java app which is quite trivial:
InitialContext initCtx = new InitialContext();
That code was working perfectly in WebSphere 7, but after updating to WebSphere 8.5 I got the following exception:
Caused by: org.omg.CORBA.TRANSIENT: initial and forwarded IOR inaccessible vmcid: IBM minor code: E07 completed: No
at com.ibm.rmi.corba.ClientDelegate.createRequest(ClientDelegate.java:1276)
at com.ibm.CORBA.iiop.ClientDelegate.createRequest(ClientDelegate.java:1457)
at com.ibm.rmi.corba.ClientDelegate.createRequest(ClientDelegate.java:1164)
at com.ibm.CORBA.iiop.ClientDelegate.createRequest(ClientDelegate.java:1423)
at com.ibm.rmi.corba.ClientDelegate.request(ClientDelegate.java:1886)
at com.ibm.CORBA.iiop.ClientDelegate.request(ClientDelegate.java:1379)
at org.omg.CORBA.portable.ObjectImpl._request(ObjectImpl.java:458)
at com.ibm.WsnBootstrap._WsnNameServiceStub.getProperties(_WsnNameServiceStub.java:38)
at com.ibm.ws.naming.util.WsnInitCtxFactory.mergeWsnNSProperties(WsnInitCtxFactory.java:1441)
... 43 more
After research, I've fout out that IBM support page, which said to go to CSIv2 inbound and outbound settings (by me, Admin Console->Security->GlobalSecurity->RMI/IIOP security) and set the transport to SSL-Supported.
However, it didn't change anything. I've tried to change the 'Cleint certificate authentication' to Never, and Transport to TCP/IP for both CSIv2 inbound and outbound, but still without success. The error persisted until I've turned off 'Enable administrative security', which is not an option, because I need to enable 'Application Security' (the application logic depends of that).
How can I make my code working again? Everything was OK on WebSphere 7.
My research on this issue may prove useful to others;
WebSphere 8 changed the default setting of RMI/IIOP SSL security from
'supported' to 'required'. If you want a secure connection you'll need
to get the certs from the server and set Java system properties to files that specify the location of the certs;
com.ibm.CORBA.ConfigURL=file:/opt/IBM/JazzSM/profile/properties/sas.client.props
com.ibm.SSL.ConfigURL=file:/opt/IBM/JazzSM/profile/properties/ssl.client.props
If this doesn't work, you'll need to start debugging by setting the following System properties;
com.ibm.CORBA.Debug=true
com.ibm.CORBA.CommTrace=true
com.ibm.CORBA.Debug.Output=/tmp/corba.log
By studying this log and orb trace logs in the working directory, I found that the client failed to establish an ephemeral TCP connection to the server at "port=0". No mention of SSL in the logs! I wrote a small app to test my code running as a java console app and found that the SSL connection was successful and it worked fine. By diff'ing the logs, I found that only in the good case, the JVM was finding a local file 'orb.properties'. I then found that in my problem case, my test app was using a different JVM and my real app was using a JVM that had no 'orb.properties'. I could resolve the problem in a number of ways .. e.g. by including an orb.properties in my application and injecting the contents as System properties.
In my case switching CSIV inbound to SSL-Supported from SSL-required and restarting the server helped.
The error description
org.omg.CORBA.TRANSIENT: initial and forwarded IOR inaccessible vmcid: IBM minor code: E07
is very vague and happens under many, not directly connected circumstances.
In my case it had nothing to do with RMI/IIOP security settings, but it was a classpath problem. I was still using old version of com.ibm.ws.webservices.thinclient.
Switching to thinclient 8.5.0, as well as setting the launch JRE to standard (Oracle) JVM has fixed the problem.

H2 database error: Database may be already in use: "Locked by another process"

I am trying to use the H2 database from a Java application.
I created the database and its tables through the H2 Console and then I try to connect from Java using
Connection con = DriverManager.getConnection("jdbc:h2:~/dbname", "username", "password");
However I receive the following error:
Exception in thread "main" org.h2.jdbc.JdbcSQLException: Database may be already in use: "Locked by another process". Possible solutions: close all other connection(s); use the server mode [90020-161]
I tried to delete the dbname.lock.db file but it is automatically re-created.
How can I unlock the database to use it from my Java program?
H2 is still running (I can guarantee it). You need to use a TCP connection for multiple users such as ->
<property name="javax.persistence.jdbc.url" value="jdbc:h2:tcp://localhost/C:\Database\Data\production;"/>
OR
DriverManager.getConnection("jdbc:h2:tcp://localhost/server~/dbname","username","password");
It also means you need to start the server in TCP mode. Honesetly, it is pretty straight forward in the documentation.
Force kill the process (javaw.exe for Windows), and make sure that any application that might have started it is shut down. You have an active lock.
I had the same problem.
in Intellj, when i want to use h2 database when my program was running i got the same error.
For solve this problem i changed the connection url from
spring.datasource.url=jdbc:h2:file:~/ipinbarbot
to:
spring.datasource.url=jdbc:h2:~/ipinbarbot;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE
And then my problem gone away. now i can connect to "ipinbarbot" database when my program is.
If you use Hibernate, also don't forget to have:
spring.jpa.hibernate.ddl-auto = update
goodluck
I'm using h2db with a test T24 tafj application, I had the same problem but I managed to resolve it by identifying the application that is running h2 (launched when I attempted to setup a database connection).
ps aux|grep java
will give output as:
sysadmin 22755 3.2 0.1 5189724 64008 pts/3 Sl 08:28 0:00 /usr/java/default/bin/java -server -Xmx2048M -XX:MaxPermSize=256M -cp h2-1.3.175.jar:/r14tafj/TAFJ/dbscripts/h2/TAFJFunctions.jar org.h2.tools.Server -tcp -tcpAllowOthers -baseDir /r14tafj/t24/data
now kill this with its process id:
kill -9 22755
and at last remove the lock file:
rm -f dbname.lock.db
I got clue from Saman Salehi above.
My usecase:
Preparing REST application for client-side load balancing(running two JVM instances of REST). Here my MVC application will call this REST application that has ActiveMQ backend for DATA.
I had the problem when I ran two instances of REST application in eclipse and trying to run both instances at the same time with the following configuration
spring.datasource.url=jdbc:h2:file:./Database;
spring.jpa.properties.hibernate.hbm2ddl.auto=update
After adding DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE
spring.datasource.url=jdbc:h2:file:./Database;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE
Both instances are running and showing in Eureka dasboard.
Don't close the database when the VM exits : jdbc:h2:;DB_CLOSE_ON_EXIT=FALSE
Multiple processes can access the same database without having to start the server manually ;AUTO_SERVER=TRUE
Further reading:
http://www.h2database.com/html/features.html
You can also visit the "Preferences" tab from the H2 Console and shutdown all active sessions by pressing the shutdown button.
Simple step: Go to the task manager and kill the java process
then start your apllication
You can also delete file of the h2 file database and problem will disappear.
jdbc:h2:~/dbname means that file h2 database with name db name will be created in the user home directory(~/ means user home directory, I hope you work on Linux).
In my local machine its present in: /home/jack/dbname.mv.db I don't know why file has a name dbname.mv.db instead a dbname.
May be its a h2 default settings.
I remove this file:
rm ~/dbname.mv.db
OR:
cd ~/
rm dbname.mv.db
Database dbname will be removed with all data. After new data base init all will be ok.
If you are running same app into multiple ports where app uses single database (h2), then add AUTO_SERVER=TRUE in the url as follows:
jdbc:h2:file:C:/simple-commerce/price;DB_CLOSE_ON_EXIT=FALSE;AUTO_RECONNECT=TRUE;AUTO_SERVER=TRUE
I ran into similar problems running with ORMLite from a web application. I initially got stuck on the syntax to use server mode in the url. The answers above helped with that. Then I had the similar user/password error which was easier to figure out. I did not have to shut anything down or erase any files. The following code worked:
protected ConnectionSource getConnectionSource() throws SQLException {
String databaseUrl = "jdbc:h2:tcp://localhost/~/test";
return new JdbcConnectionSource(databaseUrl,"sa","sa");
}
To use H2 in server mode on wildfly, I Modifed connection-url in standalone.xml
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool- name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:tcp://localhost/~/test</connection-url>
…
</datasource>
Identify the H2 process id and kill it. For mac
ps -ef|grep h2
Then get the process id and kill it.
kill -9 PID
According H2 Database Tutorial you can run the H2 Database in three different modes:
Server mode:
jdbc:h2:tcp://localhost/~/test
When using H2 db in server mode (also known as client/server mode) all data is transferred over TCP/IP. Before application can use H2 Database in server mode, you need to start the H2 DB within the same or another machine.
Embedded mode:
jdbc:h2:~/test
H2 db in embedded mode will be faster but the downside of it is that no other process can access the Database. In the above connection string, the Data will be saved into the ‘test’ folder, under the user’s home directory.
Mixed mode:
The mixed mode combines some features of the embedded and the server mode. The first application connecting to the H2 db does that in embedded mode, but at the same time it starts a server so that other applications can concurrently access the same data, even from different processes.
jdbc:h2:/data/test;AUTO_SERVER=TRUE
When using automatic mixed mode, you can share the JDBC URL for all applications using the DB. By default the server uses any free TCP port. The port can be set manually using AUTO_SERVER_PORT=9090.
Ran into a similar issue the solution for me was to run fuser -k 'filename.db' on the file that had a lock associated with it.
Hope this helps!
I was facing this issue in eclipse . What I did was, killed the running java process from the task manager.
It worked for me.
In your application.properties file > edit the datasource into:
spring.datasource.url=jdbc:h2:file:C:/temp/test;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE
Happy coding!
answer for this question => Exception in thread "main" org.h2.jdbc.JdbcSQLException: Database may be already in use: "Locked by another process". Possible solutions: close all other connection(s); use the server mode [90020-161]
close all tab from your browser where open h2 database also Exit h2 engine from your pc
For InteliJ: right lick on your database in the database view and choose "Disconnect".
I tried to delete the dbname.lock.db file but it is automatically re-created.
How can I unlock the database to use it from my Java program?
Just add FILE_LOCK=NO;. FILE_LOCK=NO doesn't make dbname.lock.db.
spring.datasource.url=jdbc:h2:file:./testdb/h2;DB_CLOSE_ON_EXIT=false;FILE_LOCK=NO;
The detail for FILE_LOCK reference this.
Using the method NO forces the database to not create a lock file at all

Categories

Resources