Skip to main content

GlassFish embedded and JDBC DataSource lookup

3 replies [Last post]
Anonymous

Hi. I am using glassfish-embedded-all.jar to start up an embedded EJb container. At certain point I want to look up a JDBC DataSource configured in the domain. The lookup succeds but in the background I get the exception:

<br />
Jul 2, 2010 10:45:06 AM com.sun.enterprise.connectors.service.ConnectorConfigurationParserServiceImpl getFileContent<br />
WARNING: Exception while performing resource-adapter's security permission check :<br />
java.io.FileNotFoundException: /home/rafal/EclipseWorkspaces/Workspace/GlassFishTest/gfembed3601547759702059688tmp/config/server.policy (No such file or directory)<br />
	at java.io.FileInputStream.open(Native Method)<br />
	at java.io.FileInputStream.(FileInputStream.java:106)<br />
	at java.io.FileReader.(FileReader.java:55)<br />
	at com.sun.enterprise.connectors.service.ConnectorConfigurationParserServiceImpl.getFileContent(ConnectorConfigurationParserServiceImpl.java:133)<br />
	at com.sun.enterprise.connectors.service.ConnectorConfigurationParserServiceImpl.getSecurityPermissionSpec(ConnectorConfigurationParserServiceImpl.java:92)<br />
	at com.sun.enterprise.connectors.ConnectorRuntime.getSecurityPermissionSpec(ConnectorRuntime.java:495)<br />
	at com.sun.enterprise.connectors.service.ResourceAdapterAdminServiceImpl.createActiveResourceAdapter(ResourceAdapterAdminServiceImpl.java:239)<br />
	at com.sun.enterprise.connectors.service.ResourceAdapterAdminServiceImpl.createActiveResourceAdapter(ResourceAdapterAdminServiceImpl.java:338)<br />
	at com.sun.enterprise.connectors.ConnectorRuntime.createActiveResourceAdapter(ConnectorRuntime.java:327)<br />
	at com.sun.enterprise.connectors.service.ConnectorService.loadDeferredResourceAdapter(ConnectorService.java:164)<br />
	at com.sun.enterprise.connectors.service.ConnectorService.loadResourcesAndItsRar(ConnectorService.java:133)<br />
	at com.sun.enterprise.connectors.service.ConnectorService.checkAndLoadPool(ConnectorService.java:307)<br />
	at com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl.createConnectorResource(ConnectorResourceAdminServiceImpl.java:91)<br />
	at com.sun.enterprise.connectors.ConnectorRuntime.createConnectorResource(ConnectorRuntime.java:266)<br />
	at com.sun.enterprise.resource.deployer.JdbcResourceDeployer.deployResource(JdbcResourceDeployer.java:107)<br />
	at org.glassfish.javaee.services.ResourceProxy.create(ResourceProxy.java:84)<br />
	at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:432)<br />
	at javax.naming.InitialContext.lookup(InitialContext.java:392)<br />
	at javax.naming.InitialContext.lookup(InitialContext.java:392)<br />
	at com.test.EmbeddedEJBTest.main(EmbeddedEJBTest.java:31)<br />

The code is:

<br />
EJBContainer ejb = null;<br />
try {<br />
    Map properties = new HashMap();<br />
    properties.put(EJBContainer.MODULES, "TestBeanArchive");<br />
    properties.put("org.glassfish.ejb.embedded.glassfish.installation.root", "glassfish");<br />
    ejb = EJBContainer.createEJBContainer(properties);<br />
    Context ic = ejb.getContext();<br />
    DataSource ds = (DataSource) ic.lookup("jdbc/DS");<br />
    System.out.println("DataSource looked up: " + ds);<br />
    DatabaseMetaData md = ds.getConnection().getMetaData();<br />
    System.out.println("Database is: " + md.getDatabaseProductName() + ", " + md.getDatabaseMajorVersion() + ", " + md.getDatabaseMinorVersion());<br />
} finally {<br />
    if (ejb != null) {<br />
        ejb.close();<br />
    }<br />
}<br />

Can anyone advise how to get rid of this problem? How can I tell GF to copy this file from domains/domain1/config/server.policy to its temp directory?

szcyp

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jakoh
Offline
Joined: 2010-08-12
Points: 0

Is there a work around for this problem?

mvatkina
Offline
Joined: 2005-04-04
Points: 0

The bug is fixed in the latest 3.1 code.

-marina

sirajg
Offline
Joined: 2006-02-01
Points: 0

This is because the security files are not in the temp location - this is in the process of being fixed and is captured in https://glassfish.dev.java.net/issues/show_bug.cgi?id=11728