You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@deltaspike.apache.org by rn...@gmail.com on 2016/09/17 11:38:21 UTC

EAR using Deltaspike

Hi everyone,

I just starting to try using deltaspike.
To begin I create a EAR Project using the tutorial (https://vaadin.com/wiki/-/wiki/Main/Implementing+Enterprise+Web+applications+with+Vaadin), and deploying on a Wildfly 10.1 .
This is made of three components:
• Common – where I keep my entities
• Backend – used for the EJB and where I try to use the Deltaspike
• UI – using Vaadin (I think that this is irrelevant for my problem)

On the “Backend”, I add this to my pom.xml:
	…
		<dependency>
				<groupId>org.apache.deltaspike.distribution</groupId>
				<artifactId>distributions-bom</artifactId>
				<version>1.7.1</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	…
		<dependency>
			<groupId>org.apache.deltaspike.core</groupId>
			<artifactId>deltaspike-core-api</artifactId>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.deltaspike.core</groupId>
			<artifactId>deltaspike-core-impl</artifactId>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.deltaspike.modules</groupId>
			<artifactId>deltaspike-data-module-api</artifactId>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.deltaspike.modules</groupId>
			<artifactId>deltaspike-data-module-impl</artifactId>
			<scope>runtime</scope>
		</dependency>

And exposed the entity manager:
	public class CdiConfig {
	@Produces
	@Dependent
	@PersistenceContext(unitName = "proto2")
	public EntityManager entityManager;
	}

Next, I created a simple entity:
@Entity
@Table(name = "customers")
public class Customer {
	private String contactPerson;
	private String email; 
	<< Setters and Getters add>>
	…

And an generic repository to host common methods:
public interface GenericRepository<T> extends EntityRepository<T, Long> {
	public T findById(Long id);
}

Last, I created a specific eepository for the customer entity:
@RequestScoped
@Repository(forEntity = Customer.class)
public interface CustomerRepository extends GenericRepository<Customer> {
	public QueryResult<Customer> findByNameLikeIgnoreCase(String filter);
}

The problem is that when I deploy the .ear file, I get this errors:
12:15:30,686 WARN  [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.rna.vaadin.proto2.ejb.dao.GenericRepository in Module "deployment.proto2.ear.backend.jar:main" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link org/rna/vaadin/proto2/ejb/dao/GenericRepository (Module "deployment.proto2.ear.backend.jar:main" from Service Module Loader): org/apache/deltaspike/data/api/EntityRepository
	at sun.reflect.GeneratedConstructorAccessor39.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
…
And,
12:15:30,686 WARN  [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.rna.vaadin.proto2.ejb.dao.CustomerRepository in Module "deployment.proto2.ear.backend.jar:main" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link org/rna/vaadin/proto2/ejb/dao/CustomerRepository (Module "deployment.proto2.ear.backend.jar:main" from Service Module Loader): Failed to link org/rna/vaadin/proto2/ejb/dao/GenericRepository (Module "deployment.proto2.ear.backend.jar:main" from Service Module Loader): org/apache/deltaspike/data/api/EntityRepository
	at sun.reflect.GeneratedConstructorAccessor39.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
	at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
…

For simplicity, I didn’t write here the remaining JPA or project settings.

What am I doing wrong? Or did I missed something?

Thank you in advance

Ricardo

RE: EAR using Deltaspike

Posted by rn...@gmail.com.
That is it. As soon as I added them, it worked.

The intent to play with EAR is to have a clear separation between business logic , domain objects and UI.
But I will also play with the WAR packaging. Thank you for the advise.


De: John D. Ament

Re: EAR using Deltaspike

Posted by "John D. Ament" <jo...@apache.org>.
Ok, I see you're packaging JARs.  Is DeltaSpike packaged in your lib folder?

And I have to ask - do you need to use EAR packaging?  Your whole
deployment structure is going to be orders of magnitude less complex by
packaging a WAR file, with your dependent JARs in it.

John

On Sat, Sep 17, 2016 at 7:38 AM <rn...@gmail.com> wrote:

> Hi everyone,
>
> I just starting to try using deltaspike.
> To begin I create a EAR Project using the tutorial (
> https://vaadin.com/wiki/-/wiki/Main/Implementing+Enterprise+Web+applications+with+Vaadin),
> and deploying on a Wildfly 10.1 .
> This is made of three components:
> • Common – where I keep my entities
> • Backend – used for the EJB and where I try to use the Deltaspike
> • UI – using Vaadin (I think that this is irrelevant for my problem)
>
> On the “Backend”, I add this to my pom.xml:
>         …
>                 <dependency>
>
> <groupId>org.apache.deltaspike.distribution</groupId>
>                                 <artifactId>distributions-bom</artifactId>
>                                 <version>1.7.1</version>
>                                 <type>pom</type>
>                                 <scope>import</scope>
>                         </dependency>
>                 </dependencies>
>         …
>                 <dependency>
>                         <groupId>org.apache.deltaspike.core</groupId>
>                         <artifactId>deltaspike-core-api</artifactId>
>                         <scope>compile</scope>
>                 </dependency>
>                 <dependency>
>                         <groupId>org.apache.deltaspike.core</groupId>
>                         <artifactId>deltaspike-core-impl</artifactId>
>                         <scope>runtime</scope>
>                 </dependency>
>                 <dependency>
>                         <groupId>org.apache.deltaspike.modules</groupId>
>                         <artifactId>deltaspike-data-module-api</artifactId>
>                         <scope>compile</scope>
>                 </dependency>
>                 <dependency>
>                         <groupId>org.apache.deltaspike.modules</groupId>
>
> <artifactId>deltaspike-data-module-impl</artifactId>
>                         <scope>runtime</scope>
>                 </dependency>
>
> And exposed the entity manager:
>         public class CdiConfig {
>         @Produces
>         @Dependent
>         @PersistenceContext(unitName = "proto2")
>         public EntityManager entityManager;
>         }
>
> Next, I created a simple entity:
> @Entity
> @Table(name = "customers")
> public class Customer {
>         private String contactPerson;
>         private String email;
>         << Setters and Getters add>>
>         …
>
> And an generic repository to host common methods:
> public interface GenericRepository<T> extends EntityRepository<T, Long> {
>         public T findById(Long id);
> }
>
> Last, I created a specific eepository for the customer entity:
> @RequestScoped
> @Repository(forEntity = Customer.class)
> public interface CustomerRepository extends GenericRepository<Customer> {
>         public QueryResult<Customer> findByNameLikeIgnoreCase(String
> filter);
> }
>
> The problem is that when I deploy the .ear file, I get this errors:
> 12:15:30,686 WARN  [org.jboss.modules] (MSC service thread 1-3) Failed to
> define class org.rna.vaadin.proto2.ejb.dao.GenericRepository in Module
> "deployment.proto2.ear.backend.jar:main" from Service Module Loader:
> java.lang.NoClassDefFoundError: Failed to link
> org/rna/vaadin/proto2/ejb/dao/GenericRepository (Module
> "deployment.proto2.ear.backend.jar:main" from Service Module Loader):
> org/apache/deltaspike/data/api/EntityRepository
>         at sun.reflect.GeneratedConstructorAccessor39.newInstance(Unknown
> Source)
>         at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>         at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
> …
> And,
> 12:15:30,686 WARN  [org.jboss.modules] (MSC service thread 1-3) Failed to
> define class org.rna.vaadin.proto2.ejb.dao.CustomerRepository in Module
> "deployment.proto2.ear.backend.jar:main" from Service Module Loader:
> java.lang.NoClassDefFoundError: Failed to link
> org/rna/vaadin/proto2/ejb/dao/CustomerRepository (Module
> "deployment.proto2.ear.backend.jar:main" from Service Module Loader):
> Failed to link org/rna/vaadin/proto2/ejb/dao/GenericRepository (Module
> "deployment.proto2.ear.backend.jar:main" from Service Module Loader):
> org/apache/deltaspike/data/api/EntityRepository
>         at sun.reflect.GeneratedConstructorAccessor39.newInstance(Unknown
> Source)
>         at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>         at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
>         at
> org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
>         at
> org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
> …
>
> For simplicity, I didn’t write here the remaining JPA or project settings.
>
> What am I doing wrong? Or did I missed something?
>
> Thank you in advance
>
> Ricardo
>

RE: EAR using Deltaspike

Posted by rn...@gmail.com.
I sure didn’t. 😊
Vaadin CDI is in place.

Maybe an article updated is needed, or a “Part 2”.

I added exclusions in the UI pom.xml. And work perfectly.

Thank you for your help,
Ricardo


De: Matti Tahvonen

Re: EAR using Deltaspike

Posted by Matti Tahvonen <ma...@vaadin.com>.
I hope you are not literally following those instructions as they are rather dated. As John said you are probably better of with plain war packaging these days. If you are using  Vaadin CDI ( and you should, even though the old wiki instructions don't mention), I'd check there are no version collisions with Deltaspike. Vaadin CDI depends on an older version, but you can most probably exclude its dependencies and use a newer version.

I hope this helps,
Matti

> On 17 Sep 2016, at 4.38, <rn...@gmail.com> <rn...@gmail.com> wrote:
> 
> Hi everyone,
> 
> I just starting to try using deltaspike.
> To begin I create a EAR Project using the tutorial (https://vaadin.com/wiki/-/wiki/Main/Implementing+Enterprise+Web+applications+with+Vaadin), and deploying on a Wildfly 10.1 .
> This is made of three components:
> • Common – where I keep my entities
> • Backend – used for the EJB and where I try to use the Deltaspike
> • UI – using Vaadin (I think that this is irrelevant for my problem)
> 
> On the “Backend”, I add this to my pom.xml:
>    …
>        <dependency>
>                <groupId>org.apache.deltaspike.distribution</groupId>
>                <artifactId>distributions-bom</artifactId>
>                <version>1.7.1</version>
>                <type>pom</type>
>                <scope>import</scope>
>            </dependency>
>        </dependencies>
>    …
>        <dependency>
>            <groupId>org.apache.deltaspike.core</groupId>
>            <artifactId>deltaspike-core-api</artifactId>
>            <scope>compile</scope>
>        </dependency>
>        <dependency>
>            <groupId>org.apache.deltaspike.core</groupId>
>            <artifactId>deltaspike-core-impl</artifactId>
>            <scope>runtime</scope>
>        </dependency>
>        <dependency>
>            <groupId>org.apache.deltaspike.modules</groupId>
>            <artifactId>deltaspike-data-module-api</artifactId>
>            <scope>compile</scope>
>        </dependency>
>        <dependency>
>            <groupId>org.apache.deltaspike.modules</groupId>
>            <artifactId>deltaspike-data-module-impl</artifactId>
>            <scope>runtime</scope>
>        </dependency>
> 
> And exposed the entity manager:
>    public class CdiConfig {
>    @Produces
>    @Dependent
>    @PersistenceContext(unitName = "proto2")
>    public EntityManager entityManager;
>    }
> 
> Next, I created a simple entity:
> @Entity
> @Table(name = "customers")
> public class Customer {
>    private String contactPerson;
>    private String email; 
>    << Setters and Getters add>>
>    …
> 
> And an generic repository to host common methods:
> public interface GenericRepository<T> extends EntityRepository<T, Long> {
>    public T findById(Long id);
> }
> 
> Last, I created a specific eepository for the customer entity:
> @RequestScoped
> @Repository(forEntity = Customer.class)
> public interface CustomerRepository extends GenericRepository<Customer> {
>    public QueryResult<Customer> findByNameLikeIgnoreCase(String filter);
> }
> 
> The problem is that when I deploy the .ear file, I get this errors:
> 12:15:30,686 WARN  [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.rna.vaadin.proto2.ejb.dao.GenericRepository in Module "deployment.proto2.ear.backend.jar:main" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link org/rna/vaadin/proto2/ejb/dao/GenericRepository (Module "deployment.proto2.ear.backend.jar:main" from Service Module Loader): org/apache/deltaspike/data/api/EntityRepository
>    at sun.reflect.GeneratedConstructorAccessor39.newInstance(Unknown Source)
>    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
> …
> And,
> 12:15:30,686 WARN  [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.rna.vaadin.proto2.ejb.dao.CustomerRepository in Module "deployment.proto2.ear.backend.jar:main" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link org/rna/vaadin/proto2/ejb/dao/CustomerRepository (Module "deployment.proto2.ear.backend.jar:main" from Service Module Loader): Failed to link org/rna/vaadin/proto2/ejb/dao/GenericRepository (Module "deployment.proto2.ear.backend.jar:main" from Service Module Loader): org/apache/deltaspike/data/api/EntityRepository
>    at sun.reflect.GeneratedConstructorAccessor39.newInstance(Unknown Source)
>    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
>    at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
>    at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
> …
> 
> For simplicity, I didn’t write here the remaining JPA or project settings.
> 
> What am I doing wrong? Or did I missed something?
> 
> Thank you in advance
> 
> Ricardo