运行Springboot + JSF App失败,出现MalformedParameterizedTypeException

时间:2019-07-09 11:58:50

标签: spring-boot jsf

我正在尝试运行基于maven + spring-boot + primefaces的应用程序。这些是我的依赖:

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jdt.core.compiler</groupId>
            <artifactId>ecj</artifactId>
            <version>4.6.1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>3.3.7</version>
        </dependency>

        <dependency>
            <groupId>org.joinfaces</groupId>
            <artifactId>primefaces-spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <plugin>
                <artifactId>maven-war-plugin</artifactId>
            </plugin>
            <!-- wildfly-maven-plugin -->
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>1.2.1.Final</version>
                <configuration>
                    <server-args>
                        <server-arg>-Djboss.http.port=8080</server-arg>
                    </server-args>
                </configuration>
            </plugin>
        </plugins>
    </build>

这些是日志的一部分(太多行无法上传所有内容)。似乎与Primefaces和视图有关,但是由于应用程序在Tomcat中正常运行,所以我看不出问题出在哪里。

  "Services that may be the cause:" => [
 "jboss.clustering.web.route.default-server",
            "jboss.deployment.unit.\"myApp-0.0.1-SNAPSHOT.war\".component.\"com.myApp.viewmodel.CounterView\".START",
            "jboss.deployment.unit.\"myApp-0.0.1-SNAPSHOT.war\".component.\"com.myApp.viewmodel.CounterView\".WeldInstantiator",
            "jboss.deployment.unit.\"myApp-0.0.1-SNAPSHOT.war\".component.\"com.myApp.viewmodel.CounterView\".WeldInterceptorBindingsService",
            "jboss.deployment.unit.\"myApp-0.0.1-SNAPSHOT.war\".component.\"com.sun.faces.config.ConfigureListener\".START",
            "jboss.deployment.unit.\"myApp-0.0.1-SNAPSHOT.war\".component.\"com.sun.faces.config.ConfigureListener\".WeldInstantiator",
         "jboss.deployment.unit.\"com.myApp-0.0.1-SNAPSHOT.war\".component.\"com.sun.faces.taglib.jsf_core.ValueChangeListenerTag\".WeldInstantiator",
            "jboss.deployment.unit.\"com.myApp-0.0.1-SNAPSHOT.war\".component.\"com.sun.faces.taglib.jsf_core.VerbatimTag\".WeldInstantiator",
            "jboss.deployment.unit.\"com.myApp-0.0.1-SNAPSHOT.war\".component.\"com.sun.faces.taglib.jsf_core.ViewTag\".WeldInstantiator",
...

编辑:添加了更多日志信息

javax.enterprise.event.ObserverException
              at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
              at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
              at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
              at java.lang.Class.newInstance(Class.java:442)
              at org.jboss.weld.security.NewInstanceAction.run(NewInstanceAction.java:33)
              at java.security.AccessController.doPrivileged(Native Method)
              at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:40)
              at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:78)
              at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:103)
              at org.jboss.weld.injection.MethodInvocationStrategy$SpecialParamPlusBeanManagerStrategy.invoke(MethodInvocationStrategy.java:144)
              at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:330)
              at org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:123)
              at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:308)
              at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:286)
              at org.jboss.weld.util.Observers.notify(Observers.java:172)
              at org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:285)
              at org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:273)
              at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:177)
              at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:171)
              at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:53)
              at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:44)
              at org.jboss.weld.bootstrap.events.ProcessManagedBeanImpl.fire(ProcessManagedBeanImpl.java:31)
              at org.jboss.weld.bootstrap.events.ContainerLifecycleEvents.fireProcessBean(ContainerLifecycleEvents.java:242)
              at org.jboss.weld.bootstrap.events.ContainerLifecycleEvents.fireProcessBean(ContainerLifecycleEvents.java:236)
              at org.jboss.weld.bootstrap.AbstractBeanDeployer.deploySpecialized(AbstractBeanDeployer.java:111)
              at org.jboss.weld.bootstrap.BeanDeployment.deploySpecialized(BeanDeployment.java:260)
              at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:444)
              at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:86)
              at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:96)
              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1736)
              at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1698)
              at org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1556)
              at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
              at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
              at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
              at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1364)
              at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ExceptionInInitializerError
              at com.sun.faces.cdi.CdiExtension.collect(CdiExtension.java:172)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95)
              ... 28 more
Caused by: java.lang.reflect.MalformedParameterizedTypeException
              at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:58)
              at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:51)
              at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:92)
              at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:105)
              at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:140)
              at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
              at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68)
              at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138)
              at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
              at sun.reflect.generics.repository.ClassRepository.getSuperclass(ClassRepository.java:90)
              at java.lang.Class.getGenericSuperclass(Class.java:777)
              at javax.enterprise.util.TypeLiteral.getTypeParameter(TypeLiteral.java:103)
              at javax.enterprise.util.TypeLiteral.getType(TypeLiteral.java:66)
              at com.sun.faces.cdi.CdiUtils.<clinit>(CdiUtils.java:84)
              ... 34 more

我希望该应用程序能够运行。

更新:我已经使用mvn wildfly:run测试了该应用程序,并且可以正常工作。一次又一次地得到相同的错误。

1 个答案:

答案 0 :(得分:0)

@BalusC是我处理过的许多问题之一,所以我将总结解决方案。

  1. 将提供的范围用于Wildfly中已经存在的依赖项
  2. 有许多与JSF相关的注释,而不是CDI insdide视图Java类(@ManagedBean @ManagedProperty与@Named @Inject)
  3. 通过@Autowired在CDI Bean中使用spring bean。解决方案是在CDI bean中添加@Component并将org.springframework.web.jsf.el.SpringBeanFacesELResolver添加到faces-config文件中。