-
15. Re: Preconfiguring embedded Glassfish
andreyo15 Jul 19, 2011 7:09 AM (in response to dan.j.allen)May be my case was not popular here, but I faced the following
I have a custom JCA connector, which is maven module and part of ear application (service), which provides methods, accessing third party system via custom JCA connector.
I test my ear service in embedded GlassFish 3.1 using Arquillian and Shrinkwrap-maven-dependency-resolving
Problem is, that jca connector can not be preconfigured same way to jdbc or jms connectors, because it's library is deployed at runtime
and I need to specify in sun-resources.xml link to connector library: resource-adapter-name="ear-module-name#connector-library-name".
In jdbc/jms case, libs are just copied before container starts, and there is no problem with preconfiguring in domain.xml.
Packaging sun-resources.xml to ear/META-INF with connector module inside and deploying to embeded GF doesn't install my connector (may be I do something wrong here..)
but add-resources command on standalone GF works good, and connector is created.
My question is, is there any way to install/configure custom connectors dynamically in embedded GF 3.1? I've tried Jboss IronJacamar library (1.0.0.Final), works well standalone, but it uses older arquillian libs (1.0.0.CR1), and I faced difficulties to make it working with arquillian 1.0.0.Alpha5.
my sun-resources.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Resource Definitions //EN"
"http://www.sun.com/software/appserver/dtds/sun-resources_1_4.dtd">
<resources>
<connector-resource enabled="true" jndi-name="eis/conn-factory1" object-type="user" pool-name="connector-conn-pool">
</connector-resource>
<connector-connection-pool connection-definition-name="javax.resource.cci.ConnectionFactory" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" max-pool-size="6" max-wait-time-in-millis="60000" name="connector-conn-pool" pool-resize-quantity="2" resource-adapter-name="ear-module-name#connector-library-name" steady-pool-size="2"/>
</resources>
-
16. Re: Preconfiguring embedded Glassfish
aslak Jul 19, 2011 7:42 AM (in response to andreyo15)Can you split up the deployment in two? first Deploy the RAR Adaptor, then a EAR with the sun-resources for configuration ?
@Deployment(name = "RAR", order = 1) public static ResourceAdaptorArchive createRar() { ... } @Deployment(name = "EAR", order = 2) public static EnterpriseArchive createEar() { return ShrinkWrap.create(EnterpriseArchive.class) .addApplicationResource("my-rar-sun-resource.xml", "sun-resources.xml") }
?
-
17. Re: Preconfiguring embedded Glassfish
andreyo15 Jul 19, 2011 10:28 AM (in response to aslak)jndi-name="eis/hod-conn-factory2" is not created (as specified in sun-resources.xml)
@Deployment(order = 1, testable = false, name="rar") public static ResourceAdapterArchive getRAA() { String name = "hod-connection-pool"; ResourceAdapterArchive raa = ShrinkWrap.create(ResourceAdapterArchive.class, name + ".rar"); JavaArchive ja = ShrinkWrap.create(JavaArchive.class, UUID.randomUUID().toString() + ".jar"); ja.addClasses(J2HOD3270ManagedConnectionFactory.class, J2HODConnectionFactory.class, J2HODConnection.class); raa.addAsLibrary(ja); raa.addAsManifestResource("ra.xml", "ra.xml"); return raa; } @Deployment(order = 2, name="ear") public static Archive<?> createDeployment2() { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "foo2.ear"); // ear.addAsApplicationResource("sun-resources.xml", "sun-resources.xml"); ear.addAsManifestResource("sun-resources.xml", "sun-resources.xml"); return ear; } @Test @OperateOnDeployment(value="ear") public void doLookup() throws NamingException { new JNDITree().printJNDITree(""); InitialContext context = new InitialContext(); context.lookup("eis/hod-conn-factory2"); }
sun-resources.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE resources PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Resource Definitions //EN" "http://www.sun.com/software/appserver/dtds/sun-resources_1_4.dtd"> <resources> <connector-resource enabled="true" jndi-name="eis/hod-conn-factory2" object-type="user" pool-name="connector-conn-pool"> </connector-resource> <connector-connection-pool connection-definition-name="javax.resource.cci.ConnectionFactory" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" max-pool-size="6" max-wait-time-in-millis="60000" name="connector-conn-pool" pool-resize-quantity="2" resource-adapter-name="hod-connection-pool" steady-pool-size="2"/> </resources>
Created only this one:
__SYSTEM/resource/hod-connection-pool#javax.resource.cci.ConnectionFactory
it is always created after resource adapter deployed in own jar, or within ear
log
INFO: GlassFish Server Open Source Edition 3.1 (java_re-private) startup time : Embedded (7,806ms), startup services(976ms), total(8,782ms)
PlainTextActionReporterSUCCESSDescription: deploy AdminCommandApplication deployed with name foo2.
[name=foo2
Jul 19, 2011 5:01:51 PM com.sun.enterprise.web.WebApplication start
INFO: WEB0671: Loading application [foo2#test.war] at [test]
Jul 19, 2011 5:01:51 PM org.glassfish.deployment.admin.DeployCommand execute
INFO: foo2 was successfully deployed in 1,773 milliseconds.
Jul 19, 2011 5:01:51 PM org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher injectClass
INFO: BeanManager cannot be located at java:comp/BeanManager. Either you are using an archive with no beans.xml, or the BeanManager has not been bound to that location in JNDI.
-->jdbc: com.sun.enterprise.naming.impl.TransientContext
-->__default: org.glassfish.javaee.services.ResourceProxy
Jul 19, 2011 5:01:51 PM org.hibernate.validator.engine.resolver.DefaultTraversableResolver detectJPA
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
-->__TimerPool: org.glassfish.javaee.services.ResourceProxy
-->ExactDatasource: org.glassfish.javaee.services.ResourceProxy
Jul 19, 2011 5:01:52 PM org.hibernate.validator.engine.resolver.DefaultTraversableResolver detectJPA
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
Jul 19, 2011 5:01:52 PM com.sun.enterprise.connectors.util.ResourcesUtil getRANameofJdbcConnectionPool
WARNING: RAR8068: Using default datasource : __ds_jdbc_ra for pool : HsqldbPool
Jul 19, 2011 5:01:52 PM com.sun.enterprise.connectors.util.ResourcesUtil getRANameofJdbcConnectionPool
WARNING: RAR8068: Using default datasource : __ds_jdbc_ra for pool : HsqldbPool
-->UserTransaction: com.sun.enterprise.transaction.TransactionNamingProxy$UserTransactionProxy
-->ejb: com.sun.enterprise.naming.impl.TransientContext
-->mgmt: com.sun.enterprise.naming.impl.TransientContext
-->MEJB: org.glassfish.kernel.javaee.MEJBNamingObjectProxy
-->java:global: com.sun.enterprise.naming.impl.TransientContext
-->__SYSTEM: com.sun.enterprise.naming.impl.TransientContext
-->descriptors: com.sun.enterprise.naming.impl.TransientContext
-->__cp_jdbc_ra: org.glassfish.javaee.services.ConnectorDescriptorProxy
Jul 19, 2011 5:01:52 PM org.glassfish.kernel.javaee.MEJBNamingObjectProxy deployMEJB
INFO: Loading MEJB app on JNDI look up
-->jmsra: org.glassfish.javaee.services.ConnectorDescriptorProxy
-->__ds_jdbc_ra: com.sun.enterprise.deployment.ConnectorDescriptor
-->hod-connection-pool: com.sun.enterprise.deployment.ConnectorDescriptor
-->__dm_jdbc_ra: org.glassfish.javaee.services.ConnectorDescriptorProxy
-->__xa_jdbc_ra: com.sun.enterprise.deployment.ConnectorDescriptor
-->jaxr-ra: org.glassfish.javaee.services.ConnectorDescriptorProxy
-->pools: com.sun.enterprise.naming.impl.TransientContext
-->DerbyPool: com.sun.enterprise.connectors.ConnectorConnectionPool
-->__TimerPool: com.sun.enterprise.connectors.ConnectorConnectionPool
-->hod-connection-pool#javax.resource.cci.ConnectionFactory: com.sun.enterprise.connectors.ConnectorConnectionPool
-->HsqldbPool: com.sun.enterprise.connectors.ConnectorConnectionPool
Jul 19, 2011 5:01:52 PM com.sun.enterprise.connectors.util.RAWriterAdapter write
INFO: -> [J2HODBaseManagedConnectionFactory.createConnectionFactory(ConnectionManager)]
Jul 19, 2011 5:01:52 PM com.sun.enterprise.connectors.util.RAWriterAdapter write
INFO:
Jul 19, 2011 5:01:52 PM com.sun.enterprise.connectors.util.RAWriterAdapter write
INFO: <- [J2HODBaseManagedConnectionFactory.createConnectionFactory(ConnectionManager)]
Jul 19, 2011 5:01:52 PM com.sun.enterprise.connectors.util.RAWriterAdapter write
INFO:
-->resource: com.sun.enterprise.naming.impl.TransientContext
-->hod-connection-pool#javax.resource.cci.ConnectionFactory: javax.naming.Reference
-->com.sun.enterprise.container.common.spi.util.InjectionManager: com.sun.enterprise.container.common.impl.util.InjectionManagerImpl
javax.naming.NamingException: Lookup failed for 'eis/hod-conn-factory2' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}