Showing posts with label Glassfish. Show all posts
Showing posts with label Glassfish. Show all posts

Tuesday, 29 September 2009

Publish failed using Ant publisher - duplicate entry

I got so frustrated this week with the eclipse + maven + glasfish combo.
It kept on refusing to publish my web project to glassfish with some lame excuse:
Publish failed using Ant publisher
unable to assemble module
duplicate entry: some.file

In any case I figured out a workaround (lucky guess):
Right-click on your project -> Maven -> Disable Workspace Resolution

Voi la. I can work again and debug my web apps.

Thursday, 23 July 2009

get rid of glassfish master password

I've set up a webapp to be able to create-domain, deploy, test and delete-domain using the maven-glassfish-plugin.
The problem is that it insists on setting the master password.
Now its not possible to set the master password being used by the eclipse JavaEE glassfish plugin.
So when you try to start it from eclipse it asks for the master
password in the background:
Please enter the master password
After a while it times out and it says:
Server GlassFish at localhost failed to start.

I found out that you can tell glassfish to not ask the password anymore by doing:
asadmin change-master-password --savemasterpassword domain1
http://forums.java.net/jive/message.jspa?messageID=341172

However, I changed my admin password maven uses,
to be the real defaut master password: "changeit",
and now eclipse can start maven-created domains without me
having to --savemasterpassword
http://blogs.sun.com/alexismp/entry/what_is_a_glassfish_master

Thursday, 4 June 2009

Howto setup up a queue in glassfish.

This is my first attempt to setup queues on glassfish, so its probably not the best way, but its simple and it works for me for now.
Using the glassfish admin console:

* Configuration -> Java message Service -> Physical Destinations
- [New]
- Give it a name eg. my_test_queue and select queue.
- [Ok]
* Resources -> JMS Resources -> Destination Resources
- [New]
- JNDI Name: queues/my_test_queue
- Physical Destination Name: my_test_queue (must be the name you set above)
- Resource Type: javax.jms.Queue
- [Ok]
* Resources -> JMS Resources -> Connection Factories
(you only need one connection factory per type, not one per queue)
- [New]
- JNDI Name: connectionfactories/queueconnectionfactory
- Resource Type: javax.jms.QueueConnectionFactory
- [Ok]

Tuesday, 14 April 2009

Alfresco pain

After struggling a lot, I finally got Alfresco running on my Glassfish (v2ur2-b04),
for a couple of minutes then it broke again. I'll update this if I get it working one day.

First of all, look at the following for how to install using an oracle db.
http://wiki.alfresco.com/wiki/Database_Configuration
Which worked mostly, except it seems like you have to use the AlfrescoOracle9Dialect eg.:
hibernate.dialect=org.alfresco.repo.domain.hibernate.dialect.AlfrescoOracle9Dialect


Initially I got the following exceptions:
Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(Z)V
Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.

and
Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Lj
ava/lang/String;Ljava/lang/String;[Ljava/lang/String;)V
Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit
This was fixed by putting the correct hibernate jars in the domain1/lib and domain1/lib/ext folders.
I put asm-attrs.jar, cglib-2.1.3.jar, ojdbc14_g.jar (for oracle) in domain1/lib and
asm.jar, serializer.jar, xalan.jar in domain1/lib/ext


Next when I tried to log into the share webapp, I got the following:
"The remote server may be unavailable or your authentication details have not been recognized."
Thanks to the following link I figured out that alfresco does not like to run on a different port the server port is hardcoded into the war files in several places:
http://forums.alfresco.com/en/viewtopic.php?f=8&t=13625&start=15&st=0&sk=t&sd=a&hilit=The+remote+server+may+be+unavailable+or+your+authentication+details+have+not+been+recognised#p45826

Since I'd like to run it on a non-default port, I updated the port number by replacing all occurrences of 8080 with 12080.

I'm lazy so I did it like this:
$ cd domain1
$ replace 8080 12080 -- `find -iname "*.wsdl"`
$ replace 8080 12080 -- `find -iname "*.xml"`
$ replace 8080 12080 -- `find -iname "*.ftl"`
(btw this replace command I used is part of mysql-server-5.0: /usr/bin/replace)
See
http://wiki.alfresco.com/wiki/Changing_Default_Port_Configuration for more info.


Next I got this exception in my logs:

org.alfresco.web.framework.exception.RendererExecutionException: Unable to execute 'body' JSP include: /site-index.jsp
Caused by: java.lang.ClassCastException: org.alfresco.tools.FakeHttpServletResponse cannot be cast to org.apache.coyote.tomcat5.CoyoteResponseFacade

I found a fixed up version of alfresco-web-framework.jar which goes in domain1/applications/j2ee-modules/share/WEB-INF/lib on this forum:
http://forums.java.net/jive/thread.jspa?threadID=58906
Now I could actually log in.


But somewere along the line I got the following:
org.alfresco.web.framework.exception.RendererExecutionException: FreemarkerProcessor failed to process template: org/alfresco/global/slingshot-login.ftl
Caused by: freemarker.core.InvalidReferenceException: on line 32, column 70 in org/alfresco/global/slingshot-login.ftl link not found.
on line 32, column 70 in org/alfresco/global/slingshot-login.ftl link not found.
The problematic instruction:
----------
==> user-directive link [on line 32, column 70 in org/alfresco/global/slingshot-login.ftl]
in user-directive template.body [on line 6, column 1 in org/alfresco/global/slingshot-login.ftl]
and what fixed it for me AFAICT is to add the sun-web.xml described here:
http://blogs.sun.com/mandy/entry/alfresco_on_glassfish_short_version

mm.. seems like everything is not working for me yet. I have to switch between the patched and the original versions of alfresco-web-framework.jar (i.e log in with the one and play further with the other)

I'm doing a svn checkout at the moment to see if the developent verion works better on glassfish.
Maybe I can submit some patches if necessary.

Tuesday, 17 March 2009

Put persistence.xml in the war

I've been trying for days to get jpa, jndi, glassfish, hibernate and oracle to play together.

The main problem turns out that you have to put the persistence.xml file in your war file (project/web-root/WEB-INF/src/META-INF) not in your jar file.
I'll probably investigate more to see if it is somehow possible to put it in the jar, but for now my problems are solved.

... after some further experimentation I was able to put it in the jar, but I'm using <mapping-file>xx_orm.xml</mapping-file> now.

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)