I'm getting a weird problem in GlassFish 2.1 - I'm a beginner with this container and I'm having trouble pinning this down.
I have a new install of GlassFish 2.1 with a JDBC connection pool defined called testDerbyPool. I then have a resource defined called jdbc/testDerbyPool pointing at that pool. The resource type is javax.sql.DataSource and I can successfully ping the pool.
I then have a single class in a webapp with this declaration:
#Resource(name="jdbc/testDerbyPool")
private javax.sql.DataSource source;
This declaration in my web.xml:
<resource-ref>
<res-ref-name>jdbc/testDerbyPool</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
When I try to deploy the application, I get this error:
[#|2009-09-09T21:40:47.582+0100|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=24;_ThreadName=Thread-32;_RequestID=1ca4ab80-ae39-4920-be18-f535b025bb51;|WebModule[/cptest1]PWC1275: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
and a huge stack trace, starting:
java.lang.NoClassDefFoundError: LDataSource;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
with root cause:
Caused by: java.lang.ClassNotFoundException: DataSource
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1498)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
I don't understand how DataSource can be 'not found'! Any ideas?
Next time I went back after asking the question, I noticed a build error in Eclipse, somehow gotten an extra JRE in the path marked 'unbound'. Looking around my system, I got a JVM point release update automatically between starting Eclipse up and doing the build/deploy.
Anyway, removed it, tried again, worked.
So check for build errors and build path problems if you see this problem.
Related
I followed the steps mentioned here to configure Keycloak 15.0.0 with PostgreSQL 13.
I have created a folder inside
(keycloak-15.0.0\modules\system\layers\keycloak\org -->
\postgresql\main) and pasted postgresql-42.2.23 jar and added
module.xml.
I have updated my standalone.xml file with changes for
driver and datasource connection properties.
But when I give the command standalone.bat -Djboss.socket.binding.port-offset=100, it is failing due to
Caused by: javax.naming.NameNotFoundException: datasources/KeycloakDS [Root exception is java.lang.IllegalStateException]
and Caused by: java.lang.IllegalStateException. If anyone faced the same issue and resolve it?
I have completely cleared the folder (keycloak - unzipped) and followed the same steps mentioned above, it is working fine now.
I am migrating an old application running on java 1.5 and jboss 4.3 to java 1.8 and jboss 7.2. While deploying on jboss 7.2, I am getting error related to resource-ref defined under ejb-ref in jboss-web.xml.
I was able to transform other parts of the application like moving libraries to modules and changes in EJB lookup jndi however I am not able to find a solution to make resource-ref work with ejb-ref
<jboss-web>
...
<ejb-ref>
<ejb-ref-name>ejb/CA_ProductEJBHome</ejb-ref-name>
<ejb-link>ProductEJB.jar#CA_ProductEJB</ejb-link>
<jndi-name>CA_ProductEJB</jndi-name>
<resource-ref>
<description>Product Database</description>
<res-ref-name>jdbc/productDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<jndi-name>java:jboss/datasources/CA_productDB</jndi-name>
<res-auth>Container</res-auth>
</resource-ref>
</ejb-ref>
...
</jboss-web>
Error Trace :
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[127,3]
Message: Unexpected element 'resource-ref' encountered
at org.jboss.metadata.parser.util.MetaDataElementParser.unexpectedElement(MetaDataElementParser.java:115)
at org.jboss.metadata.parser.ee.EJBReferenceMetaDataParser.parse(EJBReferenceMetaDataParser.java:90)
at org.jboss.metadata.parser.ee.EnvironmentRefsGroupMetaDataParser.parseRemote(EnvironmentRefsGroupMetaDataParser.java:108)
Very interesting question.
Issue below:
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[127,3]
Message: Unexpected element 'resource-ref' encountered
at org.jboss.metadata.parser.util.MetaDataElementParser.unexpectedElement(MetaDataElementParser.java:115)
So in for EAP 6/7 we needed to modify the JNDI names, following a name convention.
JNDI name convention
Following the migration guide in 3.2.14.2.3. Application Changes Required to Run EJB 2.x
We go to: Modify the JBoss-web.xml File Descriptor, which describes that you must modify the for each for 'new JNDI fully qualified' lookup format: either java:global, or java:module, or java:app.
Exception
My guess is that the parser, while reading the tag, was expecting this standard and since it didn't find the exception was thrown. Pay attention also on the parenting since is at the same level as
Regards
Trying to get WorkManagers working with CommonJ in a Spring Boot app, hosted in TomEE.
Currently have the following configuration:
Tomcat context.xml
<Context>
<Resource name="myWorkManager"
auth="Container"
type="commonj.work.WorkManager"
factory="de.myfoo.commonj.work.FooWorkManagerFactory"
maxThreads="5" />
<ResourceLink
name="myWorkManager"
global="myWorkManager"
type="commonj.work.WorkManager" />
</Context>
Spring app web.xml
<resource-ref>
<res-ref-name>myWorkManager</res-ref-name>
<res-type>commonj.work.WorkManager</res-type>
<res-auth>Container</res-auth>
</resource-ref>
This is currently throwing the following exception when the app loads:
Caused by: org.springframework.jndi.TypeMismatchNamingException: Object of type [class de.myfoo.commonj.work.FooWorkManager] available at JNDI location [java:comp/env/myWorkManager] is not assignable to [commonj.work.WorkManager]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:182)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
at org.springframework.scheduling.commonj.WorkManagerTaskExecutor.afterPropertiesSet(WorkManagerTaskExecutor.java:110)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
... 53 more
I have the CommonJ jars downloaded from http://commonj.myfoo.de/install.shtml in my Tomcat lib directory.
I feel like I'm getting pretty close but slightly puzzled by this exception.
Any help would be much appreciated.
UPDATE
If I remove the two CommonJ jars from TomEE lib folder, I get this exception
Caused by: java.lang.ClassNotFoundException: commonj.work.WorkManager
Which is what I would expect.
If I remove the factory property from the resource element I get:
Caused by: org.springframework.jndi.TypeMismatchNamingException:
Object of type [class org.apache.openejb.core.ivm.naming.IvmContext]
available at JNDI location [java:comp/env/wm/default] is not
assignable to [commonj.work.WorkManager]
Im encounter with same issue, when try to start my app locally in maven-jetty-plugin. M. Deinum comment was very helpful. This error happens if you have lib jar in shared lib of your Application Server and in your WEB-INF/lib folder of web application, because server use one jar to create resource (parent classloader), but application use self jar(child classloader) and it two different classes hierarchy, so FooWorkManager cant be cast to WorkManager.
I have one application using CDI with weld 2.2.9.Final and embedded Tomcat 7.0.57 and everything works fine.
After upgrading to embedded Tomcat 7.0.59, when I'm starting my application I got the following exception:
Caused by: org.jboss.weld.exceptions.IllegalStateException: WELD-001201: Error loading beans.xml jndi:/localhost/WEB-INF/beans.xml
at org.jboss.weld.xml.BeansXmlParser.parse(BeansXmlParser.java:124)
at org.jboss.weld.bootstrap.WeldBootstrap.parse(WeldBootstrap.java:131)
at org.jboss.weld.environment.servlet.deployment.WebAppBeanArchiveScanner.scan(WebAppBeanArchiveScanner.java:78)
at org.jboss.weld.environment.deployment.discovery.AbstractDiscoveryStrategy.performDiscovery(AbstractDiscoveryStrategy.java:83)
at org.jboss.weld.environment.servlet.WeldServletLifecycle.createDeployment(WeldServletLifecycle.java:230)
at org.jboss.weld.environment.servlet.WeldServletLifecycle.initialize(WeldServletLifecycle.java:120)
at org.jboss.weld.environment.servlet.EnhancedListener.onStartup(EnhancedListener.java:61)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5513)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 more
Caused by: java.io.FileNotFoundException: jndi:/localhost/WEB-INF/beans.xml
at org.apache.naming.resources.DirContextURLConnection.getInputStream(DirContextURLConnection.java:384)
at java.net.URL.openStream(URL.java:1037)
at org.jboss.weld.xml.BeansXmlParser.parse(BeansXmlParser.java:101)
... 14 more
The problem is java.io.FileNotFoundException: jndi:/localhost/WEB-INF/beans.xml
I just bumped into something similar today. Either the file can't be found, or you are trying to include it from your web.xml with an ENTITY declaration. If you are trying to load beans.xml with an ENTITY declaration, then the problem is caused by a new security policy in Tomcat 7.0.59 -- blocking the loading of external entities is now the default. Context parameter xmlBlockExternal is now set to "true" by default.
You have to override this in a your context: either the main context in ~Tomcat/conf/context.xml or in your application-level context file. To override, add the param like this:
<Context xmlBlockExternal="false">
I wrote a Spring application which runs on Weblogic 10.3. In this application I have some JMS Queue consumers.
Sometimes I got an error when the application is closing or opening (I saw this error in both situation) saying:
java.lang.NoClassDefFoundError: org/springframework/jms/connection/SmartConnectionFactory
at org.springframework.jms.connection.ConnectionFactoryUtils.releaseConnection(ConnectionFactoryUtils.java:72)
at org.springframework.jms.listener.AbstractJmsListeningContainer.refreshSharedConnection(AbstractJmsListeningContainer.java:385)at org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful(DefaultMessageListenerContainer.java:779)
at org.springframework.jms.listener.DefaultMessageListenerContainer.recoverAfterListenerSetupFailure(DefaultMessageListenerContainer.java:761)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:892)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: org.springframework.jms.connection.SmartConnectionFactory
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:176)
at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:35)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
... 6 more
Why do I get this error and what should I do to solve it?
The version of the spring.jar is 2.5.5
That Exception means that the class is not getting loaded into the JVM. Make sure that the spring.jar is in the Weblogic server's classpath or library folder.
It's all very well that you have this class in your war, but in Weblogic, the war has its own classloader. Since your stack trace shows a JMS listener, I'd ask: where is the listener? If it's in the war, then you have a mystery. But it sure looks as though it's somewhere else, and it's that somewhere else that would be missing this Spring class.