Wildfly 10 - HSQL Datascource - null pointer excception testing connection to database - datasource

I would like to know if anybody is aware of the following problem in wildfly 10.
When trying to setup a datasource for HSQL, I was confronted with the problem where for a non xa data source driver, you would expect the configuration element connection-url to be of any use. In particular, this configuration element is of use when you attempt to connect to H2 or oracle.
However, when testing the following configuration I was systematically hitting a null pointer exception on HSQL getConnection.
The hsql modulue is added as jboss module with:
<module xmlns="urn:jboss:module:1.3" name="org.hsql">
<properties>
</properties>
<resources>
<resource-root path="hsqldb-2.3.2.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
The original configuration of the datasource, the one that does not work was as follows:
<datasource jta="false" jndi-name="java:/jdbc/HSQL_NON_JTA_DS" pool-name="HSQL_NON_JTA_DS" enabled="true" use-ccm="true">
<connection-url>jdbc:hsqldb:hsql://localhost:9001/DATABSE</connection-url>
<datasource-class>org.hsqldb.jdbc.JDBCDataSource</datasource-class>
<driver>hsql</driver>
<security>
<user-name>USER</user-name>
<password>USER</password>
</security>
</datasource>
<driver name="hsql" module="org.hsql">
<datasource-class>org.hsqldb.jdbc.JDBCDataSource</datasource-class>
</driver>
With the following stack trace:
2017-03-01 18:08:47,083 WARN [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (thread: management task-6) IJ000604: Throwable while attempting to get a new connection: null: javax.resource.ResourceException: IJ031084: Unable to create connection
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:343)
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:350)
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:285)
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.createConnectionEventListener(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:1319)
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.getConnection(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:496)
at org.jboss.jca.core.connectionmanager.pool.AbstractPool.internalTestConnection(AbstractPool.java:1061)
at org.jboss.jca.core.connectionmanager.pool.strategy.OnePool.testConnection(OnePool.java:93)
at org.jboss.as.connector.subsystems.common.pool.PoolOperations$TestConnectionInPool.invokeCommandOn(PoolOperations.java:234)
at org.jboss.as.connector.subsystems.common.pool.PoolOperations$1.execute(PoolOperations.java:90)
at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:890)
at org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:659)
at org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:370)
at org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1344)
at org.jboss.as.controller.ModelControllerImpl.internalExecute(ModelControllerImpl.java:392)
at org.jboss.as.controller.ModelControllerImpl.execute(ModelControllerImpl.java:217)
at org.jboss.as.domain.http.server.DomainApiHandler.handleRequest(DomainApiHandler.java:212)
at io.undertow.server.handlers.encoding.EncodingHandler.handleRequest(EncodingHandler.java:72)
at org.jboss.as.domain.http.server.security.SubjectDoAsHandler$1.run(SubjectDoAsHandler.java:72)
at org.jboss.as.domain.http.server.security.SubjectDoAsHandler$1.run(SubjectDoAsHandler.java:68)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.jboss.as.controller.AccessAuditContext.doAs(AccessAuditContext.java:92)
at org.jboss.as.domain.http.server.security.SubjectDoAsHandler.handleRequest(SubjectDoAsHandler.java:68)
at org.jboss.as.domain.http.server.security.SubjectDoAsHandler.handleRequest(SubjectDoAsHandler.java:63)
at io.undertow.server.handlers.BlockingHandler.handleRequest(BlockingHandler.java:56)
at org.jboss.as.domain.http.server.DomainApiCheckHandler.handleRequest(DomainApiCheckHandler.java:95)
at io.undertow.security.handlers.AuthenticationCallHandler.handleRequest(AuthenticationCallHandler.java:52)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at org.hsqldb.jdbc.JDBCDataSource.getConnection(Unknown Source)
at org.hsqldb.jdbc.JDBCDataSource.getConnection(Unknown Source)
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:312)
... 31 more
This null pointer exception happend, quite simply because.
In the JDBCDataSource.java of HSQL, the following method was getting a null URL.
Meaning, JBOSS had not picked up the URL on the connection-url and configured on the driver.
private Connection getConnection(String url,
Properties props) throws SQLException {
if (!url.startsWith("jdbc:hsqldb:")) {
url = "jdbc:hsqldb:" + url;
}
return JDBCDriver.getConnection(url, props);
}
NOTE: If you want to debug HSQL you need to use the -debug.jar files that HSQL releases internally.
In any case...
After finding out that the subsytem for data sources is provided by IRON JCAMAR, it was possible to hunt the documentation for extra configuration properties to work-around what should never have been a problem.
Here is the documentation on elements supported for the data-source.
http://www.ironjacamar.org/doc/userguide/1.1/en-US/html_single/index.html#deployingds_descriptor
Ultiamtely, to make the connection work It was necessar to enrich it with the following element.
<connection-property name="url">jdbc:hsqldb:hsql://localhost:9001/DATABSE</connection-property>
Does it make any sense that additional element was necessary? It should have been redundant and unecessary. It is a good thing that custome data source properties are to be supported.
In this case, Is the problem with HSQL or is the problem with JBOSS.
In eery other app server, specifying the connection URL has always worked fine.
To me this appars to be a particular behavior of Wildfly.
This quite a problem since your average documentation on data sources just makes it abundantly clear that the connection-url is the element you do need to configure. In this case, it really is not.
Many thanks for a reply on this.

Looks like configuration issue. Update module name to org.hsqldb in datasource and module.xml file to follow standard module naming conventions. Update directory name from hsql to hsqldb under modules directory. It's all up to you. You can use your custom module naming convention too.
Some of the drivers does not have getURL() method implemented in their datasource classes. So, we have to specify datasource configuration differently for them.
Like Postgres, does not have getURL method. So, we will specify properties like this in our stanalone.xml/domain.xml file.
<xa-datasource-property name="ServerName">DatabaseHostName</xa-datasource-property>
<xa-datasource-property name="PortNumber">DatabasePortName</xa-datasource-property>
<xa-datasource-property name="DatabaseName">DatabaseName</xa-datasource-property>
<xa-datasource-class>com.edb.xa.PGXADataSource</xa-datasource-class>
<driver>postgresql</driver>
<security>
<user-name>database.username</user-name>
<password>database.password</password>
</security>
Whereas in case of Oracle which has getURL method implemented, configuration given below works fine.
<xa-datasource-property name="URL">jdbc:oracle:thin:#database.host:database.port:database.name</xa-datasource-property>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<driver>oracle</driver>
I am not sure about HSQL driver implementation of getURL API. You can try specifying properties like I mentioned for Postgres and check if it works for your use-case.

Related

Wildfly 17 Elytron: server side authentication with classes from EAR

We plan to migrate from Picketbox to Elytron and face the following problem:
With Picketbox a custom login module can use functionality of (or even can reside in) a deployment module (e.g. an EAR in wildfly/standalone/deployments) to implement authentication on the server side:
<subsystem xmlns="urn:jboss:domain:security:2.0">
<security-domains>
...
<security-domain name="MyDomain" cache-type="default">
<authentication>
<login-module name="MyLoginModule" code="de.example.wildfly.MyLoginModule" flag="required" module="deployment.de.example.wildfly.login"/>
</authentication>
</security-domain>
My first try was to use a custom realm in Elytron. But as far as I understand, a custom realm needs to be a "static" module (meaning it is located under wildfly/modules/...) and thus cannot access "dynamically" deployed modules (see https://developer.jboss.org/message/984198#984198).
<subsystem xmlns="urn:wildfly:elytron:7.0" final-providers="combined-providers" disallowed-providers="OracleUcrypto">
...
<security-domains>
<security-domain name="MyDomain" default-realm="MyRealm" permission-mapper="default-permission-mapper">
<realm name="MyRealm" role-decoder="from-roles-attribute" />
</security-domain>
</security-domains>
<security-realms>
...
<custom-realm name="MyRealm" module="de.example.wildfly.login" class-name="de.example.wildfly.MyCustomRealm" />
(I omitted some more of the security domain configuration)
When I try to load a Spring context (that is located in an EAR in order to access some custom classes from the EAR) in MyCustomRealm, I get the following error:
org.springframework.beans.factory.access.BootstrapException: Unable to initialize group definition. Group resource name [classpath:applicationContext-appServerBase.xml], factory key [applicationContextEjb]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext-appServerBase.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext-appServerBase.xml] cannot be opened because it does not exist
Which is no surprise, because my realm does not depend on the ear or any jar from therein, where the application context is located.
How can authentication (specifically for EJB calls) be customized on server side by using classes from a deployment module (EAR) in Elytron?
Maybe https://github.com/AntonYudin/wildfly-securityrealm-ejb is exactly what you are looking for.
It creates a SecurityRealm that can be configured with the address of an EJB that's deployed with your application.
The EJB has to be Stateless and must implement the method Map<String, Object> authenticate(String, String) which is called with a username and a password.
I guess you have to return a map that contains all roles and groups the user belongs to or null if the credentials are invalid.

Gemfire PDX error on startup : The PDX metadata has already been created as a peer metadata region. Please create your pools first

I am very new to gemfire and I am having trouble starting my application with it.
The error I get is
[info 2015/05/22 10:55:39.746 BRT <localhost-startStop-1> tid=0xf] Marking DistributionManager <v0>:17758 as closed.
10:55:40.922 [localhost-startStop-1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gfPool': Invocation of init method failed; nested exception is com.gemstone.gemfire.pdx.PdxInitializationException: The PDX metadata has already been created as a peer metadata region. Please create your pools first
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:743) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) ~[spring-context-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) ~[spring-context-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) ~[spring-web-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) [spring-web-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4728) [catalina.jar:8.0.21]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5166) [catalina.jar:8.0.21]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:8.0.21]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) [catalina.jar:8.0.21]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399) [catalina.jar:8.0.21]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_45]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_45]
Caused by: com.gemstone.gemfire.pdx.PdxInitializationException: The PDX metadata has already been created as a peer metadata region. Please create your pools first
at com.gemstone.gemfire.pdx.internal.PeerTypeRegistration.creatingPool(PeerTypeRegistration.java:501) ~[gemfire-8.0.0.jar:?]
at com.gemstone.gemfire.pdx.internal.TypeRegistry.creatingPool(TypeRegistry.java:273) ~[gemfire-8.0.0.jar:?]
at com.gemstone.gemfire.internal.cache.PoolFactoryImpl.create(PoolFactoryImpl.java:439) ~[gemfire-8.0.0.jar:?]
at org.springframework.data.gemfire.client.PoolFactoryBean.afterPropertiesSet(PoolFactoryBean.java:172) ~[spring-data-gemfire-1.6.0.RELEASE.jar:1.6.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
... 21 more
Here is my config
gemfire-context.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:gfe="http://www.springframework.org/schema/gemfire"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire-1.2.xsd">
<gfe:client-cache id="gemfireClientCache"
cache-xml-location="classpath:client.xml" pool-name="gfPool" use-bean-factory-locator="false" />
<gfe:pool id="gfPool" max-connections="10">
<gfe:locator host= "127.0.0.1" port="9980" />
</gfe:pool>
<gfe:lookup-region id="myRegion" name="myRegion" cache-ref="gemfireClientCache" />
</beans>
Here is Client.xml
<pdx read-serialized="false">
<pdx-serializer>
<class-name>com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer</class-name>
<parameter name="classes">
<string>br.com.xxx.*</string>
</parameter>
<parameter name="check-portability">
<string>true</string>
</parameter>
</pdx-serializer>
</pdx>
<region name="myRegion">
<region-attributes refid="PROXY" />
</region>
My applicationContext.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gfe="http://www.springframework.org/schema/gemfire"
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/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<!-- Use this configuration to test locally -->
<gfe:cache id="gemfireCache" pdx-persistent="true"/>
<gfe:partitioned-region id="myRegion" data-policy="PARTITION"/>
<import resource="classpath:registry-gemfire-context.xml"/>
<import resource="classpath:br/com/xxx/context.xml"/>
<context:component-scan base-package="br.com.xxx.*"/>
<bean id="string" class="java.lang.String"/>
</beans>
Agreed, the error message was perhaps not all that useful, but then this was a GemFire-specific Exception (i.e. PdxInitializationException) and error message.
Also, a few tips here...
You do not need to explicitly give <gfe:cache> or <gfe:client-cache> and <gfe:pool> an ID if you do not plan to change the defaults, which SDG sets in the XML namespace corresponding to the constants defined in... https://github.com/spring-projects/spring-data-gemfire/blob/master/src/main/java/org/springframework/data/gemfire/config/GemfireConstants.java#L27-31.
In this way, any client-side Region will automatically get assigned the 1 and only Pool in your configuration appropriately, providing, as #dturanski stated, you forgoe the native GemFire XML configuration and define your client Region as so...
<gfe:client-region id="myRegion" shortcut="PROXY"/>
Then "myRegion" is automatically associated with the ClientCache and client Pool.
You also do not need to explicitly set the DataPolicy on your server-side PARTITION Region...
Since <gfe:partitioned-region> without the persistent attribute set to true (defaults to false) implies PARTITION (i.e. it is redundant).
You can also define PDX Serialization on a ClientCache using the element. See the XML namespace for further details.
Finally, while you did the right thing in your Spring config on the server-side, explicitly declaring the <context:component-scan> element after the GemFire configuration, be sure to continue to do this otherwise you may run into unexpected behavior down the road as your use case and requirements grow, especially if you are injecting Regions into, say DAOs (rather than using the SDG Repository abstraction), for instance.
In fact, it maybe wiser to separate out the GemFire configuration from your application configuration altogether and rely on imports as you have done with
registry-gemfire-context.xml, and...
br/com/xxx/context.xml
GemFire is a complex animal, so keeping things encapsulated, organized and simple is the key to success with GemFire.
Hope this helps; cheers!
You might try configuring what's in Client.xml in Spring.
Got it.
The issue was that the name of the region on applicationContext.xml had a typo (minor case letter) So the region was not being created and after that I was trying to add it to the pool.
Anyway, that error message is just terrible... Maybe something related to the missing region on it would help a lot.
Hope it helps someone else.

Arquillian tomee remote

Using Arquillian 1.1.4.Final and Tomee 1.6.0.2
Took the tomee-plus-remote profile setup from the Tomee information about arqullian adapters and put it into the Maven pom.xml (with activeByDefault true).
Goal is to deploy a MQ JCA rar into the remote Tomee and configure a connection factory to MQ.
Set the arqullian.xml initially to:
<container qualifier="tomee" default="true">
<configuration>
<property name="httpPort">-1</property>
<property name="stopPort">-1</property>
</configuration>
</container>
Running via JUnit not sure why the webprofile is initialized and started rather than plus (when I have tomee plus specified in Maven):
Info: Succeeded in installing singleton service
jun 11, 2014 11:07:52 FM org.apache.openejb.config.ConfigurationFactory init
Info: openejb configuration file is 'C:\Users\MYG\AppData\Local\Temp\arquillian-apache-tomee\apache-tomee-webprofile-1.6.0.2\conf\tomee.xml'
Another thing is how to load a tomee.xml configuration. Thought, the "serverXml" in the arquillian.xml (set to src/test/resources/tomee.xml) would work but then everything inside that xml is not recognized as a valid rule. Can't add directives like Deployments as one does with resources. So how to configure the remote tomee from arquillian?
Yeah, tomee.xml was not really designed for arquillian.xml since all its config can be passed to properties attribute of tomee container using properties format
By adding a conf property to the arquillian.xml to for example src/test/conf where there is a tomee.xml file then it is loaded. This must be Tomee thing that I didn't know about until now.

org.apache.commons.dbcp.SQLNestedException on tomcat7

I've been fighting with my tomcat server for a while now and it still doesn't work.
I'm using tomcat7, on Debian Wheezy, with PostgreSQL v9.1.
I tried everything possible, and here is what I'm keeping on getting :
database.DataBaseException: Database error while trying to get a new connection. Error information: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
database.Connection$.getConnection(Connection.scala:20)
database.Users$.createRegisteredUser(Users.scala:58)
controllers.page.CreateAccountController.before(CreateAccountController.scala:36)
controllers.page.AbstractPageController.processRequest(AbstractPageController.scala:52)
controllers.page.AbstractPageController.doPost(AbstractPageController.scala:79)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
I have access to the application pages when I'm running my application and my tomcat server, so far I configured tomcat well enough for this, but as soon as I'm having an action that involves a request to the database (creation of user, etc.), I get this error !
As for the general context of the web application, I've started helping on an already existing project, I installed tomcat7 and cloned the source on my laptop. It works well with the other people working on it - and I haven't made any change to the application code so far (the code works fine): so the error definitely comes from my tomcat configuration and not from the code.
To configure a Tomcat7 server for a web application, what we have to do to configure is creating a context.xml in the META-INF/ directory right ?
I've also added a for the data source to the WEB-INF/web.xml file but it doesn't seem to be mandatory to have a tomcat7 application data source work fine.
I've copied and past my META-INF/context.xml file to Catalina/localhost/ directory with .xml.
I've added the postgres jdbc jar to /usr/share/tomcat7/lib (I've seen a lot of forum posts talking about a conf/lib but I can't find it so I figured it's this lib)
I've read things about tweaking with the tomcat context.xml file and whatnot, but there are pros and cons, and anyway it doesn't work either for me.
Here is my context.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="jdbc/dbname"
auth="Container"
type="javax.sql.DataSource"
username="user1"
password="user1"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/dbname"
maxActive="8"
maxIdle="4"/>
<Environment name="encryptionKey" type="java.lang.String" value="<the key>" override="false"/>
</Context>
What I added to the WEB-INF/web.xml:
<resource-ref>
<res-ref-name>jdbc/dbname</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
The code sample where it all starts (application written in scala) :
private val ds: DataSource = new javax.naming.InitialContext().lookup("java:comp/env/jdbc/dbname").asInstanceOf[DataSource]
private var connec: java.sql.Connection = null
def getConnection(): java.sql.Connection = {
try {
if (connec == null) {
connec = ds.getConnection() //here is raised the error
connec.setAutoCommit(false)
}
connec
} catch {
case ex: SQLException => throw new DataBaseException("Database error while trying to get a new connection. Error information: " + ex.toString())
}
}
I tried to run the application without context.xml and without the copy of if in the Catalina/localhost directory, and I get the same error. I guess the server just doesn't find my context.xml file ?
The last thing is I've compared my context.xml with some other people from the project, and they have exactly the same - and it works for them (except the db name and password that depends on what they chose)....
I also made sure the port 5432 is the right one, and it is.
Yes, it's pretty puzzly !
If you want more precision (I might be missing relevant things) don't hesitate to ask me !

weblogic, deployments are not reading properties from WEB-INF/classes, configured using Spring

I have a similar problem to: Using external properties files in weblogic and note that the accepted answer there is mainly working for me.
However, I have a follow-up (sorry, cannot work out how to just add comments to re-open the original question)
Does anyone know what the actual cause of this is and the "correct" (if there is such a thing) solution, or do people take copying files to the domain as a common practise in weblogic (10.3.3)
What I am using is:
Spring config has this:
<bean id="messages" class="java.util.ResourceBundle" factory-method="getBundle">
<constructor-arg index="0" value="config/messages"/>
</bean>
the messages bean is then referenced in other beans
The error is
<code>
<11-Apr-2011 11:47:23 o'clock BST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1302518829904' for task '4'. Error is: 'weblogic.application.ModuleException: '
weblogic.application.ModuleException:
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1514)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:486)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
Truncated. see log file for complete stacktrace
Caused By: java.util.MissingResourceException: Can't find bundle for base name config/messages, locale en_GB
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1521)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1260)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:715)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Truncated. see log file for complete stacktrace
</code>
I have tried removing the config/ at the start (and copying the messages.properties to WEB-INF and also WEB-INF/classes, to no avail. Should also point out that all of messages, messages _en_GB and messages _en_US exist
Your path reference doesn't have a 'classpath' in it. Have you tried putting the config directory in the root of the war?