I am deploying an ear on wildfly which contains the Extension DeltaspikeContextExtension. In my test directory, I used a Producer for this extension called DeltaspikeProducerDCE. I need this producer for my integration tests, because he cannot inject the original extension.
After building (successfully, including the integration tests) and deploying the ear, I start my Wildfly Server and get the following errors:
org.jboss.weld.exceptions.DeploymentException: WELD-001409: Ambiguous dependencies for type DeltaSpikeContextExtension with qualifiers #Default
..
at org.apache.deltaspike.core.impl.scope.viewaccess.ViewAccessContextArtifactProducer.deltaSpikeContextExtension(ViewAccessContextArtifactProducer.java:0)
Possible dependencies:
- Extension [class org.apache.deltaspike.core.impl.scope.DeltaSpikeContextExtension] with qualifiers [#Default]; torino-application.ear,
- Producer Method [DeltaSpikeContextExtension] with qualifiers [#Any #Default] declared as [[BackedAnnotatedMethod] #SessionScoped #Produces public ..ejb.api.registration.service.DeltaspikeProducerDCE.produce()]
I replaced the original package of the project with ...
What could cause this behaviour?
The class DeltaspikeProducerDCE is located in
src/test/java/../api.registration.service, which normally should be excluded from the ear.
I am using Eclipse Mars and Wildfly 10 and build via Maven.
Related
I have the following error when deploying and starting the application with Wildfly.
No EJB found with interface of type "de.dev.java.project.api.ProjectApi" for binding de.dev.java.project.restservice.ProjectRestService/projectApi.
Project module structure:
- project-api -> built as jar
- ProjectApi.java
- project-impl -> built as jar
- ProjectRestService.java
{
#EJB ProjectApi projectApi
}
- application -> built as ear, which includes modules above
I only have a problem when i build "project-impl" module as jar. When i built as war i do not have a problem. What does war include which jar does not?
You must build as a proper ejb jar, not just regular jar. It also needs to be referenced properly in the ear. Use you IDE to setup suitable maven project with the right archetype
The TheConverter would like to use an injected Config produced by the ConfigProducer.
Where ConfigProducer is in the WAR but TheConverter and Config are in a jar.
Sadly it seems the config isn't injected leading to a javax.ejb.EJBException: javax.persistence.PersistenceException: Error attempting to apply AttributeConverter caused by a NullPointerException in TheConverter.
I'm using WildFly 8.1.0 which uses Weld to do CDI injection.
Am I trying to do something impossible or is this meant to work?
example.war
- ConfigProducer.class
#Produces Config
- WEB-INF/beans.xml (empty <beans></beans>)
- META-INF/persistence.xml
- WEB-INF/lib/entities.jar
- Config.class
- TheConverter.class
implements AttributeConverter
#Inject Config <-- FAIL
- TheEntity.class
- META-INF/beans.xml (empty <beans></beans>)
- META-INF/orm.xml
I don't know what exactly your problem is. But it is definitively possible to use this Producer and injection point combination.
Also WildFly should warn you if there were problems during bean discovery...
Probably you can add some more explanation about your beans.xml's, the Producer class and the persistence.xml.
Your beans.xml in your WAR file needs to go in WEB-INF, not META-INF
Using GGTS 3.6.0M1 with Grails 2.4, I have a java class file that needs an external jar to compile. That jar is defined in BuildConfig.groovy in the "compile" stage, but Eclipse still complains that the references class is not found (because it's not in the Java Build Path).
Since dependency management is performed by Grails, what's the best way to handle dependencies from Java classes that are within Grails projects?
EDIT: Refresh-dependencies doesn't solve the problem of my JAVA classes (under src/java) not seeing the jars in their classpath within Eclipse (showing project errors). If I compile externally - it works (grails compile).
I want to not use the built in Websphere 7 jpa plugin, instead use an application WEB-INF/lib/open-jpa 2 and a proprietary persistence provider. I cannot install the OSGI and JPA 2 feature pack for Websphere.
Originally, I was getting a sax parse error simply trying to load the persistence.xml (version="2" not supported). The error was thrown by a class in open-jpa 1.2.3. When I run websphere/appserver/bin/wsjpaversion.bat, the open-jpa 1.2.3 jar is displayed. By default it overrides the open-jpa 2 jar in the app. I created a shared library containing the open-jpa 2 jar with this config option checked: 'Use an isolated class loader for this shared library'. I set my application classloader to load parent last and assigned it the new shared library resource. The 'version 2' error is gone, but there is another problem. When I try to initialize an EntityManager I get an error:
Caused by: javax.persistence.PersistenceException: Failed to load provider from META-INF/services
at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(PersistenceProviderResolverHolder.java:121)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:91)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
... 2 more
Caused by: java.lang.ClassCastException: com.ibm.websphere.persistence.PersistenceProviderImpl incompatible with javax.persistence.spi.PersistenceProvider
at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(PersistenceProviderResolverHolder.java:110)
... 11 more
One more detail: inside the persistence.xml, the provider element is set to the proprietary PersistenceProviderImpl not the default Websphere persistence provider. So where is this websphere default coming from and how do I prevent it? (another important note: when I remove persistence.xml completely, I get the same error)
Thank you
Without installing the feature pack, you're fighting a losing battle. While it is possible to plug in your own JPA implementation, it is not possible to do that with JPA API — so WAS 7 ties you to the 1.0 version of JPA (see, for example, here how this is done — no class loader policy juggling will change that, though it seems tempting at first).
I have a Spring web project that uses Maven to compile/build. There is no issue in building the project. I am trying to run the project in Eclipse (3.3.2) on Tomcat (v6) server.
As part of Spring project, I have a spring-servlet.xml file in WEB-INF directory. This file includes another resource xml file that has datasource configuration.
<import resource="classpath:${datasourceInclude}.xml"/>
Now when the project is compiled using Maven, it resolves the variable ${datasourceInclude} and set it with appropriate values resulting in spring-servlet.xml with proper values.
<import resource="classpath:datasourceLocal.xml"/>
But when I tried running the project in Eclipse (Tomcat), I am getting following error:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:${datasourceInclude}.xml]
Offending resource: ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [${datasourceInclude}.xml]; nested exception is java.io.FileNotFoundException: class path resource [${datasourceInclude}.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
...
...
Basically when I starts Tomcat, it tries to pick the spring-servlet.xml from /src/main/webapp/WEB-INF folder which has ${datasourceInclude} variable.
Can anyone tell me how to fix this issue so that I dont have to change spring-servlet.xml and add hard code value in place of ${datasourceInclude} variable.
Try to add war:inplace to the list of goals executed for resource filtering in the Maven project configuration page.
Right-click on your project, then go to Properties > Maven > Lifecycle Mapping and add war:inplace to the Goals to invoke on resource changes as shown below:
Who's responsible for resolving the property/variable name in your Spring XML? This is done at compile time via Maven or is it supposed to happen at runtime? If at runtime, are you using Spring's PropertyPlaceholderConfigurer?