I am unable to get the JDBC connection for the below configuration. Getting the error: HHH000342: Could not obtain connection to query metadata - hibernate-mapping

My hibernate.cfg.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL8Dialect</property>
<property name="hbm2ddl.auto">update</property>
<property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
<property name="connectin.url">jdbc:mysql://localhost:3306/hibernate</property>
<property name="connection_username">root</property>
<property name="connection_password">root</property>
</session-factory>
</hibernate-configuration>
My Programm: In which I am just tyring to print the session print the session g=factory object to check if the connection is established.
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
public class App
{
public static void main( String[] args )
{
// Here i am just trying to print the SessionFactory object to check if the connection is
//established.
Configuration c= new Configuration();
c.configure("hibernate.cfg.xml");
SessionFactory s= c.buildSessionFactory();
System.out.println(s);
}
}
I am getting the below exception when I run the code. I am using JDK-11, Hibernate 5.6.1, and MySQL 8
Feb 08, 2022 8:40:27 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate ORM core version 5.6.1.Final
Feb 08, 2022 8:40:28 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
Feb 08, 2022 8:40:28 PM org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator initiateService
WARN: HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections
Feb 08, 2022 8:40:28 PM org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator initiateService
WARN: HHH000342: Could not obtain connection to query metadata
java.lang.UnsupportedOperationException: The application must supply JDBC connections
at org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl.getConnection(UserSuppliedConnectionProviderImpl.java:44)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:181)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:178)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:175)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:127)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:86)
at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:479)
at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:85)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:709)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:746)
at com.hibernateprogms.App.main(App.java:14)
Feb 08, 2022 8:40:28 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
Exception in thread "main" java.lang.UnsupportedOperationException: The application must supply JDBC connections
at org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl.getConnection(UserSuppliedConnectionProviderImpl.java:44)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:181)
at org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl.getIsolatedConnection(DdlTransactionIsolatorNonJtaImpl.java:44)
at org.hibernate.tool.schema.internal.exec.ImprovedExtractionContextImpl.getJdbcConnection(ImprovedExtractionContextImpl.java:60)
at org.hibernate.tool.schema.internal.exec.ImprovedExtractionContextImpl.getJdbcDatabaseMetaData(ImprovedExtractionContextImpl.java:67)
at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.processTableResultSet(InformationExtractorJdbcDatabaseMetaDataImpl.java:64)
at org.hibernate.tool.schema.extract.internal.AbstractInformationExtractorImpl.getTables(AbstractInformationExtractorImpl.java:555)
at org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl.getTablesInformation(DatabaseInformationImpl.java:119)
at org.hibernate.tool.schema.internal.GroupedSchemaMigratorImpl.performTablesMigration(GroupedSchemaMigratorImpl.java:65)
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:208)
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:115)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:192)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:81)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:327)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:471)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:728)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:746)
at com.hibernateprogms.App.main(App.java:14)

Search your code for UserSuppliedConnectionProviderImpl. When this is put into the config as connection provider for Hibernate, then it will ignore the values in <session-factory>.

Related

Plugin, authenticateNode NotSerializableException

I have troubles implementing an authentication plugin. A NotSerializableException is raised on the instance of my AuthPluginProcessor class. Disabling the authentication with enabled returning false makes the node start.
I think I am missing something (I tried adding parameters to authenticateNode without success), below is the minimum code reproducing the error.
AuthPluginProcessor :
public class AuthPluginProcessor implements IgnitePlugin, GridSecurityProcessor, Serializable
{
#Override
public SecurityContext authenticateNode(ClusterNode clusterNode, SecurityCredentials securityCredentials) throws IgniteCheckedException
{
return new SecurityContext() {
#Override
public SecuritySubject subject() { return null; }
#Override
public boolean taskOperationAllowed(String s, SecurityPermission securityPermission) { return true; }
#Override
public boolean cacheOperationAllowed(String s, SecurityPermission securityPermission) { return true; }
#Override
public boolean serviceOperationAllowed(String s, SecurityPermission securityPermission) { return true; }
#Override
public boolean systemOperationAllowed(SecurityPermission securityPermission) { return true; }
};
}
#Override
public boolean isGlobalNodeAuthentication() { return true; }
#Override
public boolean enabled() { return true; }
// others empty methods ...
}
Here is most of the log file :
[16:38:10,598][INFO][main][IgniteKernal] PID: 10152
[16:38:10,598][INFO][main][IgniteKernal] Language runtime: Java Platform API Specification ver. 1.8
[16:38:10,599][INFO][main][IgniteKernal] VM information: Java(TM) SE Runtime Environment 1.8.0_172-b11 Oracle Corporation Java HotSpot(TM) 64-Bit Server VM 25.172-b11
[16:38:10,602][INFO][main][IgniteKernal] VM total memory: 0.96GB
[16:38:10,602][INFO][main][IgniteKernal] Remote Management [restart: on, REST: on, JMX (remote: on, port: 49186, auth: off, ssl: off)]
[16:38:10,603][INFO][main][IgniteKernal] Logger: JavaLogger [quiet=false, config=null]
[16:38:10,603][INFO][main][IgniteKernal] IGNITE_HOME=D:\db\Ignite2.4
[16:38:10,605][INFO][main][IgniteKernal] VM arguments: [-Xms1g, -Xmx1g, -XX:+AggressiveOpts, -XX:MaxMetaspaceSize=256m, -DIGNITE_QUIET=false, -DIGNITE_SUCCESS_FILE=D:\db\Ignite2.4\work\ignite_success_18756fda-d6de-4b6f-9ff2-5dc0bbe5f8b7, -Dcom.sun.management.jmxremote, -Dcom.sun.management.jmxremote.port=49186, -Dcom.sun.management.jmxremote.authenticate=false, -Dcom.sun.management.jmxremote.ssl=false, -DIGNITE_HOME=D:\db\Ignite2.4, -DIGNITE_PROG_NAME=ignite.bat]
[16:38:10,606][INFO][main][IgniteKernal] System cache's DataRegion size is configured to 40 MB. Use DataStorageConfiguration.systemCacheMemorySize property to change the setting.
[16:38:10,613][INFO][main][IgniteKernal] Configured caches [in 'sysMemPlc' dataRegion: ['ignite-sys-cache']]
[16:38:10,613][WARNING][main][IgniteKernal] Peer class loading is enabled (disable it in production for performance and deployment consistency reasons)
[16:38:10,617][WARNING][pub-#19][GridDiagnostic] This operating system has been tested less rigorously: Windows 10 10.0 amd64. Our team will appreciate the feedback if you experience any problems running ignite in this environment.
[16:38:10,620][INFO][main][IgniteKernal] 3-rd party licenses can be found at: D:\db\Ignite2.4\libs\licenses
[16:38:10,683][INFO][main][IgnitePluginProcessor] Configured plugins:
[16:38:10,684][INFO][main][IgnitePluginProcessor] ^-- AuthPlugin 0.1.0
[16:38:10,686][INFO][main][IgnitePluginProcessor] ^-- null
[16:38:10,686][INFO][main][IgnitePluginProcessor]
[16:38:10,725][INFO][main][TcpCommunicationSpi] Successfully bound communication NIO server to TCP port [port=47101, locHost=0.0.0.0/0.0.0.0, selectorsCnt=4, selectorSpins=0, pairedConn=false]
[16:38:11,230][WARNING][main][TcpCommunicationSpi] Message queue limit is set to 0 which may lead to potential OOMEs when running cache operations in FULL_ASYNC or PRIMARY_SYNC modes due to message queues growth on sender and receiver sides.
[16:38:11,242][WARNING][main][NoopCheckpointSpi] Checkpoints are disabled (to enable configure any GridCheckpointSpi implementation)
[16:38:11,263][WARNING][main][GridCollisionManager] Collision resolution is disabled (all jobs will be activated upon arrival).
[16:38:11,265][INFO][main][IgniteKernal] Security status [authentication=on, tls/ssl=off]
[16:38:11,314][INFO][main][TcpDiscoverySpi] Successfully bound to TCP port [port=47501, localHost=0.0.0.0/0.0.0.0, locNodeId=8acfdf1f-1371-443a-a6b1-38189fcee66f]
[16:38:12,331][INFO][main][PdsFoldersResolver] Unable to acquire lock to file [D:\db\Ignite2.4\work\db\node00-3413bf9c-56ea-4041-ae02-6967e6118354], reason: Failed to acquire file lock during 1 sec, (locked by [4c07699d-cb8f-4e20-9531-9154eb4e8a12][]): D:\db\Ignite2.4\work\db\node00-3413bf9c-56ea-4041-ae02-6967e6118354\lock
[16:38:12,364][INFO][main][PdsFoldersResolver] Successfully locked persistence storage folder [D:\db\Ignite2.4\work\db\node01-e607d470-4b11-42c1-b054-2a60a5ddaa02]
[16:38:12,364][INFO][main][PdsFoldersResolver] Consistent ID used for local node is [e607d470-4b11-42c1-b054-2a60a5ddaa02] according to persistence data storage folders
[16:38:12,365][INFO][main][CacheObjectBinaryProcessorImpl] Resolved directory for serialized binary metadata: D:\db\Ignite2.4\work\binary_meta\node01-e607d470-4b11-42c1-b054-2a60a5ddaa02
[16:38:12,530][INFO][main][FilePageStoreManager] Resolved page store work directory: D:\db\Ignite2.4\work\db\node01-e607d470-4b11-42c1-b054-2a60a5ddaa02
[16:38:12,531][INFO][main][FileWriteAheadLogManager] Resolved write ahead log work directory: D:\db\Ignite2.4\work\db\wal\node01-e607d470-4b11-42c1-b054-2a60a5ddaa02
[16:38:12,531][INFO][main][FileWriteAheadLogManager] Resolved write ahead log archive directory: D:\db\Ignite2.4\work\db\wal\archive\node01-e607d470-4b11-42c1-b054-2a60a5ddaa02
[16:38:12,543][INFO][main][FileWriteAheadLogManager] Started write-ahead log manager [mode=LOG_ONLY]
[16:38:12,552][INFO][main][GridCacheDatabaseSharedManager] Read checkpoint status [startMarker=null, endMarker=null]
[16:38:12,565][INFO][main][PageMemoryImpl] Started page memory [memoryAllocated=100,0 MiB, pages=24936, tableSize=1,4 MiB, checkpointBuffer=100,0 MiB]
[16:38:12,566][INFO][main][GridCacheDatabaseSharedManager] Checking memory state [lastValidPos=FileWALPointer [idx=0, fileOff=0, len=0], lastMarked=FileWALPointer [idx=0, fileOff=0, len=0], lastCheckpointId=00000000-0000-0000-0000-000000000000]
[16:38:12,572][INFO][main][GridCacheDatabaseSharedManager] Applying lost cache updates since last checkpoint record [lastMarked=FileWALPointer [idx=0, fileOff=0, len=0], lastCheckpointId=00000000-0000-0000-0000-000000000000]
[16:38:12,574][INFO][main][GridCacheDatabaseSharedManager] Finished applying WAL changes [updatesApplied=0, time=0ms]
[16:38:12,633][INFO][main][ClientListenerProcessor] Client connector processor has started on TCP port 10801
[16:38:12,665][INFO][main][GridTcpRestProtocol] Command protocol successfully started [name=TCP binary, host=0.0.0.0/0.0.0.0, port=11212]
[16:38:13,969][INFO][main][IgniteKernal] Non-loopback local IPs: 124.0.0.9, fe80:0:0:0:15be:bcfe:4ff6:1422%eth10, fe80:0:0:0:49ae:87cd:b8a4:a6bb%eth2, fe80:0:0:0:7943:2fb2:1da3:e69b%eth1, fe80:0:0:0:859b:b174:7412:4eb7%wlan1, fe80:0:0:0:d1fb:422:9dfa:aada%eth17, fe80:0:0:0:dd7d:8d79:7438:1db7%eth0, fe80:0:0:0:e593:8733:6979:aa7f%wlan0
[16:38:13,969][INFO][main][IgniteKernal] Enabled local MACs: 00090FFE0001, 00FF20F9E686, 025041000001, 184F32F210F1, 1A4F32F210F1, 54587804FD10, 54C6D294231E, 54CCB184D71B, 64006A8BA7BF
[16:38:13,995][SEVERE][main][IgniteKernal] Failed to start manager: GridManagerAdapter [enabled=true, name=o.a.i.i.managers.discovery.GridDiscoveryManager]
class org.apache.ignite.IgniteCheckedException: Failed to start SPI: TcpDiscoverySpi [addrRslvr=null, sockTimeout=5000, ackTimeout=5000, marsh=JdkMarshaller [clsFilter=org.apache.ignite.internal.IgniteKernal$5#3f390d63], reconCnt=10, reconDelay=2000, maxAckTimeout=600000, forceSrvMode=false, clientReconnectDisabled=false]
at org.apache.ignite.internal.managers.GridManagerAdapter.startSpi(GridManagerAdapter.java:300)
at org.apache.ignite.internal.managers.discovery.GridDiscoveryManager.start(GridDiscoveryManager.java:892)
at org.apache.ignite.internal.IgniteKernal.startManager(IgniteKernal.java:1669)
at org.apache.ignite.internal.IgniteKernal.start(IgniteKernal.java:983)
at org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance.start0(IgnitionEx.java:1973)
at org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance.start(IgnitionEx.java:1716)
at org.apache.ignite.internal.IgnitionEx.start0(IgnitionEx.java:1144)
at org.apache.ignite.internal.IgnitionEx.startConfigurations(IgnitionEx.java:1062)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:948)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:847)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:717)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:686)
at org.apache.ignite.Ignition.start(Ignition.java:347)
at org.apache.ignite.startup.cmdline.CommandLineStartup.main(CommandLineStartup.java:302)
Caused by: class org.apache.ignite.spi.IgniteSpiException: Failed to authenticate local node (will shutdown local node).
at org.apache.ignite.spi.discovery.tcp.ServerImpl.localAuthentication(ServerImpl.java:991)
at org.apache.ignite.spi.discovery.tcp.ServerImpl.joinTopology(ServerImpl.java:862)
at org.apache.ignite.spi.discovery.tcp.ServerImpl.spiStart(ServerImpl.java:364)
at org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.spiStart(TcpDiscoverySpi.java:1930)
at org.apache.ignite.internal.managers.GridManagerAdapter.startSpi(GridManagerAdapter.java:297)
... 13 more
Caused by: class org.apache.ignite.IgniteCheckedException: Failed to serialize object: test.ignite.AuthPluginProcessor$1#1af687fe
at org.apache.ignite.marshaller.jdk.JdkMarshaller.marshal0(JdkMarshaller.java:103)
at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.marshal(AbstractNodeNameAwareMarshaller.java:70)
at org.apache.ignite.marshaller.jdk.JdkMarshaller.marshal0(JdkMarshaller.java:117)
at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.marshal(AbstractNodeNameAwareMarshaller.java:58)
at org.apache.ignite.internal.util.IgniteUtils.marshal(IgniteUtils.java:9984)
at org.apache.ignite.spi.discovery.tcp.ServerImpl.localAuthentication(ServerImpl.java:985)
... 17 more
Caused by: java.io.NotSerializableException: test.ignite.AuthPluginProcessor$1
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
at org.apache.ignite.marshaller.jdk.JdkMarshaller.marshal0(JdkMarshaller.java:98)
... 22 more
Here is the configuration file :
<bean abstract="true" id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<!-- Set to true to enable distributed class loading for examples, default is false. -->
<property name="peerClassLoadingEnabled" value="true"/>
<!-- Enable task execution events for examples. -->
<property name="includeEventTypes">
<list>
<!--Task execution events-->
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>
<!--Cache events-->
<util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED"/>
</list>
</property>
<property name="pluginConfigurations">
<bean class="test.ignite.AuthPluginConfiguration"/>
</property>
<!--<property name="binaryConfiguration">
<bean class="org.apache.ignite.configuration.BinaryConfiguration">
<property name="compactFooter" value="false"/>
<property name="idMapper">
<bean class="org.apache.ignite.binary.BinaryBasicIdMapper">
<property name="lowerCase" value="true"/>
</bean>
</property>
</bean>
</property>-->
<!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<!--
Ignite provides several options for automatic discovery that can be used
instead os static IP based discovery. For information on all options refer
to our documentation: http://apacheignite.readme.io/docs/cluster-config
-->
<!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<list>
<value>124.0.0.127</value>
<value>124.0.0.125</value>
<value>124.0.0.9</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
<property name="dataStorageConfiguration">
<bean class="org.apache.ignite.configuration.DataStorageConfiguration">
<property name="defaultDataRegionConfiguration">
<bean class="org.apache.ignite.configuration.DataRegionConfiguration">
<property name="persistenceEnabled" value="true"/>
</bean>
</property>
</bean>
</property>
</bean>
Your SecurityContext doesn't implement Serializable likely.
Move to named inner class => add implements.

Hibernate 4.2.2 The Network Adapter could not establish the connection

I've been working through several Hibernate Tutorial but the application won't run. I get a JDBCConnectionException.
I think maybe there is something wrong with the connection settings: "ERROR: I/O-Fehler: The Network Adapter could not establish the connection"
Therefore I linked the SQL Developer Settings and my hibernate.cfg.xml.
Link to SQL Developer Settings
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:#localhost:1521:xe</property>
<property name="connection.username">test</property>
<property name="connection.password">test</property>
<!-- SQL dialect -->
<property name="dialect"> org.hibernate.dialect.Oracle10gDialect</property>
<mapping resource="TEST.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Here is the Main Class:
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.Session;
import org.hibernate.Query;
import org.hibernate.cfg.Configuration;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
import java.util.Map;
public class Main {
private static final SessionFactory ourSessionFactory;
private static final ServiceRegistry serviceRegistry;
static {
try {
Configuration configuration = new Configuration();
configuration.configure();
serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
ourSessionFactory = configuration.buildSessionFactory(serviceRegistry);
} catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}
public static Session getSession() throws HibernateException {
return ourSessionFactory.openSession();
}
public static void main(final String[] args) throws Exception {
final Session session = getSession();
final Test a1 = new Ankuendigung(3,"AA", "AAAA");
session.beginTransaction();
session.save(a1);
session.getTransaction().commit();
try {
System.out.println("querying all the managed entities...");
final Map metadataMap = session.getSessionFactory().getAllClassMetadata();
for (Object key : metadataMap.keySet()) {
final ClassMetadata classMetadata = (ClassMetadata) metadataMap.get(key);
final String entityName = classMetadata.getEntityName();
final Query query = session.createQuery("from " + entityName);
System.out.println("executing: " + query.getQueryString());
for (Object o : query.list()) {
System.out.println(" " + o);
}
}
} finally {
session.close();
}
}
}
Here is the complete stacktrace:
Apr 19, 2016 11:31:22 AM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
Apr 19, 2016 11:31:22 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.2.2.Final}
Apr 19, 2016 11:31:22 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Apr 19, 2016 11:31:22 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Apr 19, 2016 11:31:22 AM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
Apr 19, 2016 11:31:22 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Apr 19, 2016 11:31:22 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: Ankuendigung.hbm.xml
Apr 19, 2016 11:31:22 AM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
Apr 19, 2016 11:31:22 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)
Apr 19, 2016 11:31:22 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 20
Apr 19, 2016 11:31:22 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000006: Autocommit mode: false
Apr 19, 2016 11:31:22 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000401: using driver [oracle.jdbc.driver.OracleDriver] at URL [jdbc:oracle:thin:#localhost:1521:xe]
Apr 19, 2016 11:31:22 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000046: Connection properties: {user=vias, password=****}
Apr 19, 2016 11:31:25 AM org.hibernate.engine.jdbc.internal.JdbcServicesImpl configure
WARN: HHH000342: Could not obtain connection to query metadata : I/O-Fehler: The Network Adapter could not establish the connection
Apr 19, 2016 11:31:25 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
Apr 19, 2016 11:31:25 AM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000422: Disabling contextual LOB creation as connection was null
Apr 19, 2016 11:31:25 AM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
Apr 19, 2016 11:31:25 AM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
Apr 19, 2016 11:31:27 AM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 17002, SQLState: 08006
Apr 19, 2016 11:31:27 AM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: I/O-Fehler: The Network Adapter could not establish the connection
Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Could not open connection
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:132)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:221)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:157)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:67)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:160)
at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1426)
at Main.main(Main.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.sql.SQLRecoverableException: I/O-Fehler: The Network Adapter could not establish the connection
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:489)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:553)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:254)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528)
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:204)
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:292)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:214)
... 10 more
Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:439)
at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:454)
at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:693)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:251)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1140)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:340)
... 17 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:149)
at oracle.net.nt.ConnOption.connect(ConnOption.java:133)
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:405)
... 22 more
Process finished with exit code 1
Thanks a lot!
The Problem is solved!!!
The URL was wrong (Thanks to Mohamed) and I had to add the configuration details from the Sql Developer settings (Host, Port & SID).
<property name="connection.url">jdbc:oracle:thin:#000.000.000.000:1111:xe</property>
I think the Url is not valid
<property name="connection.url">000.000.000.000:11111</property>
try this out :
<property name="connection.url">jdbc:oracle:thin:#localhost:1521:orcl</property>
orcl is the default instance name, You can find the SID/SERVICE name in your tnsnames.ora file.

Spring Shell: Startup and shutdown LOGs

I'm quite new on Spring Shell framework. I've built/programmed the Spring Shell using the maven (mvn) repository/tool. It's quite easy to create/add new commands on it.
I issue that I have found is around the start up and shutdown of the Spring Shell application, because it output some LOGs in this processes which I couldn't disable then.
java -jar target/spring-shell-demo-1.0-SNAPSHOT.jar
Mar 04, 2014 9:47:20 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#d90727: startup date [Tue Mar 04 09:47:20 BRT 2014]; root of context hierarchy
Mar 04, 2014 9:47:20 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
:
--
spring-shell>quit
Closing org.springframework.context.support.ClassPathXmlApplicationContext#173180c: startup date [Tue Mar 04 09:51:17 BRT 2014]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#d90727
Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#f13e82: defining beans [readContainerCmd,getSubscriberAccountDetailsCmd,removeContainerCmd,addContainerCmd,getSubscriberDetailsCmd,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,deleteSubscriberCmd,createSubscriberCmd,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory#1f7d3b1
:
I thought that it could be a log4j configuration, so I have create the log4j.xml configuration as:
src/main/resources$ cat log4j.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="appender" class="org.apache.log4j.FileAppender">
<param name="File" value="helloWorld-Log.txt"/>
<param name="Append" value="false"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %p - %m%n"/>
</layout>
</appender>
<appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.SimpleLayout"/>
</appender>
<root>
<priority value ="ERROR"/>
<appender-ref ref="ConsoleAppender"/>
</root>
</log4j:configuration>
I was expecting that this could remove those INFO logs from start up and shutdown, but it is still the same.
As you can see i have create the log4j.xml at resource folder... I'm not sure it should be in another path, but I've tried to put in almost every place.
I would appreciate any help/tips on how to work out on this.
Regards,
Additional information of Spring Shell configuration:
src/main/resources/META-INF/spring$ cat spring-shell-plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:component-scan base-package="com.xx.yy" />
<context:component-scan base-package="com.xx.zz" />
</beans>
This works for me:
public static void main(String[] args) throws IOException {
LogManager.getLogManager().reset();
Bootstrap.main(args);
}

Unable to do a remote ejb access from a different host

We are using a servlet to access a remote ejb deployed on a different host and getting the
exception mentioned in the stacktrace below.
The remote access works if the servlet client and the remote ejb war are deployed in different domains and on the same host.
Works if they are deployed on the same host and same domain
does not work when deployed on two diffrent hosts.
Looking at the exception"CORBA.NO_PERMISSION: vmcid: 0x0 minor code: 0 completed: No", we thought it could be security issue.
But the test ejb application didnt have any security configurations. Tried adding the "" details to the sun-ejb-jar.xml
and used ProgrammaticLogin api. We got the same exception. Not sure if the security config was correct though.
The glassfish-corba log level was set to finest in the server where the ejb application was deployed. We then got this exception, "
org.omg.CORBA.BAD_INV_ORDER: FINE: IOP01600015: Service context add failed in portable interceptor because a service context with id 15 already exists vmcid: SUN minor code: 15 completed: No".
The full stacktrace is mentioned below in the server log.
tried using the front-end back-end test cases from Glassfish bug: http://java.net/jira/browse/GLASSFISH-15523. We are
getting the same exception.
Glassfish version: 3.1 build 43
Not sure where we are going wrong. Please help. Thanks.
Client Side log:
Caused by: javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=TestService,Remote 3.x interface =com.medallion.test.service.TestService,ejb-link=null,lookup=,mappedName=,jndi-name=corbaname:iiop:50.57.150.62:3700#TestService,refType=Session' . Actual (possibly internal) Remote JNDI name used for lookup is 'corbaname:iiop:50.57.150.62:3700#TestService__3_x_Internal_RemoteBusinessHome__' [Root exception is org.omg.CORBA.BAD_PARAM: FINE: IOP00100009: string_to_object conversion failed due to bad schema specific part in name TestService__3_x_Internal_RemoteBusinessHome__ vmcid: SUN minor code: 9 completed: No]
at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:178)
at com.sun.enterprise.container.common.impl.ComponentEnvManagerImpl$EjbReferenceProxy.create(ComponentEnvManagerImpl.java:1106)
at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:776)
at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:744)
at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:172)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:498)
... 38 more
Caused by: org.omg.CORBA.BAD_PARAM: FINE: IOP00100009: string_to_object conversion failed due to bad schema specific part in name TestService__3_x_Internal_RemoteBusinessHome__ vmcid: SUN minor code: 9 completed: No
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.sun.corba.ee.spi.orbutil.logex.corba.CorbaExtension.makeException(CorbaExtension.java:248)
at com.sun.corba.ee.spi.orbutil.logex.corba.CorbaExtension.makeException(CorbaExtension.java:95)
at com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator.handleFullLogging(WrapperGenerator.java:387)
at com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator.access$400(WrapperGenerator.java:107)
at com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator$2.invoke(WrapperGenerator.java:511)
at com.sun.corba.ee.spi.orbutil.proxy.CompositeInvocationHandlerImpl.invoke(CompositeInvocationHandlerImpl.java:99)
at $Proxy142.soBadSchemaSpecific(Unknown Source)
at com.sun.corba.ee.impl.resolver.INSURLOperationImpl.resolveCorbaname(INSURLOperationImpl.java:227)
at com.sun.corba.ee.impl.resolver.INSURLOperationImpl.resolveINSURL(INSURLOperationImpl.java:154)
at com.sun.corba.ee.impl.resolver.INSURLOperationImpl.operate(INSURLOperationImpl.java:145)
at com.sun.corba.ee.impl.orb.ORBImpl.string_to_object(ORBImpl.java:976)
at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:171)
... 43 more
Caused by: org.omg.CORBA.NO_PERMISSION: ----------BEGIN server-side stack trace----------
org.omg.CORBA.NO_PERMISSION: vmcid: 0x0 minor code: 0 completed: No
at com.sun.enterprise.iiop.security.SecServerRequestInterceptor.handle_null_service_context(SecServerRequestInterceptor.java:421)
at com.sun.enterprise.iiop.security.SecServerRequestInterceptor.receive_request(SecServerRequestInterceptor.java:443)
at com.sun.corba.ee.impl.interceptors.InterceptorInvoker.invokeServerInterceptorIntermediatePoint(InterceptorInvoker.java:612)
at com.sun.corba.ee.impl.interceptors.PIHandlerImpl.invokeServerPIIntermediatePoint(PIHandlerImpl.java:612)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.getServantWithPI(CorbaServerRequestDispatcherImpl.java:333)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:196)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1624)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1486)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:990)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:214)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:742)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:539)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2324)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
----------END server-side stack trace---------- vmcid: 0x0 minor code: 0 completed: No
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.MessageBase.getSystemException(MessageBase.java:900)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.ReplyMessage_1_2.getSystemException(ReplyMessage_1_2.java:131)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.getSystemExceptionReply(CorbaMessageMediatorImpl.java:637)
at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.processResponse(CorbaClientRequestDispatcherImpl.java:499)
at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(CorbaClientRequestDispatcherImpl.java:373)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.invoke(CorbaClientDelegateImpl.java:273)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.is_a(CorbaClientDelegateImpl.java:395)
at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:112)
at org.omg.CosNaming.NamingContextExtHelper.narrow(NamingContextExtHelper.java:73)
at com.sun.corba.ee.impl.resolver.INSURLOperationImpl.resolveCorbaname(INSURLOperationImpl.java:212)
... 47 more
Server Side log( after setting the corba log level to finest):
[#|2011-12-02T11:37:16.111-0600|FINE|glassfish3.1.1|javax.enterprise.resource.corba.org.glassfish.enterprise.iiop.impl|_ThreadID=161;_ThreadName=Thread-2;ClassName=org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory;MethodName=setAcceptedSocketOptions;|setAcceptedSocketOptions: SocketOrChannelAcceptorImpl[3700 IIOP_CLEAR_TEXT true true] ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=3700] Socket[addr=/173.13.42.205,port=54829,localport=3700]|#]
[#|2011-12-02T11:37:16.113-0600|FINE|glassfish3.1.1|javax.enterprise.resource.corba|_ThreadID=15;_ThreadName=Thread-2;ClassName=com.sun.logging.LogDomains$1;MethodName=getResourceBundle;|Can not find resource bundle for this logger. class name that failed: org.glassfish.enterprise.iiop.impl.GlassFishORBManager|#]
[#|2011-12-02T11:37:16.180-0600|FINE|glassfish3.1.1|javax.enterprise.resource.corba|_ThreadID=161;_ThreadName=Thread-2;ClassName=com.sun.logging.LogDomains$1;MethodName=getResourceBundle;|Can not find resource bundle for this logger. class name that failed: org.glassfish.enterprise.iiop.impl.GlassFishORBManager|#]
[#|2011-12-02T11:37:16.179-0600|FINE|glassfish3.1.1|javax.enterprise.resource.corba.org.glassfish.enterprise.iiop.impl|_ThreadID=161;_ThreadName=Thread-2;ClassName=org.glassfish.enterprise.iiop.impl.POAProtocolMgr;MethodName=getEjbDescriptor;|POAProtocolMgr.getEjbDescriptor->: [B#77dc7838|#]
[#|2011-12-02T11:37:16.181-0600|FINE|glassfish3.1.1|javax.enterprise.resource.corba|_ThreadID=161;_ThreadName=Thread-2;ClassName=com.sun.logging.LogDomains$1;MethodName=getResourceBundle;|Can not find resource bundle for this logger. class name that failed: org.glassfish.enterprise.iiop.impl.GlassFishORBManager|#]
[#|2011-12-02T11:37:16.181-0600|FINE|glassfish3.1.1|javax.enterprise.resource.corba.org.glassfish.enterprise.iiop.impl|_ThreadID=161;_ThreadName=Thread-2;ClassName=org.glassfish.enterprise.iiop.impl.POAProtocolMgr;MethodName=getEjbDescriptor;|POAProtocolMgr.getEjbDescriptor: [B#77dc7838: ejbId: 4,294,967,297|#]
[#|2011-12-02T11:37:16.181-0600|FINE|glassfish3.1.1|javax.enterprise.resource.corba|_ThreadID=161;_ThreadName=Thread-2;ClassName=com.sun.logging.LogDomains$1;MethodName=getResourceBundle;|Can not find resource bundle for this logger. class name that failed: org.glassfish.enterprise.iiop.impl.GlassFishORBManager|#]
[#|2011-12-02T11:37:16.181-0600|FINE|glassfish3.1.1|javax.enterprise.resource.corba.org.glassfish.enterprise.iiop.impl|_ThreadID=161;_ThreadName=Thread-2;ClassName=org.glassfish.enterprise.iiop.impl.POAProtocolMgr;MethodName=getEjbDescriptor;|POAProtocolMgr.getEjbDescriptor<-: [B#77dc7838: null|#]
[#|2011-12-02T11:37:16.183-0600|FINE|glassfish3.1.1|javax.enterprise.resource.corba.OMG|_ThreadID=161;_ThreadName=Thread-2;ClassName=com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator;MethodName=handleFullLogging;|IOP01600015: Service context add failed in portable interceptor because a service context with id 15 already exists
org.omg.CORBA.BAD_INV_ORDER: FINE: IOP01600015: Service context add failed in portable interceptor because a service context with id 15 already exists vmcid: SUN minor code: 15 completed: No
at sun.reflect.GeneratedConstructorAccessor729.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.sun.corba.ee.spi.orbutil.logex.corba.CorbaExtension.makeException(CorbaExtension.java:248)
at com.sun.corba.ee.spi.orbutil.logex.corba.CorbaExtension.makeException(CorbaExtension.java:95)
at com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator.handleFullLogging(WrapperGenerator.java:387)
at com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator.access$400(WrapperGenerator.java:107)
at com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator$2.invoke(WrapperGenerator.java:511)
at com.sun.corba.ee.spi.orbutil.proxy.CompositeInvocationHandlerImpl.invoke(CompositeInvocationHandlerImpl.java:99)
at $Proxy210.serviceContextAddFailed(Unknown Source)
at com.sun.corba.ee.impl.interceptors.ServerRequestInfoImpl.enqueue(ServerRequestInfoImpl.java:702)
at com.sun.corba.ee.impl.interceptors.ServerRequestInfoImpl.add_reply_service_context(ServerRequestInfoImpl.java:482)
at com.sun.corba.ee.impl.interceptors.ServerRequestInfoImpl.setCurrentExecutionPoint(ServerRequestInfoImpl.java:738)
at com.sun.corba.ee.impl.interceptors.PIHandlerImpl.invokeServerPIEndingPoint(PIHandlerImpl.java:632)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.runInterceptors(CorbaMessageMediatorImpl.java:2189)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.createResponseHelper(CorbaMessageMediatorImpl.java:2101)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.createResponseHelper(CorbaMessageMediatorImpl.java:2089)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.createSystemExceptionResponse(CorbaMessageMediatorImpl.java:2014)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleThrowableDuringServerDispatch(CorbaMessageMediatorImpl.java:1796)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleThrowableDuringServerDispatch(CorbaMessageMediatorImpl.java:1758)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:255)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1624)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1486)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:990)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:214)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:742)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:539)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2324)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
|#]
Code used:
Client:
servlet:
#WebServlet("/TestServlet")
public class TestServlet extends HttpServlet {
#EJB(name = "TestService")
private TestService testService;
/**
* #see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter w = response.getWriter();
try {
w.write("Test o/p: " + testService.testEJB("This is a test msg") + "\n");
} catch (Exception e) {
e.printStackTrace(w);
}
}
}
sun-web.xml:
<ejb-ref>
<ejb-ref-name>TestService</ejb-ref-name>
<!-- <jndi-name>corbaname:iiop:localhost:3700#TestService</jndi-name> -->
<jndi-name>corbaname:iiop:<ip>:3700#TestService</jndi-name>
</ejb-ref>
Remote ejb:
#Stateless(mappedName="TestService")
public class TestServiceImpl implements Serializable, TestService {
private static final long serialVersionUID = 1L;
private static final Logger logger = Logger.getLogger(TestServiceImpl.class.getName());
#Resource EJBContext ejbContext;
#Override
public String testEJB(String testStr) {
String userName = ejbContext.getCallerPrincipal().getName();
System.out.println("Username: " + userName);
return "Msg Recieved: " + testStr;
}
sun-ejb-jar.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
<sun-ejb-jar>
<enterprise-beans>
<ejb>
<ejb-name>TestServiceImpl</ejb-name>
<jndi-name>TestService</jndi-name>
<!--<ior-security-config>
<as-context>
<auth-method>USERNAME_PASSWORD</auth-method>
<realm>database-realm</realm>
<required>true</required>
</as-context>
<sas-context>
<caller-propagation>supported</caller-propagation>
</sas-context>
<transport-config>
<establish-trust-in-client>supported</establish-trust-in-client>
</transport-config>
</ior-security-config>-->
</ejb>
</enterprise-beans>
<security-role-mapping>
</security-role-mapping>
</sun-ejb-jar>
Perhaps not the answer to your question but I'll mention this here:
We had a similar problem with glassfish 3.1.2 where the occurring exception mentions CORBA.NO_PERMISSION and there is no stacktrace on the server side. Somewhere in the logfile we found the Exception Invalid iiop-listener orb-listener-1. Lazy-init not supported for SSL iiop-listeners
This is a bug in glassfish see:
https://java.net/jira/browse/GLASSFISH_CORBA-13
The glassfish admin interface automatically adds an SSL entry to the configured non SSL iiop-listener, due to this, the exception occures and remoting won't work anymore. As workaround you can remove the SSL-config-entry from the domain.xml manually to get remoting work again. But a soon as you open the IOP-Listener section again in the admin interface, the entry will be created again on glassfish restart.

NHibernate - Why is connection needed to build factory if connection can be passed to session constructor?

I'm new to NHibernate and am attempting to use it to connect to DB2. After trial and error and research, and more trial and error and research, I've finally come down to an error to which I cannot find an answer.
The error message reads: "The user must provide an ADO.NET connection - NHibernate is not creating it."
This error is not very helpful. Does this mean that I need to 1) put a connection string in my config file or 2) do I need to pass the connection into the factory? If 1 is true, is this mandatory? If it is then why are we given the ability to pass the connection object into the session which is what I desire to do?
If 2) is true, how do I pass in a connection object into the factory?
Thank you in advance. Below are my code snippets which may be helpful:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="dialect">NHibernate.Dialect.DB2400Dialect</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
</session-factory>
</hibernate-configuration>
</configuration>
try
{
Configuration cfg = new Configuration();
cfg.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(persistentClass));
SessionFactory = cfg.Configure().BuildSessionFactory(); //HERE I GET THE EXCEPTION
}
catch (Exception ex)
{
throw new Exception("NHibernate initialization failed", ex);
}
You need the session factory for configuration like connections, what kind of mapping you use, what kind of caches you use, what kind of sql dialect, etc. Not just the connection, so passing a connection as constructor argument probably will give you another unhelpful exception. You have to setup the connection in your configuration.
If you look at the documentation you should be able to see how to create the session factory programaticaly. Alternatively you could use fluentNhibernate to avoid that configuration file.