Showing posts with label glassfish. Show all posts
Showing posts with label glassfish. Show all posts

30 August 2018

Glassfish console log timestamps

By default glassfish does not add timestamps to console logging messages and that allways leaves me wondering wether I'm looking at an old message or a new one.
To add timestamps edit $GLASSFISH_INSTALL/glassfish/domains/domain1/config/logging.properties
Replace domain1 with the domain your domainin the above,  if you are not using the default domain.
change:
java.util.logging.ConsoleHandler.formatter=com.sun.enterprise.server.logging.UniformLogFormatter
to:
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter

The default format is fine for me, but you can customize the format using:
java.util.logging.SimpleFormatter.format="your %format string"

The javadoc contains some format string examples.
Then (re)start the server.

18 January 2015

Glassfish missing DataSource: Table/View XXX does not exist

I have a little old webapp connecting to a DB using a glassfish ConnectionPool.
This used to run fine but on a more recent glassfish (4.0) I do net get a good datasource from Glassfish, resulting in a Table/View <name> does not exist error message (the message is a general symptom for a failed DB connection, which can have many other reasons).
The problem exists if I configure the DataSource in web.xml and also if I inject it using @Resource.
The solution is to explicitly map the application reference to the JNDI name in WEB-INF/glassfish-web.xml:

<resource-ref>
    <res-ref-name>jdbc/theDB</res-ref-name>
    <jndi-name>jdbc/theDB</jndi-name>
</resource-ref>  

If you don't, Glassfish returns a ConnectionPoolDataSource. Some people corrected this by refering in their web.xml to the ConnectionPoolDataSource, but the solution above will work both for web.xml and Resource injection.

22 September 2010

Glassfish 3 Admin Console hangs behind a proxy

When installing glassfish you can install the updatetool (default on) and configure proxysettings for it.
If the proxy settings do not match the currently active proxy the glassfish admin console may hang.
The glassfish web admin console will not forward your browser proxy settings to the updatetool, which has its own settings. It will wait for the updatetool to return, which never happens.

Here's a solution from the forums:
Change the update configuration using updatetool in GlassfishInstallDir/bin (it may ask you to install the tool first, just do so and start updatetool again).
In the tool go to preferences and enter correct proxy settings  (or disable automatic updates in the updates tab).

Alternatively, if you fail to install the tool, you can just kick out the module $GLASSFISH_HOME/glassfish/modules/console-updatecenter-plugin.jar by renaming it.

15 September 2010

How to get Java EE6 libraries

If you want to download Java EE6 libraries, Oracle bundles the whole glassfish server, and more with the java EE6 SDK. Other application servers also bundle the libraries.
That’ a whole lot of bloat if you just want to compile a little webapp. You can just put a small subset of the glassfish jars in your classpath:

  • glassfish_install_dir/glassfish/modules/javax.servlet.jar
  • glassfish_install_dir/glassfish/modules/javax.servlet.jsp.jar
  • glassfish_install_dir/glassfish/modules/javax.servlet.jsp.jstl.jar 
  • glassfish_install_dir/glassfish/modules/jstl-impl.jar
  • glassfish_install_dir/glassfish/modules/javax.ejb.jar (if using ejb)
If you are using maven this is not so much of a problem, just add a dependency to your POM.
<dependencies>
  <dependency>
    <groupId>javaee</groupId>
    <artifactId>javaee-api</artifactId>
    <version>6.0</version>
    <scope>provided</scope>
  </dependency>
</dependencies>
<repository>
   <id>java.net</id>
   <name>GlassFish Maven Repository</name>
   <url>http://download.java.net/maven/2</url>
</repository>
Use artifactId javaee-web-api if you just want the web profile.
If you are not using maven, you can just download the jars from the maven repository:
For Java EE5 that is:
<dependency>
  <groupId>javaee</groupId>
  <artifactId>javaee-api</artifactId>
  <version>5</version>
  <scope>provided</scope>
</dependency>

20 January 2009

Glassfish error loading EJB client application container application

Whenever you load an EJB standalone client to be run within a client container into Glassfish 2 you get this error (with a whole stack trace following it):

Error attempting to process extensions from the manifest of JAR file C:\projectlocal\netbeans\SL351_D2\project\Auction\dist\gfdeploy\Auction-ejb.jar; ignoring it and continuing
java.io.FileNotFoundException: C:\projectlocal\netbeans\SL351_D2\project\Auction\dist\gfdeploy\Auction-ejb.jar (The system cannot find the file specified)

The error can be safely ignored, as Tim Quinn explains.

Still it clutters other server output, so I tend to set the deployment logging level (javax.enterprise.system.tools.deployment) to severe in the glassfish console to get rid of it. I just switch it back when in doubt.