I Have a Stateless Local Bean like that:
#Stateless(name="GerencialFacadeBean", mappedName="GerencialFacade")
public class GerencialFacadeBean implements GerencialFacadeBeanLocal {
#Resource(name="jdbc/adq_sistint", mappedName = "jdbc/adq_sistint")
private DataSource dataSource;
.. }
So, when I take use of this bean I got the follow exception:
Caused by: com.bea.core.repackaged.springframework.beans.factory.BeanCreationException: Dependency injection failure: can't find the bean definition about class interface javax.sql.DataSource; nested exception is com.bea.core.repackaged.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.sql.DataSource] is defined: No beans of type javax.sql.DataSource; owner=com.bea.core.repackaged.springframework.context.support.GenericApplicationContext#5d225fc1: display name [com.bea.core.repackaged.springframework.context.support.GenericApplicationContext#5d225fc1]; startup date [Mon Oct 15 16:30:12 BRT 2012]; parent: com.bea.core.repackaged.springframework.context.support.GenericApplicationContext#885e019
at com.oracle.pitchfork.inject.Jsr250Metadata.applyInjections(Jsr250Metadata.java:241)
at com.oracle.pitchfork.inject.Jsr250Metadata.inject(Jsr250Metadata.java:223)
at com.oracle.pitchfork.inject.Jsr250Metadata.injectAndPostConstruct(Jsr250Metadata.java:253)
at com.oracle.pitchfork.inject.Jsr250MetadataBeanPostProcessor.postProcessAfterInstantiation(Jsr250MetadataBeanPostProcessor.java:40)
at com.bea.core.repackaged.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:957)
at com.bea.core.repackaged.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
... 66 more
Caused by: com.bea.core.repackaged.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.sql.DataSource] is defined: No beans of type javax.sql.DataSource; owner=com.bea.core.repackaged.springframework.context.support.GenericApplicationContext#5d225fc1: display name [com.bea.core.repackaged.springframework.context.support.GenericApplicationContext#5d225fc1]; startup date [Mon Oct 15 16:30:12 BRT 2012]; parent: com.bea.core.repackaged.springframework.context.support.GenericApplicationContext#885e019
at com.oracle.pitchfork.inject.Jsr250Metadata.getUniqueInstanceOfType(Jsr250Metadata.java:304)
at com.oracle.pitchfork.inject.Jsr250Metadata.resolveByType(Jsr250Metadata.java:298)
at com.oracle.pitchfork.inject.Jsr250Metadata.resolve(Jsr250Metadata.java:285)
at com.oracle.pitchfork.inject.Jsr250Metadata.applyInjections(Jsr250Metadata.java:235)
Important:
I use this EJB from a Webservice (in the same EAR), like:
.. class MyWebService.. {
#EJB(name="GerencialFacadeBean", mappedName="GerencialFacade")
private GerencialFacadeBeanLocal gerencialBean;
}
and, if I try got the datasource on the Webservice´s class it work sucessfully.
EDIT:
Another consideration: using REMOTE interface it works. But I want to use it with Local interface.
I'm using Weblogic 10.3.5. My Datasource is created and works fine in other applications (that get it directly by JNDI), So, what I´m getting this error?
Related
I am developing a web application using DataNucleus as DAO layer (mainly due to historical reasons). It runs inside Payara server (a Glassfish 4 fork)
It works fine, but now I'd like to use a JNDI db connection pool to obtain the PersistenceManagerFactory for DataNucleus.
From the documentation, it seems that the following code would suffice:
pmf = JDOHelper.getPersistenceManagerFactory( "jdbc/HxWmDb", context );
but this way I obtain an error starting the application (DbSession is the class which implements the DAO layer, and the error line is exactly the one above):
Caused by: java.lang.ClassCastException
at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:262)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:150)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:1791)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:1755)
at ejb.DbSession.<init>(DbSession.java:119)
...
Caused by: java.lang.ClassCastException: com.sun.gjc.spi.jdbc40.DataSource40 cannot be cast to org.omg.CORBA.Object
at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:245)
Any suggestion?
Little update, as requested by DN1:
As a first approach, I tried exactly what is described in the link:
Properties properties = new Properties();
properties.setProperty("datanucleus.ConnectionFactoryName","jdbc/HxWmDb");
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(properties);
And the error is, as already said, that a URI is anyway required:
Caused by: org.datanucleus.exceptions.NucleusException: You haven't specified persistence property 'datanucleus.ConnectionURL'
I have a 3 node Apache Ignite Cluster, I have created a cache with Integer as Key and a 'Subscriber' POJO as value, when I connect to the cluster from inside a JAVA program and access the cache , I get the above mentioned exception, I have 'peerclassloading' property set to false, and I have deployed 'Subscriber' POJO Binaries in all the nodes, Please find the complete stack trace below. What am I missing here? Why is it looking for some file inside my IGNITE_HOME when I am starting client inside my JAVA program with Ignition.start()?
class org.apache.ignite.IgniteCheckedException: Failed to read class name from file [id=-1219769240, file=/home/benakaraj/Downloads/apache-ignite-fabric-1.5.0.final-bin/work/marshaller/-1219769240.classname]
at org.apache.ignite.internal.MarshallerContextImpl.className(MarshallerContextImpl.java:158)
at org.apache.ignite.internal.MarshallerContextAdapter.getClass(MarshallerContextAdapter.java:174)
at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:483)
at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1443)
at org.apache.ignite.internal.binary.BinaryObjectImpl.deserializeValue(BinaryObjectImpl.java:537)
at org.apache.ignite.internal.binary.BinaryObjectImpl.value(BinaryObjectImpl.java:117)
at org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinary(CacheObjectContext.java:280)
at org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinaryIfNeeded(CacheObjectContext.java:145)
at org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinaryIfNeeded(CacheObjectContext.java:132)
at org.apache.ignite.internal.processors.cache.GridCacheContext.unwrapBinaryIfNeeded(GridCacheContext.java:1748)
at org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture.setResult(GridPartitionedSingleGetFuture.java:598)
at org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture.onResult(GridPartitionedSingleGetFuture.java:454)
at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter.processNearSingleGetResponse(GridDhtCacheAdapter.java:153)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.access$1200(GridDhtAtomicCache.java:128)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$11.apply(GridDhtAtomicCache.java:295)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$11.apply(GridDhtAtomicCache.java:293)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager.processMessage(GridCacheIoManager.java:582)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager.onMessage0(GridCacheIoManager.java:280)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager.handleMessage(GridCacheIoManager.java:204)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager.access$000(GridCacheIoManager.java:80)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager$1.onMessage(GridCacheIoManager.java:163)
at org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:821)
at org.apache.ignite.internal.managers.communication.GridIoManager.access$1600(GridIoManager.java:103)
at org.apache.ignite.internal.managers.communication.GridIoManager$5.run(GridIoManager.java:784)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.FileNotFoundException: /home/benakaraj/Downloads/apache-ignite-fabric-1.5.0.final-bin/work/marshaller/-1219769240.classname (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileReader.<init>(FileReader.java:72)
at org.apache.ignite.internal.MarshallerContextImpl.className(MarshallerContextImpl.java:154)
... 26 more
Looks like the cache tries to deserialize the value after retrieving it from cache, but you don't have a class for it on the node where IgniteCache.get() was called. You can either deploy the class, or use IgniteCache.withKeepBinary() to avoid deserialization: https://apacheignite.readme.io/docs/binary-marshaller#binaryobject-cache-api
The issue turned out to be pretty simple, Ignite looks for the user defined POJOs from the list of classes loaded by default class loader, if it does not find it there , it looks inside marshalled classes, In my case, my value POJO was inside the test resources , hence default class loader was not loading the class, causing ignite to look inside marshalled classes folder(IGNITE_HOME/work/marshaller/) .
I am facing a class cast exception while doing lookup for datasource .we have recently migrated to weblogic 12c from weblogic 11. Below is the code via which I am looking up for Datasource .
ds = (javax.sql.DataSource) ctx.lookup("my_data_source_name");
this code is giving class cast exception
Caused by: java.lang.ClassCastException: weblogic.jndi.internal.WLEventContextImpl cannot be cast to javax.sql.DataSource
we have weblogic.jar in our class path .. i am not sure why it is returning the object of type WLEventContextImpl instead of Datasource . Can someone suggest something?
I had this problem and in my case I created a datasource without associate with a target, in the last page of datasource configuration you can see:
Select Targets:
Servers
[ ] AdminServer
After I check the AdminServer checkbox, I could use the datasource.
I have packaged my app with :
mvn -Pprod package
Then I ran
java -jar myapp-0.0.1-SNAPSHOT.war
it works fine.
But if I run :
java -jar myapp-0.0.1-SNAPSHOT.war --spring.profiles.active=prod
I am getting this error:
[ERROR] org.springframework.boot.context.embedded.tomcat.ServletContextInitializerLifecycleListener - Error starting Tomcat context: org.springframework.beans.factory.BeanCreationException
[WARN] org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:124) [spring-boot-1.2.0.RELEASE.jar!/:1.2.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474) ~[spring-context-4.1.3.RELEASE.jar!/:4.1.3.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109) [spring-boot-1.2.0.RELEASE.jar!/:1.2.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691) [spring-boot-1.2.0.RELEASE.jar!/:1.2.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) [spring-boot-1.2.0.RELEASE.jar!/:1.2.0.RELEASE]
at com.myapp.Application.main(Application.java:57) [classes!/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_25]
at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_25]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53) [bioandbio-0.0.1-SNAPSHOT.war:na]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25]
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:97) ~[spring-boot-1.2.0.RELEASE.jar!/:1.2.0.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:74) ~[spring-boot-1.2.0.RELEASE.jar!/:1.2.0.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:374) ~[spring-boot-1.2.0.RELEASE.jar!/:1.2.0.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:150) ~[spring-boot-1.2.0.RELEASE.jar!/:1.2.0.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:148) [spring-boot-1.2.0.RELEASE.jar!/:1.2.0.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:121) [spring-boot-1.2.0.RELEASE.jar!/:1.2.0.RELEASE]
... 11 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.setFilterChainProxySecurityConfigurer(org.springframework.security.config.annotation.ObjectPostProcessor,java.util.List) throws java.lang.Exception; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.security.core.userdetails.UserDetailsService com.myapp.config.SecurityConfiguration.userDetailsService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.myapp.repository.UserRepository com.myapp.security.UserDetailsService.userRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Cannot create inner bean '(inner bean)#1f1288f5' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#1f1288f5': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [com/myapp/config/DatabaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.ValidationFailedException: Validation Failed:
1 change sets check sum
classpath:config/liquibase/changelog/00000000000000_initial_schema.xml::00000000000001::jhipster is now: 7:788e6cd59e4764c45e1b83437356e748
I don't understand why prod profile causes this issue.
If someone knows what's wrong here
Thank you.
Reading all the way to the bottom of the stack trace, I see that the root cause is a liquibase checksum validation failure. I'm not sure how familiar you are with liquibase, but it is a tool that is embedded inside jhipster that is used to manage database schema changes as your objects change. What liquibase does is use an XML format to describe the database schema as a series of 'changesets'. When liquibase deploys a changeset (i.e. a changeset that says 'changeset with id "CreateTableFoo" is "create table foo with columns bar baz etc") is that it actually creates the table, and then it also adds a row to a table called 'databasechangelog' that records that the changeset "CreateTableFoo" was successfully applied at such and such a time, and the checksum of that changeset was some value. Now, if you come along and change the changeset xml file so that the changeset "CreateTableFoo" instead creates a table with a different name or different columns, then the checksum calculated for that changeset also changes, so when you try to update the schema liquibase says "Wait! Something wrong!"
So that is what is happening here.
Error creating bean with name 'liquibase' defined in class path resource [com/myapp/config/DatabaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.ValidationFailedException: Validation Failed:
1 change sets check sum
classpath:config/liquibase/changelog/00000000000000_initial_schema.xml::00000000000001::jhipster is now: 7:788e6cd59e4764c45e1b83437356e748
What this indicates is that the prod database already has had a liquibase update run on it to populate the schema, but that the changeset has changed since that initial deploy. I am not familiar with how jhipster uses liquibase, so you would need to look at the file classpath:config/liquibase/changelog/00000000000000_initial_schema.xml to see what database schema it is trying to set up, and compare that to the schema that is actually in place in production.
Now that things are out of sync, you'll have to figure out a way to get them back in sync, which is more complicated than can be answered here and depends greatly on what the differences between the changelog and the production schema are.
I'm blocked on this GORM inheritance problem I have and id appreciate some fresh eyes to have a look over this problem. (Im using Grails 1.3.2)
I have a base abstract class...
abstract class MaintenanceSchedule {
static belongsTo = [ maintenanceTask:MaintenanceTask ]
}
and I want to extend it like so...
class OneOffSchedule extends MaintenanceSchedule {
Date scheduleDate
static constraints = {
scheduleDate(nullable:false)
}
private static OneOffSchedule getReferenceOneOffSchedule() {
return new OneOffSchedule(scheduleDate:new Date())
}
}
when I try and run my application I get the following stack trace.
2010-06-26 12:01:43,090 [main] ERROR context.GrailsContextLoader - Error executing bootstraps: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: An association from the table maintenance_task refers to an unmapped class: preventIT.maintenance.MaintenanceSchedule
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: An association from the table maintenance_task refers to an unmapped class: preventIT.maintenance.MaintenanceSchedule
at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:164)
at grails.web.container.EmbeddableServer$start.call(Unknown Source)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy:159)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:282)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:150)
at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
at _GrailsRun_groovy.runInline(_GrailsRun_groovy:116)
at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59)
at RunApp$_run_closure1.doCall(RunApp.groovy:33)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: An association from the table maintenance_task refers to an unmapped class: preventIT.maintenance.MaintenanceSchedule
... 23 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: An association from the table maintenance_task refers to an unmapped class: preventIT.maintenance.MaintenanceSchedule
... 23 more
Caused by: org.hibernate.MappingException: An association from the table maintenance_task refers to an unmapped class: preventIT.maintenance.MaintenanceSchedule
... 23 more
The problem is arguably a bug in gorm (maybe hibernate, not sure where the root of the bug lies) in that it does not persist abstract classes and breaks polymorphic relationships . Presumably you've got a
static hasMany = [schedules:MaintenanceSchedule]
in your MaintenanceTask class. If your MaintenanceSchedule class is really just like it appears in your post, you can work around the problem by removing the abstract descriptor on the class. If you want to prevent someone from creating a MaintenanceSchedule you can explicitly add a protected no argument constructor.
If you want to have abstract methods in the MaintenanceSchedule then the approach doesn't work so well. But, if you either remove the abstract keyword or the relationship on MaintenanceTask your compiler error should go away.
In Grails version 1.4 this is going to be solved. It's actually solved... but we have to wait to the 1.4 stable version be released.
See http://jira.grails.org/browse/GRAILS-2583