kumuluz / kumuluzee

Lightweight open-source framework for developing microservices using standard Java EE technologies and migrating Java EE to cloud-native architecture.
https://ee.kumuluz.com
MIT License
291 stars 71 forks source link

Error when declaring interceptor on beans.xml Kumuluzee 3.1 #130

Closed raphaelLacerda closed 4 years ago

raphaelLacerda commented 5 years ago

I'm using 3.1.0 and Java 8. Actually, i've tried with Java 10 also, but it didn't work.

The beans.xml works fine, until you declare an interceptor.

The error is on startup and i'm using ubber jar

Does anyone have the same problem?

<beans 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/beans_2_0.xsd"
       bean-discovery-mode="all">

    <interceptors><class>br.com.raphael.infra.Test</class></interceptors>
</beans>
@TestAnnotation
@Interceptor
public class Test {

    @AroundInvoke
    public Object intercept(InvocationContext ic) throws  Exception{

        ic.proceed();

        System.out.println("intercepts");
        return true;
    }
}
<kumuluzee.version>3.1.0</kumuluzee.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
WELD-001202: Error parsing file:/target/tmp/EeClassLoader/META-INF/beans.xml**
        at org.eclipse.jetty.annotations.ServletContainerInitializersStarter.doStart(ServletContainerInitializersStarter.java:69)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:346)
        at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497)
        at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459)
        at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:852)
        at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:278)
        at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
        at org.eclipse.jetty.server.Server.start(Server.java:415)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
        at org.eclipse.jetty.server.Server.doStart(Server.java:382)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at com.kumuluz.ee.jetty.JettyServletServer.startServer(JettyServletServer.java:83)
        at com.kumuluz.ee.EeApplication.initialize(EeApplication.java:375)
        at com.kumuluz.ee.EeApplication.<init>(EeApplication.java:73)
        at com.kumuluz.ee.EeApplication.main(EeApplication.java:85)
        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 com.kumuluz.ee.loader.EeClassLoader.invokeMain(EeClassLoader.java:437)
        at com.kumuluz.ee.loader.EeBootLoader.launch(EeBootLoader.java:54)
        at com.kumuluz.ee.loader.EeBootLoader.main(EeBootLoader.java:41)
Caused by: org.jboss.weld.exceptions.IllegalStateException: WELD-001202: Error parsing file:/target/tmp/EeClassLoader/META-INF/beans.xml
        at org.jboss.weld.xml.BeansXmlStreamParser.parse(BeansXmlStreamParser.java:161)
        at org.jboss.weld.bootstrap.WeldBootstrap.parse(WeldBootstrap.java:136)
        at org.jboss.weld.environment.deployment.discovery.AbstractBeanArchiveScanner.parseBeansXml(AbstractBeanArchiveScanner.java:46)
        at org.jboss.weld.environment.deployment.discovery.DefaultBeanArchiveScanner.scan(DefaultBeanArchiveScanner.java:76)
        at org.jboss.weld.environment.servlet.deployment.WebAppBeanArchiveScanner.scan(WebAppBeanArchiveScanner.java:73)
        at org.jboss.weld.environment.deployment.discovery.AbstractDiscoveryStrategy.performDiscovery(AbstractDiscoveryStrategy.java:93)
        at org.jboss.weld.environment.servlet.WeldServletLifecycle.createDeployment(WeldServletLifecycle.java:302)
        at org.jboss.weld.environment.servlet.WeldServletLifecycle.initialize(WeldServletLifecycle.java:156)
        at org.jboss.weld.environment.servlet.EnhancedListener.onStartup(EnhancedListener.java:62)
        at org.eclipse.jetty.plus.annotation.ContainerInitializer.callStartup(ContainerInitializer.java:140)
        at org.eclipse.jetty.annotations.ServletContainerInitializersStarter.doStart(ServletContainerInitializersStarter.java:64)
        ... 25 more
Caused by: javax.xml.stream.XMLStreamException: Precondition for readText is nextEvent().getTypeEventType() == START_ELEMENT (got 4)
        at com.bea.xml.stream.XMLEventReaderBase.getElementText(XMLEventReaderBase.java:87)
        at org.jboss.weld.xml.BeansXmlStreamParser.getTrimmedElementText(BeansXmlStreamParser.java:391)
        at org.jboss.weld.xml.BeansXmlStreamParser.parseInterceptors(BeansXmlStreamParser.java:239)
        at org.jboss.weld.xml.BeansXmlStreamParser.parse(BeansXmlStreamParser.java:146)
<plugin>
                <groupId>com.kumuluz.ee</groupId>
                <artifactId>kumuluzee-maven-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <id>package</id>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
urbim commented 5 years ago

Hi!

I couldn't replicate your problem on my machine. I used the same configuration as yours but my uber jar works as expected.

The only thing I changed is the return true; statement in the interceptor. It should return the object returned from ic.proceed() call. But I doubt that is the issue here.

Can you check the encoding of your beans.xml file? If that doesn't solve your problem, please provide more information about your system (JRE version, OS). And if possible attach the project in which the problem is present.

raphaelLacerda commented 4 years ago

After a looooooonnggg time... i've left the project and returned back a month ago

I've figured out what was the problem. It's a dependecy

`

stax stax 1.2.0

`

After i removed it, it worked fine

cen1 commented 4 years ago

Good to see you managed to get it working.