Can't deploy plain Java web project with selected frameworks support to Wildfly application server

Answered

 I am starting graduation thesis Java web project.

I started new Intellij project with following framework(libraries) support:

Web,

JSF and Primefaces

EJB

Hibernate

JPA

I've selected Wildfly server. I haven't made any changes at all. Just plain project that IDE generated. When i enter project structure it reports problems. I click resolve, and when i try to deploy i get bunch of errors.

 https://kopy.io/fbNZr#U6Tu1ZSrfC2GWb

I've attached log on the kopy.io because it is not very readable here.

 

Also i tried creating project in NetBeans, it deploys normally without errors. But i want to use Intellij, since i am using PhpStorm for some time now, and i am very much used to the IDE, so it would be much easier for me to develop using Jetbrains IDE.

Do i need some config files or something that IDE didn't generate? Some file for Wildfly etc? I've setup datasource in Wildfly administration.

I would very much appreciate any help because i am tight with time. Thank you.

0
19 comments

Try excluding dom4j jar from the hibernate library and deployment.

0
Avatar
Permanently deleted user

I've tried. Still won't deploy.

0

Can't reproduce, deploys fine with the following configuration:






0
Avatar
Permanently deleted user

I see i have one library more than you. Look at screenshots. And also one more artifact.

And what about config files etc?

Did Intellij generate something more? Can you tell me what do you have in META-INF?

Here are the screenshots:

0
Avatar
Permanently deleted user

I still get dom4j error:

15:00:24,335 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 23) MSC000001: Failed to start service jboss.persistenceunit."Bookstore_ear_exploded.ear/web.war#NewPersistenceUnit": org.jboss.msc.service.StartException in service jboss.persistenceunit."Bookstore_ear_exploded.ear/web.war#NewPersistenceUnit": java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory

 

This is driving me crazy, and i haven't even started coding. :(

0

Double check dom4j jar is excluded like shown on this screenshot: https://intellij-support.jetbrains.com/hc/user_images/PcryRwYUqXdhuqO1cB8Sdg.png.

See artifact output location to ensure that the jar is not there.

If the issue remains, please provide a sample project illustrating the problem and the exact steps to reproduce.

0
Avatar
Permanently deleted user

OK. I managed to deploy it. Thank you. It was excluded but somehow it was compiled anyway. I deleted it, now it deployed successfully.

One more thing, now that i removed Mojarra library for Primefaces, i get errors for those namespaces in source code. It is undefined, can i get those to be recognized without library? Because i delete it, as per your advice.

0

You can change the scope of the library to Provided or add the version distributed with WildFly as a library and also set the scope to Provided since it's already available in the server installation.

0
Avatar
Permanently deleted user

Yes, that works. Thanks.

So, now one things bugs me, just to know if i come into problems in the future. I deleted the dom4j library from the libraries settings. Exclude from there doesn't work, it gets deployed.

But if it was some other library, such as Mojarra that gives me code errors if delete it. How can i exclude certain library classes from deployment, but still keep them in project libraries and get code assistance for it.

Can i set certain class from library to provided? Something like that. For instance here i need to do for dom4j llb.

Again, thank you very much you have been more than helpfull.

0

You need to split it into 2 different libraries, one will contain dom4j, another all the rest jars. Then one of the libraries can be set to Provided and excluded from the deployment.

0
Avatar
Permanently deleted user

I am sorry, me again. :( I was told to use Eclipselink, because it was presented in colledge course instead of Hibernate. I also read, it is reference JPA implementation, and that i can use native SQL in JPA queries with it.

I tried to start Intellij project with it, but it doesn't deploy. I also tried to download Eclipselink library from the official site since, i saw it isn't downloaded to project libraries. Both with and without eclipselink library project doesn't deploy.

Do you know what is the problem here? Also when i download Eclipselink library from site i only included eclpselink.jar, and it was liste in external libraries? Do i need to add something more? Also i haven't changed anything, everything is stock as IDE generated. Thank you.

0

You also need to add EclipseLink library to the artifact that is deployed, see https://www.jetbrains.com/help/idea/artifacts.html.

0
Avatar
Permanently deleted user

I got error again. java.lang.StackOverflowError.

Is the Eclipselink.jar the only aditional library i need?



0

Yes, eclipselink.jar should contain all you need. Try to analyze the exception you get and google for it, maybe someone has already resolved this problem.

0
Avatar
Permanently deleted user

Should i configure persistence.xml somehow? I haven't changed anything in the files.

 

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">

<persistence-unit name="NewPersistenceUnit">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<properties>
<property name="eclipselink.jdbc.url" value=""/>
<property name="eclipselink.jdbc.driver" value=""/>
<property name="eclipselink.jdbc.user" value=""/>
<property name="eclipselink.jdbc.password" value=""/>
</properties>
</persistence-unit>
</persistence>

Here is the current content. Also doesn't IDE initalise persistence config? I know NeBeans, does that pretty well, but as i said, i am used to Jebrains IDEs.

0
Avatar
Permanently deleted user
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
<persistence-unit name="BookstorePU">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.bookstore.domain.Address</class>
<class>com.bookstore.domain.Administrator</class>
<class>com.bookstore.domain.BookCategory</class>
<class>com.bookstore.domain.Book</class>
<class>com.bookstore.domain.Category</class>
<class>com.bookstore.domain.OrderItem</class>
<class>com.bookstore.domain.OrderE</class>
<class>com.bookstore.domain.User</class>
<properties>
<property name="eclipselink.jdbc.url" value="jdbc:mysql://localhost:3306/bookstore"/>
<property name="eclipselink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="eclipselink.jdbc.user" value="root"/>
<property name="eclipselink.jdbc.password" value="root"/>
</properties>
</persistence-unit>
</persistence>

Here is the persistence.xml. Looks fine to me.

0
Avatar
Permanently deleted user

Hello, i haven't been working on this for some time.

Anyways i think i should configure separate modules, for each part of application. EJB, JPA and Web.

Also can i generate persistence mapping based on Wildfly data source, like Netbeans does.

persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
<persistence-unit name="BookstorePU">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>java:/BookstoreDS</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties/>
</persistence-unit>
</persistence>

I plan on doing like this. I create blank project and add modules. Three of them to be exact.

JPA -> BookstoreJPA

Web -> BookstoreWEB

EJB layer -> BookstoreEJB

How should i configure deployment for these?

0

Please sign in to leave a comment.