I am working through this deployment one step at a time. Did get some answers from people that have helped but I am now stuck on this error:
JBAS014775: New missing/unsatisfied dependencies:
service jboss.naming.context.java.jboss.datasources.DoDSRDS (missing) dependents: [service jboss.persistenceunit."dodsr.ear/dodsr.jar#DoDSRMGR"]
My persistence.xml file is this:
<?xml version="1.0" encoding="windows-1252" ?>
<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_1_0.xsd"
version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="DoDSRMGR">
<jta-data-source>java:jboss/datasources/DoDSRDS</jta-data-source>
<class>mil.army.amedd.dodsr.model.ManifestsPass1</class>
<class>mil.army.amedd.dodsr.model.ManifestsPass2</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="javax.persistence.jtaDataSource" value="java:/DoDSRDS"/>
</properties>
</persistence-unit>
And the datasource in standalone.xml is this:
<datasource jndi-name="java:jboss/datasources/DoDSRDS" pool-name=" DoDSRDS " enabled="true" use-java-context="true">
<connection-url>jdbc:oracle:thin:#160.151.120.38:2115:apdb</connection-url>
<driver>oracle</driver>
<pool>
<prefill>true</prefill>
<use-strict-min>false</use-strict-min>
</pool>
<security>
<user-name>username</user-name>
<password>password</password>
</security>
How do I get this thing to deploy??
There might be 2 potential problems:
The name of the datasource in standalone.xml might be wrong or missing.
You might need to change
<jta-data-source>java:jboss/datasources/DoDSRDS</jta-data-source>
in persistence.xml to
<jta-data-source>java:/DoDSRDS</jta-data-source>.
I'd your main problem is number 2 but number 1 might still be true (you didn't provide the name definition in your post).
Update:
If you don't need to use the name jboss/datasources/DoDSRDS I'd suggest just using DoDSRS, i.e. jndi-name="java:/DoDSRDS" and <jta-data-source>java:/DoDSRDS</jta-data-source>.
Update 2:
A third problem might be the spaces in the pool-name. I'm not sure they're allowed here but at least it might cause problems if you reference the pool by name and don't have the exact same number of spaces, so I'd remove those in any case.
Related
good evening.
I'm trying to create a project that uses:
Java
JSF 2.3
Maven
CDI 2.0
Hibernate
Wildfly server
My intention here is to learn the basics of all these fellas.
At first I followed an awesome [tutorial by #BalusC][1] that tought me how to set up and first run the webapp.
My problem now rests on integrating the database with the application. I followed some guides and searched a bit on internet and found that a way to do it is by editing web.xml and persistence.xml. (I tried to keep it as close to hist tutorial as possible).
Here are my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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/web-app_4_0.xsd"
version="4.0" metadata-complete="true">
<display-name>project</display-name>
... (some params)
<data-source>
<name>java:global/projectDS</name>
<class-name>org.postgresql.ds.PGConnectionPoolDataSource</class-name>
<url>jdbc:postgresql://localhost:5432/project</url>
</data-source>
... (servlet info)
</web-app>
And my persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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_2.xsd"
version="2.2">
<persistence-unit name="projectPU"
transaction-type="JTA">
<jta-data-source>java:global/projectDS</jta-data-source>
<class>project.entity.Message</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.PostgreSQL95Dialect" />
<property name="hibernate.default_schema" value="main" />
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="javax.persistence.jdbc.driver"
value="org.postgresql.Driver" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
</properties>
</persistence-unit>
</persistence>
When I run the web app I receive the following error:
Caused by: org.jboss.as.controller.OperationFailedException: WFLYJCA0117: org.postgresql.ds.PGConnectionPoolDataSource is not a valid javax.sql.DataSource implementation [ "WFLYJCA0117: org.postgresql.ds.PGConnectionPoolDataSource is not a valid javax.sql.DataSource implementation" ]
I'd like to know if any of you know what I'm doing wrong and how can I work it out.
P.S.: I read on WildFly's page that WildFly has it's own Hibernate "version", and some foruns said that there might be some issues while working with an "external" hibernate source. However, as my Hibernate configuration has nothing linked to any of Wildfly's config (i believe so), I guess that's not the problem.
Thanks in advance.
UPDATE #1
I tried solution #2 from link #TacheDeChoco sent. At first it worker, but I got another error that I'm still trying to solve. I'll try I little bit more and will come here If a more complete feedback.
Ansewring your questions: by the time I first asked, I hadn't done any of the things you asked.
TY very much.
Did you
register a new postgres module (with the appropriate jar) in Wildfly ?
Declare the datasource, along with the used driver, in wildfly config file (standalone-***.xml) ?
Nice explanations can be found here (see option#2):
https://www.stenusys.com/how_to_setup_postgresql_datasource_with_wildfly/
I'm struggling for a few days about this error.
When I try to deploy from ide(IntelliJ-eclipse), it works correct.
But when I try to deploy from WebLogic console, I got these errors;
Error Unable to access the selected application.
Error Unable to invoke Annotation processoror.
Error Unable to invoke Annotation processoror.
For more information, I checked logs and errors from stack trace.
It looks like the main error is: javax.persistence.PersistenceException: No Persistence provider for EntityManager named.
In debug, throwing from this code; Persistence.createEntityManagerFactory("persistanceUnitName");
Persistence classes are coming from javaee-web-abi-7.0.jar.
Everything looks fine in persistence.xml.
<?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="persistanceUnitName"
transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>dataSource</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.target-database" value="Oracle" />
<property name="eclipselink.logging.parameters" value="true" />
<property name="eclipselink.logging.logger" value="DefaultLogger" />
<property name="eclipselink.logging.level" value="WARNING" />
<property name="eclipselink.refresh" value="true" />
<property name="eclipselink.query-results-cache" value="false" />
<!-- <property name="eclipselink.ddl-generation" value="create-or-extend-tables" />-->
</properties>
</persistence-unit>
</persistence>
persistance.xml located in /WEB-INF/classes/META-INF
We got a case like that: we have a test and prep environment. In test, it works, in prep doesn't work, in local doesn't work (from WebLogic console). Unfortunately, I can't see test server configs. But I expect the same options with prep. Anyway forget other environments, firstly I need to deploy successful from local.
Could you pls help me, I really don't know what I miss. Read every topic, tried everything
It looks like a classpath issue. Check your weblogic classpath.
If you are using eclipselink library must be loaded first when you are deploying.
Check this.
Add eclipselink into your project with scope provided:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.0</version>
<scope>provided<scope>
</dependency>
add same dependency into your weblogic classpath:
$WEBLOGIC_HOME/user_projects/domains/base_domain/lib
Then, add below to your weblogic.xml to use eclipselink library.
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>org.eclipse.persistence.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
I'm new to Jboss and I don't understand where should I define the database connection data like url, username, password etc..
Here is my multimodule project:
app-root
app-api
- src
- pom.xml
app-ear
- src
- pom.xml
app-ejb
- src
- pom.xml
pom.xml
My persinstence.xml located unter app-root/app-ejb/src/main/config/default/META-INF/persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
<persistence-unit name="ejb3_jpa_myapp_pu" transaction-type="JTA">
<description>Jboss Test application</description>
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jdbc/MyApp</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="none" />
<property name="hibernate.show_sql" value="true" />
</properties>
</persistence-unit>
</persistence>
And finaly my simple Service:
#Stateless
#Remote(IService.class)
public class ServiceImpl implements IService{
#PersistenceContext(unitName = "ejb3_jpa_myapp_pu")
private EntityManager em;
#Override
public void doSomeJob() {
// [...]
}
}
I know I have to define the database connection properties but where can I do that?
You need to define the data source in the standalone XML file that your JBoss instance is using. JBoss does not ship with database drivers so there are two steps:
1) Create a JBoss module for the database drivers (eg MySQL, Oracle, Postgres etc)
2) Create the datasource definition
Step 1) needs only to be done once, ie many MySQL datasources can use the same MySQL JBoss module.
Step 2) An example datasource configuration for MySQL would be:
<datasources>
<datasource jndi-name="java:jboss/datasources/MySqlDS" pool-name="MySqlDS">
<connection-url>jdbc:mysql://localhost:3306/EJB3</connection-url>
<driver>com.mysql</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>test</user-name>
<password>test</password>
</security>
<statement>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<share-prepared-statements/>
</statement>
</datasource>
<drivers>
<driver name="com.mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
The above can be automated using the JBoss CLI. Also creating the JBoss modules can also be automated for example using the smartics-jboss-modules-maven-plugin see Generate an xml file with all dependencies with maven for more info.
I am using JBoss Developer Studio. I have a project with a persistence.xml file. The file is perfect to me, but I keep getting this error on the tab that lists all the Problems of my project.
Class "[Ljava.lang.String;#22ec7158" cannot be resolved
I include the picture for a better context.
When I click on the error, so that it takes me to the place where the error is happening, it takes me to the end of the file.
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="Persistence">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/MemberOfferDS</jta-data-source>
<class>com.bbb.memberoffer.model.SycsCoordinator</class>
<class>com.bbb.aicweb.memberoffer.model.SycsCoordinatorPhoneNumber</class>
<class>com.bbb.memberoffer.model.SycsCoordinatorClub</class>
<class>com.bbb.memberoffer.model.SycsCoordinatorSecurityGroup</class>
<class>com.bbb.memberoffer.model.SycsCoordinatorClubPk</class>
<class>com.bbb.memberoffer.model.PhoneNumberType</class>
<class>com.bbb.memberoffer.model.Club</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<!-- Not sure if this is the right one to use or not? -->
<property name='hibernate.show_sql' value='true' />
<property name='hibernate.format_sql' value='true' />
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
</properties>
</persistence-unit>
</persistence>
You may have solved this already, however, in my case the problem was caused by referencing a class in a element that no longer existed.
EDIT: The exact reason for this type of error message is that the error generator is trying to run a toString() on a String array when it generates the error message.
I am trying to set up a persistence unit in JEE 6 on JBoss AS 6.
The injected EntityManager is always null. I've fiddled around with the configuration quite a bit but can't get anything to work. I've tried JTA/LOCAL_RESOURCE, I've tried using a unit name in my code the same as in my persistence.xml, but also with the war name prepended, as the log suggests the JNDI name might be that.
I have a mysql-ds.xml file as follows:
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>myconnection</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/cog1</connection-url>
<driver-class>org.gjt.mm.mysql.Driver</driver-class>
<user-name>bw</user-name>
<password></password>
<min-pool-size>2</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>5</idle-timeout-minutes>
<exception-sorter-class-name>com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter</exception-sorter-class-name>
<valid-connection-checker-class-name>com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker</valid-connection-checker-class-name>
</local-tx-datasource>
</datasources>
I have a persistence.xml as follows:
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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"
version="2.0">
<persistence-unit name="myunit" transaction-type="RESOURCE_LOCAL">
<jta-data-source>java:/myconnection</jta-data-source>
<non-jta-data-source>java:/myconnection</non-jta-data-source>
<class>com.cognitura.simulation.dao.model.History</class>
<properties>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
<property name="eclipselink.logging.level" value="INFO" />
</properties>
</persistence-unit>
</persistence>
And I have a bean with the following code in it:
#Stateful
#LocalBean
public class HistoryEJB {
#PersistenceContext(unitName = "myunit")
private EntityManager em;
#EJB
private RealityElement el;
I can see that the RealityElement el is getting injected fine, so I think it's definitely being container-managed?
Grateful for any ideas!
EDIT: The logs seem to be fine for setting up the 'myunit' unit. There is a warning, but I read that it's not important?
01:28:06,276 INFO [org.jboss.jpa.deployment.PersistenceUnitDeployment] Starting persistence unit persistence.unit:unitN
ame=cog1.war#myunit
01:28:06,278 INFO [org.hibernate.ejb.Ejb3Configuration] Processing PersistenceUnitInfo [
name: myunit
...]
01:28:06,305 WARN [org.hibernate.ejb.Ejb3Configuration] Persistence provider caller does not implement the EJB3 spec co
rrectly.PersistenceUnitInfo.getNewTempClassLoader() is null.
Seems happy here:
01:28:06,965 INFO [org.hibernate.impl.SessionFactoryObjectFactory] Bound factory to JNDI name: persistence.unit:unitNam
e=cog1.war#myunit
Could it be the jndi name? Try making the following changes in datasource and persistence files
<jndi-name>java:jboss/datasources/employeedb</jndi-name>
<jta-data-source>java:jboss/datasources/employeedb</jta-data-source>