Saturday 14 February 2009

No PasswordCredential found

I got the exception below while trying to set up a JNDI database configuration in glasshish to point to my local Oracle XE installation. Google didn't help so I'm posting it here for in case it happens to me again.
I didn't actually figure out how to resolve it. I fiddled around in domains/domain1/config/domain.xml a little, but in the end I think restarting Glassfish did the trick for me.


INFO: RAR7099: The mcf being used to allocate the connection and the MCF in the pool are not equal.
WARNING: RAR5038:Unexpected exception while creating resource for pool aum_pool. Exception : No PasswordCredential found
WARNING: RAR5117 : Failed to obtain/create connection from connection pool [ aum_pool ]. Reason : No PasswordCredential found
WARNING: RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: No PasswordCredential found]
WARNING: java.sql.SQLException: Error in allocating a connection. Cause: No PasswordCredential found
at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:115)

Friday 13 February 2009

Eclipse Dynamic Web Project + Maven2 = initial pain

Eclipse 3.4 ganymede gave me a VERY frustrated day yet again :(
I spent most of the day convincing it to to install the m2eclipse plugin.
It kept on telling me:
No repository found containing: org.maven.ide.components.dependency_tree/osgi.bundle
So after updating all my eclipse plugins and also using the Maven Integration for Eclipse Dev Update Site and restarting Eclipse, it finally decided it will install.
(You almost want to swear at it and call it M$ Eclipse. Ok it wasn't that bad.)

Next I came to a painful catch 22: I want a Dynamic Web Project so that my code can be automatically deployed on my Glassfish server. But I also want it to be a Maven project for all the maven goodness, without changing the standard maven code layout.

I googled for hours but I only found my worst fear to be true: The only way to do it is to make it a web project, changing its structure to be in the maven layout and then activate it as a maven project. I improved on this site's methods a bit by doing some configs up front and thus avoiding to mess with them later. Here are my steps as good as I remembered:
  1. (I created a reference maven web project in eclipse, but it turned out that I didn't actually need it)
  2. Create a new Eclipse Dynamic Web Project. Don't click finish, click [next].
  3. Set the 'Content Directory' to 'src/main/webapp' and the 'Java Source Directory' to 'src/main/java'. Now you can click [finish].
  4. Right click on the project -> Maven -> Enable Dependancy Management.
  5. Set the packaging to war, [finish].
  6. You can delete the build folder now since maven already started to use the target folder.
  7. If you need the other standard maven source and target folers, you can add them manually or directly in .classpath:
    <classpathentry kind="src" path="src/main/resources">
    <classpathentry kind="src" output="target/test-classes"
    path="src/test/java">
    <classpathentry kind="src" output="target/test-classes"
    path="src/test/resources">



  8. From there I just had to set maven to use Java6 in pom.xml:
    <build>
    <pluginmanagement>
    <plugins>
    <plugin>
    <groupid>org.apache.maven.plugins</groupid>
    <artifactid>maven-compiler-plugin</artifactid>
    <configuration>
    <source>1.6</source>
    <target>1.6</target>
    </configuration>
    </plugin>
    </plugins>
    </pluginmanagement>
    </build>

  9. Right click on the project -> Maven -> Update Dependancies.
  10. I removed the following from .settings/org.eclipse.wst.common.component:
    <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
    <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
  11. Then I could run maven tasks and also deploy it to my glassfish server (already set up to be managed by eclipse the normal JavaEE way (run as -> run on server))
sweetness! I love Eclipse+JavaEE+maven again.
I think the WTP or whatever does the new 'Dynamic Web Project' wizard would do well to have a checkbox which can setup the web project in the maven sturcture for you.
tomorrow (aka later today) I have to do the real work of actually putting an application into this empty shell.

goodnight