JNDI lookup issue when upgrade GWT from 2.2 to 2.8

180 views
Skip to first unread message

simontu...@gmail.com

unread,
Apr 16, 2017, 8:26:49 PM4/16/17
to GWT Users
We used GWT for many years and not upgrade it for far.
We want to upgrade it to the latest GWT 2.8 and Java 1.8. We had a lot of issues.

Currently we had problem to create a data source with Spring under JBoss 6.4. It used to work on under GWT 2.2.

The data source is defined in JBoss and it bounds to the database without issue. It specified JNDI name there.

In Spring context we reference the jndi name defined in JBoss data source:

    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName">
            <value>java:jboss/datasources/oe</value>
        </property>
    </bean>

This used to work in GWT 2.2 but not in GWT 2.8. It tried to look in the jetty environment.It failed to find the jndi name.
Do I need to specify something special to let it looking for the JBoss defined jndi name?

23:39:32,746 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] (ServerService Thread Pool -- 53) Invoking afterPropertiesSet() on bean with name 'dataSource'
23:39:32,746 DEBUG [org.springframework.jndi.JndiTemplate] (ServerService Thread Pool -- 53) Looking up JNDI object with name [java:jboss/datasources/oe]
23:39:32,746 DEBUG [jndi] (ServerService Thread Pool -- 53) InitialContextFactory.getInitialContext()
23:39:32,746 DEBUG [jndi] (ServerService Thread Pool -- 53) Created initial context delegate for local namespace:org.eclipse.jetty.jndi.local.localContextRoot@7f559695
23:39:32,746 DEBUG [jndi] (ServerService Thread Pool -- 53) Looking up name="java:jboss/datasources/oe"
23:39:32,777 ERROR [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 53) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'departmentCodeDAOImpl': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/classes/resources/database-context.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/classes/resources/database-context.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException; remaining name 'java:jboss/datasources/oe'
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/classes/resources/database-context.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException; remaining name 'java:jboss/datasources/oe'
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:342) [org.springframework.orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) [org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) [org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385) [org.springframework.web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284) [org.springframework.web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) [org.springframework.web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3339) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3780) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:163) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:61) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:96) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_60]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_60]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_60]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_60]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_60]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/classes/resources/database-context.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/classes/resources/database-context.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException; remaining name 'java:jboss/datasources/oe'
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.orm.jpa.EntityManagerFactoryUtils.findEntityManagerFactory(EntityManagerFactoryUtils.java:99) [org.springframework.orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findNamedEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:511) [org.springframework.orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:493) [org.springframework.orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:657) [org.springframework.orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:630) [org.springframework.orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:339) [org.springframework.orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
... 24 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/classes/resources/database-context.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException; remaining name 'java:jboss/datasources/oe'
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
... 41 more
Caused by: javax.naming.NameNotFoundException; remaining name 'java:jboss/datasources/oe'
at org.eclipse.jetty.jndi.local.localContextRoot.lookup(localContextRoot.java:487) [gwt-dev.jar:]
at org.eclipse.jetty.jndi.local.localContextRoot.lookup(localContextRoot.java:533) [gwt-dev.jar:]
at javax.naming.InitialContext.lookup(InitialContext.java:417) [rt.jar:1.8.0_60]
at javax.naming.InitialContext.lookup(InitialContext.java:417) [rt.jar:1.8.0_60]
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154) [org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87) [org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152) [org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178) [org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95) [org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105) [org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201) [org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187) [org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
... 48 more

Juan Pablo Gardella

unread,
Apr 16, 2017, 8:44:37 PM4/16/17
to GWT Users

Gwt 2.8 uses java7. Are you using this version? The jndi name AFAIK is defined in jboss-web.xml file for jboss


--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Ignacio Baca Moreno-Torres

unread,
Apr 17, 2017, 1:45:31 AM4/17/17
to GWT Users

This is the classic classpath problem in GWT, you should not use the same classpath in client and server, tbroyer has been writing about that for years. In the server side no client side dependency should be added. You can either migrate to a multimodule project layout over selectively exclude client dependencies in the server until you get it work, this is probably what you do in previous versions, but as you can see, this is pretty fragile.

I deduce all this just seen the jetty class, maybe I'm wrong, but, really look like that.

simontu...@gmail.com

unread,
Apr 17, 2017, 3:43:21 AM4/17/17
to GWT Users
We run JBoss as standalone and the datasource are defined in standalone.xml file as below. It works fine for years under GWT 2.2.

        <subsystem xmlns="urn:jboss:domain:datasources:1.2">
            <datasources>
                <datasource jndi-name="java:jboss/datasources/oe" pool-name="DataSource" enabled="true" use-java-context="true">
                    <connection-url>jdbc:sqlserver://dbserver/wdsql1_inst:1442;databaseName=Dev</connection-url>
                    <driver>sqljdbc4</driver>
                    <pool>
                        <min-pool-size>2</min-pool-size>
                        <max-pool-size>5</max-pool-size>
                    </pool>
                    <security>
                        <user-name>db</user-name>
                        <password>password</password>
                    </security>
                    <validation>
                        <check-valid-connection-sql>select @@VERSION</check-valid-connection-sql>
                    </validation>
                    <statement>
                        <prepared-statement-cache-size>32</prepared-statement-cache-size>
                        <share-prepared-statements>true</share-prepared-statements>
                    </statement>
                </datasource>
                <drivers>
                    <driver name="sqljdbc4" module="com.sql.sqljdbc4">
                        <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
                    </driver>
                </drivers>
            </datasources>
        </subsystem>
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsub...@googlegroups.com.

simontu...@gmail.com

unread,
Apr 17, 2017, 2:01:25 PM4/17/17
to GWT Users
We have built only one war file for all server/client. Do you mean we should build separate war files? one for server and one for client? Can we totally avoid gwt-dev.jar in the server war file? Currently it is the gwt-dev.jar which requires jetty even we build in production mode.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsub...@googlegroups.com.

To post to this group, send email to google-we...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsub...@googlegroups.com.

Ignacio Baca Moreno-Torres

unread,
Apr 17, 2017, 3:27:20 PM4/17/17
to GWT Users
Having one final war file is ok. But, you should compile the client side in one module, and add the GWT compilation output to your war file as an overlay. This is a poor summary, all this is explained in the new maven plugin which was designed to solve exactly this problem.

To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.

Jens

unread,
Apr 17, 2017, 7:04:26 PM4/17/17
to GWT Users

Can we totally avoid gwt-dev.jar in the server war file? Currently it is the gwt-dev.jar which requires jetty even we build in production mode.

Oh, actually you NEVER EVER deploy gwt-dev.jar and gwt-user.jar. Both jars are only required during compilation from Java to JavaScript. The only things you might want to deploy are gwt-servlet.jar, gwt-servlet-deps.jar, requestfactory-server.jar in case you are using GWT-RPC or RequestFactory or AutoBeans on the server.

Once you remove those jars from your war file it should already work I guess.

-- J.

simontu...@gmail.com

unread,
Apr 17, 2017, 8:08:13 PM4/17/17
to GWT Users
Hi Jen, thanks so much for having saved my day! Once I removed gwt-dev.jar from my war file under WEB-INF/lib, it worked!
Reply all
Reply to author
Forward
0 new messages