2

I already made some research on Google and SO but could not find a solution.

I am writing a java ee 7 Web application including Omnifaces and Primefaces using Eclipse. When deploying the application to Glassfish 4, I get the following error:

javax.naming.NamingException: Lookup failed for 'java:comp/BeanManager'

The longer part of the stacktrace is

java.lang.IllegalStateException: javax.naming.NamingException: Lookup failed for 'java:comp/BeanManager' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Error retrieving java:comp/BeanManager [Root exception is java.lang.IllegalStateException: Cannot resolve bean manager]]
at org.omnifaces.util.JNDI.lookup(JNDI.java:87)
at org.omnifaces.config.BeanManager.init(BeanManager.java:76)
at org.omnifaces.config.BeanManager.getReference(BeanManager.java:115)
at org.omnifaces.application.OmniApplication.createConverter(OmniApplication.java:86)
at javax.faces.application.ApplicationWrapper.createConverter(ApplicationWrapper.java:403)
at org.primefaces.config.ConfigContainer.initConfig(ConfigContainer.java:69)

But I highly doubt that the problem is related to Omnifaces, it's more to state that I didn't do any messy call to cause this.

There is a beans.xml in WEB-INF, it's not completely empty.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
   http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
    bean-discovery-mode="all">
    <interceptors>
    <class>x.y.z.security.SecurityInterceptor</class>
</interceptors>    
</beans>

For the discovery-mode=all, I know it is not recommended, but this is due to an issue I found here: https://java.net/jira/browse/GLASSFISH-20667

If you need more information, facets config or the like, I am happy to post it - but as I've run out of ideas where to locate the problem I don't want to post the everything like complete POM, Glassfish, Eclipse, Maven config or all the code.

edit 2014-01-27:

Ok, after I had written my below comment (the one in comments), I got an idea. Can someone maybe check it out/confirm easily? I was able to load the application to GF after recreating a new database. Can eclipselink cause the above? I am using MS SQL Server 2012, and of course I get SQLExceptions and warnings that tables+fks already exist when redploying, but warnings should not fail my application deployment, should they?

<persistence-unit name="xyzPersistenceUnit" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> 
<jta-data-source>jdbc/xyzDS</jta-data-source>
  <properties>
    <property name="eclipselink.ddl-generation" value="create-tables"/>
    </properties>

th_eg
  • 21
  • 5
  • Looks like PrimeFaces is initialized before CDI is initialized. Haven't seen this before. Do you see chance to switch to a different server? (do you by the way already know that Oracle ever officially announced that GF open source version shouldn't be used for production?) – BalusC Jan 22 '14 at 19:51
  • @BalusC: I will test on a different server on the weekend and update this post on what happened. On the GF: I know, unfortunately, but GF is my personal choice for early development. To my bad: I don't know much details on the initialization order and what it#s based on. – th_eg Jan 23 '14 at 15:17
  • @BalusC: I was not able to get it run on an EAP 6, I used the most recent version as I just set the server up. I get a ClassNotFoundException for one of my self-written classes in Web-inf/classes during deployment, which from (the little I know about jboss) is most likely covering an underlying exception in the initialization of the class. However I can not find any hints in the logfile. Any suggestions? I'm not a 100% sure yet, but I believe we had this project already running on the GF. – th_eg Jan 27 '14 at 20:47

0 Answers0