I need create a website in weblogic container, but i donĀ“t know how to connected jpa 2.0 to jndi weblogic connection and management with spring.
now i have one project but with errors, in this case my file setup are :
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="unitPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/fact</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
</properties>
</persistence-unit>
</persistence>
and the error is:
weblogic.deployment.EnvironmentException: Error processing persistence unit unitPU of module web: Error instantiating the Persistence Provider class org.eclipse.persistence.jpa.PersistenceProvider of the PersistenceUnit factory-web-copyPU: java.lang.ClassNotFoundException: org.eclipse.persistence.jpa.PersistenceProvider
any sample or any idea to help me to solved this error o create a project jpa + spring + weblogic i will be greatful
You haven't got the class: org.eclipse.persistence.jpa.PersistenceProvider in your classpath. That is what is causing the exception. So add the .jar file containing this class into your classpath or if you are using Maven add this dependency:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>{artifact}</artifactId>
<version>{version}</version>
<scope>compile</scope>
</dependency>
And specify the appropriate artifactId.
See:
EclipseLink/Maven
Related
I am developing j2EE application it is web sotre I use Jboss7 , maven and wildfly my problem is that after every login database content will be deleted .. any suggestion to solve this ?
this is my persistance file
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="PiDevECommerce-ejb">
<jta-data-source>java:jboss/datasources/MySQLDS</jta-data-source>
<class>ecommerce.entites.Admin</class>
<class>ecommerce.entites.Brand</class>
<class>ecommerce.entites.Category</class>
<class>ecommerce.entites.Coupon</class>
<class>ecommerce.entites.Customer</class>
<class>ecommerce.entites.Event</class>
<class>ecommerce.entites.Offre</class>
<class>ecommerce.entites.Product</class>
<class>ecommerce.entites.Publication</class>
<class>ecommerce.entites.ReclamationCoupon</class>
<class>ecommerce.entites.ReclamationOffre</class>
<class>ecommerce.entites.Review</class>
<class>ecommerce.entites.Store</class>
<class>ecommerce.entites.Storemanager</class>
<class>ecommerce.entites.Transaction</class>
<class>ecommerce.entites.TransactionPK</class>
<class>ecommerce.entites.User</class>
<properties>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
</persistence-unit>
</persistence>
The problem is in your configuration
<properties>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
The correct value would be validate
This post answer your question completely
Click here
I'm making a Maven EJB module, and i have troubles when i run tests using JUnit and Embedded GlassFish container.
EJB module consists of JPA entity and EJB stateless session bean.
whole project can be found here
https://github.com/muhamed-hassan/service-layer
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="custmgr-pu" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/customerCM_PU</jta-data-source>
<class>model.Customer</class>
<properties>
<property name="eclipselink.target-database" value="MySQL"/>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.logging.level" value="ALL"/>
</properties>
</persistence-unit>
</persistence>
I'm getting this kind of exception
`java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName custmgr-pu`
Note that i put persistence.xml file under src/main/resources/META-INF directory, because i'm using a maven ejb project.
I have this spring config that I used in my tests:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:solr="http://www.springframework.org/schema/data/solr"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/solr
http://www.springframework.org/schema/data/solr/spring-solr-1.0.xsd">
<solr:embedded-solr-server id="tgySolrServer" solrHome="target/test-classes" />
</beans>
throwing now this exception
Caused by: java.lang.NoSuchMethodError: org.apache.solr.core.CoreContainer.<init>(Ljava/lang/String;Ljava/io/File;)V
at org.springframework.data.solr.server.support.EmbeddedSolrServerFactory.createPathConfiguredSolrServer(EmbeddedSolrServerFactory.java:101)
at org.springframework.data.solr.server.support.EmbeddedSolrServerFactory.initSolrServer(EmbeddedSolrServerFactory.java:77)
at org.springframework.data.solr.server.support.EmbeddedSolrServerFactoryBean.afterPropertiesSet(EmbeddedSolrServerFactoryBean.java:36)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
... 40 more
I currently have Solr 4.5.0 and spring-data-solr 1.0.0-RELEASE. What should I do to use the embedded server in my tests?
I got it working now
we need to add following dependency and repository to pom.xml
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-solr</artifactId>
<version>1.1.0.BUILD-SNAPSHOT</version>
</dependency>
<repositories>
<repository>
<id>spring-maven-snapshot</id>
<url>http://repo.springsource.org/libs-snapshot</url>
</repository>
</repositories>
That's it !!!
I'm trying to setup our REST server for OAuth2 with spring-security. (The server already supports spring-security without OAuth). Now I tried to follow the sparklr example and added the spring-security-oauth artifact to my maven (mvn dependency:tree shows it is available) as well as the namespace configuration to my spring-security-context.xml but all I get is:
Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security/oauth2]
Browsing to http://www.springframework.org/schema/security/ all I see are the .xsd files but no oauth2 folder.. How can that be? I am assuming the sparklr example is a working version, so what am I doing wrong?
Here's my spring-security-context header:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
xmlns:sec="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-1.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
If needed, here's the maven setup:
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth</artifactId>
<version>1.0.0.RC2</version>
</dependency>
You referer to OAuth2 but import the OAuth 1. replace the dependency to
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
You need to ensure that spring-security-oauth2 jar is present in classpath and it will work
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.4.0.RELEASE</version>
</dependency>
I am trying to use ClassPathXmlApplicationContext in my java standalone code to load applicationContext.xml that is inside a jar file which is in my class path.
ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:**/applicationContext*.xml");
applicationContext.xml entry as follows,
<bean id="myAdder" class="com.foo.bar.MyAdder">
<property name="floatAdder" ref="floatAdder"/>
</bean>
And, when I try to load a bean that way I am getting NoSuchBeanException. Can't a bean by loaded in this way?
The jar file is added to my classpath as a maven dependency. When I see the Java Build Path in Eclipse for this project, I see this jar linked as M2_REPO/.../..
I was assuming I can load the bean inside the jar file as the jar is in classpath this way. Am I missing something?
Thanks,Abi
This should work, I just created the 2 projects and checked.
Project A (standard Maven project created with STS) has applicationContext.xml in src/main/resources.
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.D</groupId>
<artifactId>A</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<spring.version>3.0.5.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
</project>
applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="myAdder" class="com.foo.bar.MyAdder">
<property name="foo" value="bar" />
</bean>
</beans>
Project B:
pom.xml: same as A, except A is added as dependency:
<dependency>
<groupId>org.D</groupId>
<artifactId>A</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
Start.java in project B:
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext(
"classpath*:**/applicationContext*.xml");
MyAdder myAdder = (MyAdder) context.getBean("myAdder");
System.out.println(myAdder.getFoo());
}
mvn install A first, then run Start in project B.
Do you really need the classpath*: prefix on that location? (Is that * legal?) I would have expected something more like:
ApplicationContext context = new ClassPathXmlApplicationContext("**/applicationContext*.xml);