I have an EJB JAR + JSF WAR that runs fine on local GlassFish deployed from NetBeans, but if i try to deploy the WAR on an online GlassFish, I get the following error:
Exception while loading the app :
java.lang.Exception: java.lang.IllegalStateException:
ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED!
com.ejb.entity.myEntity
EDIT GlassFish Log Message:
Message ID
Unsanitized stacktrace from failed start... com.sun.faces.config.ConfigurationException
Complete Message
http://pastebin.com/deSsYgDV
Also:
EJB deploys fine on online GF
EJB # local GF: sometimes yes, mostly not: http://pastebin.com/9R1acDVq
The EJB is pretty messy, both interfaces implement the same methods: When a session bean has remote as well as local business interface, there should not be any method common to both the interfaces. Should I fix this first?
Both servers are configured the same way. The EJB is imported in the WAR. What could be the problem? Any thoughts or ideas would be appreciated!
When a session bean has remote as well as local business interface, there should not be any method common to both the interfaces.
This is a NetBeans warning which I thought would cause no problems since the web application was using Local interfaces only. After removing the Remote interfaces from the EJB, I was able to deploy the WAR on both local and online GlassFish.
Related
I'm trying a very simple task of injecting an EJB on a JSF ManagedBean, both web and ejb module are in the same ear, I'm using a local interface of a stateless ejb, however, when trying to render the view which references the managed bean, I get this error:
GRAVE: Error Rendering View[/ejecutivo.xhtml]
javax.ejb.EJBException: Attempt to pass a reference to an EJBLocalObject to a remote client. A local EJB component may only be accessed by clients co-located in the same ear or standalone jar file.
at cl.bbb.vrc.ejb.bean.NotaClienteEJB_eeud7i_NotaClienteServiceImpl.writeObject(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
[...]
My project setup is this:
And I'm using Weblogic 10.3.6 (From OEPE) and JSF 2.0 shared library from WLS
I have tried every posible combination of dependency settings on the proyects on eclipse, but I can't get it to work, even exported an EAR and made sure that the war and ejb-jar were on it, deployed it on WLS, but got the same error.
If I change to #Remote Interface, I get a NotSerializableException
I already googled all over but didn't get anything useful for this issue...
EDIT
Okay, it has something to do with managedbean's serialization for client state saving method, I changed it to server and it works fine, however, I need to know why is this behavior happening. Maybe is a WLS 10.3.6 issue or setting?
I've got RESTful web services that I deploy in a .war file in JBoss AS 7.1. So far so good. Now I'm adding a .jar file with JPA 2.0 Entities. When I deploy the .war with the .jar file with the JPA Entities included I get this Exception at deploy time:
org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
This problem is posted numerous times all over the web and there are about half as many suggested solutions but none of them work.
There is no dom4j.jar in my archive. My Hibernate 4.0 dependencies are all <scope>provided</scope>. None of the .jar files included in my .war file have any dom4j classes in them.
Does anyone know what causes this with JBoss 7.1 and what the solution is?
Thanks.
The dom4j Exception was caused by having an incorrect port number in the in standalone.xml. Instead of throwing a meaningful exception JBoss threw the meaningless exception about dom4j.
After correcting the port number, I tried to reproduce the error by undeploying the archive, shutting down JBoss and setting the port number back to the incorrect port number. When I deployed and enabled the archive this time JBoss showed an Exception that it could not get a managed connection for the datasource. The meaningless exception gets replaced by meaningful exception after the first successful deployment of the archive with the correct .
A longer thread about this process is here.
Glassfish is not loading the com.mysql.jdbc.jdbc2.optional.MysqlXADataSource package.
The following error is thrown
javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence
Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException:
Error in allocating a connection. Cause: Class name is wrong or classpath is not set
for:com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
Error Code: 0 at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy
(EntityManagerSetupImpl.java:517)...
I have copied the mysql-connector jar file to the lib directory of Glassfish but I still get the above error.
How do I ensure that Glassfish can find my JDBC driver for my deployed application?
You will need to make the MySQL JDBC jar file available to Glassfish.
http://ushainformatique.com/blog/2010/03/19/jdbcwithglassfish/
EDIT:
How do I use different JDBC drivers? Where should I copy the jar(s)?
It is recommended to place JDBC drivers, that are used by all the
applications in the domain, in domain-dir/lib or
domain-dir/lib/classes. A restart of the application server instance
is required today so that the JDBC drivers are visible to applications
deployed in the domain.
From https://blogs.oracle.com/sivakumart/entry/classloaders_in_glassfish_an_attempt
So move the jar file into the lib dir below the domain into which you are deploying your app. The default Glassfish domain is domain1.
Restart Glassfish and this should work.
There is a Maven Glassfish plugin which may be worth evaluating http://maven-glassfish-plugin.java.net/ Using Maven and this plugin would help automate the deployment step. This would be more robust than doing manual deployments. Your call though of course.
Besides adding the driver to your classpath, you should try adding the appserv-rt.jar file to your project's build path (the jar is located in Glassfish's lib directory). If you don't want to include all the other jars you should first create a library containing the appserv-rt jar and then add it to your project's build path.
We could fix using
./asadmin start-database
This starts Derby (don't know why this is required, may be a bug, and I dont use this DB in my app)
:)
How do I use a deployed EJB app from a separate JSF application?
I'm attempting to separate the two applications and access the EJB through the remote interface. To do this I have two eclipse projects - one contains the EJB and persistence logic, tested independently and works. I then created a JSF project that references the EJB project (so I gain access to the remote interface), however this fails when attempting to either inject the EJB instance or lookup the JNDI name (I've tried several variants to no avail). This is what my JSF backing bean contains:
#EJB(lookup="java:global/LocEJB/LocalityEJB!com.ame.business.LocalityEJBRemote")
private LocalityEJBRemote locality;
This is on Glassfish, and I am only referencing the EJB project and not packaging it with the JSF project. When I do the latter, I receive error initializing EJB container problems on the JSF project. So, how do I access the remote EJB and does the way I'm approaching this make any sense?
Thanks in advance!
Your JSF application has to know about the EJB interfaces (at least they did on EJB 2.0). You're using the Proxy pattern to hide the fact that this is a remote component from your JSF client.
First of all you can not use Local interface if trying to access outside the container. You must use Remote Interface.
You can define your Remote interface in the sun-web.xml or EJB injection in the bean.
sun-web.xml code:
<ejb-ref>
<ejb-ref-name>com.xxx.session.UserRemote</ejb-ref-name>
<jndi-name>corbaname:iiop:127.0.0.xxx:3700#com.xxx.session.UserRemote</jndi-name>
</ejb-ref>
Another thing you must have Remote interfaces in your classpath.
I have a grails WAR that works in production in tomcat6, but when I go to redeploy the WAR, I overwrite the WAR files. The app reloads and I can load the front page (static page) but then when I try go to any other page I get this warning.
org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Error executing tag <g:render>: Error creating bean with name 'org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib': Instantiation of bean failed; nested exception is java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext at /WEB-INF/grails-app/views/layouts/baseContainer.gsp:28
at gsp_app_layoutsbaseContainerMapFb_gsp$_run_closure2.doCall(gsp_app_layoutsbaseContainer_gsp.groovy:42)
at gsp_app_layoutsbaseContainerMapFb_gsp$_run_closure2.doCall(gsp_app_layoutsbaseContainer_gsp.groovy)
at gsp_app_layoutsbaseContainerMapFb_gsp.run(gsp_app_layoutsbaseContainerMa_gsp.groovy:49)
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib': Instantiation of bean failed; nested exception is java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
at gsp_app_templates_facebookConnect_gsp.run(gsp_app_templates_facebookConnect_gsp.groovy:23)
... 4 more
Caused by: java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
What am I don't wrong? How can I call this so called "refresh"?
Whats the best way to hot redeploy WAR's on tomcat?
We'll probably not be able to resolve this at Stackoverflow. I hope you'll grade my support attempt, though, if you cannot find better information.
First, the Grails documentation suggests to restart Tomcat after (re-)deployment. But this shouldn't be necessary in most cases.
When Tomcat reloads the web application, a Grails ServletContextListener gets informed about that event and creates (should create) the Grails/Spring ApplicationContext that wires all the application's Spring beans (by using the aforementioned refresh(..) method, BTW). This goes wrong in your case.
Normally, after hot-deployment, you'll just have to wait a while until the ApplicationContext is completely available, but it should be after some time, finally. In between these two states, your error would be normal. Spring is working on the problem (for quite some time now) to make Spring's DispatcherServlet wait for the second state even when requests come in before that. So this is considered an improvement, not a bug.
As for the deployment process to Tomcat itself, see the Tomcat documentation. By default, hot-deployment should be as easy as overwriting an existing WAR file and letting Tomcat unpack it, but that can be customized on the <Host> tag in conf/server.xml.
Other ideas:
I guess you did wait long enough after re-deployment to make sure the error doesn't occur for a limited time, only.
You could post the complete stacktrace.
In the web.xml file of your WAR, are there any <listener>s or <filter>s that do not belong to the namespace org.codehaus...?
Do you use any special plugins, versions, specifications?
If you've setup a virtual host in Tomcat, have some look at the autoDeploy and unpackWAR settings.