Jetty deployment: Unable to compile class for JSP - jetty

I tried to deploy to and run Jetty from an Ant-script, but get the following error:
[jetty.run] 2016-06-25 09:16:54.333: Starting web application null
[jetty.run] [main] WARN org.eclipse.jetty.annotations.ServletContainerInitializersStarter -
[jetty.run] javax.servlet.ServletException: Not running on Jetty, WebSocket+CDI support unavailable
[jetty.run] at org.eclipse.jetty.cdi.websocket.WebSocketCdiInitializer.onStartup(WebSocketCdiInitializer.java:49)
[jetty.run] at org.eclipse.jetty.plus.annotation.ContainerInitializer.callStartup(ContainerInitializer.java:140)
[jetty.run] at org.eclipse.jetty.annotations.ServletContainerInitializersStarter.doStart(ServletContainerInitializersStarter.java:63)
[jetty.run] at
...
It work without deployment, but with the war-file this happens. What is corrupt?
UPDATE:
Added
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
<resource-env-ref>
<description>Object factory for the CDI Bean Manager</description>
<resource-env-ref-name>BeanManager</resource-env-ref-name>
<resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
</resource-env-ref>
to web.xml andweld jars to lib. Now I get this:
java.lang.reflect.InvocationTargetException
[jetty.run] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[jetty.run] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[jetty.run] at ...
[jetty.run] Caused by: java.lang.IllegalStateException: Nothing to bind for name BeanManager
UPDATE 2:
Ok, I didn't need the extra things in my web.xml. Instead I had forgot to add
<typedef name="webApp" classname="org.eclipse.jetty.ant.AntWebAppContext" classpathref="classpath" loaderref="jetty.loader"/>
to build.xml. I can now deploy and run jetty, but can't process JSP files:
[jetty.run] [qtp1387380406-14] WARN org.eclipse.jetty.servlet.ServletHandler -
[jetty.run] org.apache.jasper.JasperException: Unable to compile class for JSP
[jetty.run] at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:600) ...
Why is this so?

Remove the various jetty cdi jar files from your project.
Those are designed specifically for jetty-distribution use, and are inappropriate for embedded-jetty.
Use the weld jars directly in your war file, along with the various recommended configurations that the weld project documentation tell you about.

Related

Startup Errors for Version 5.2 of WSO2 Identity Server

I have downloaded the latest version of wso2 identity server (5.2). However during the startup process I am getting the following errors.
[2016-10-26 09:50:27,563] INFO {org.wso2.carbon.webapp.mgt.TomcatGenericWebappsDeployer} - Deployed webapp: StandardEngine[Catalina].StandardHost[localhost].StandardContext[/wso2].File[D:\wso2is-5.2.0\bin\..\repository\deployment\server\webapps\wso2.war]
java.io.IOException: DerInputStream.getLength(): lengthTag=109, too big.
java.security.KeyStoreException: failed to extract any certificates or private keys - maybe bad password?
[2016-10-26 09:50:29,074] ERROR {org.jaggeryjs.scriptengine.engine.RhinoEngine} -
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Caused by: java.lang.ExceptionInInitializerError
at org.apache.commons.ssl.SSL.<init>(SSL.java:154)
at org.apache.commons.ssl.SSLClient.<init>(SSLClient.java:60)
at org.apache.commons.ssl.HttpSecureProtocol.<init>(HttpSecureProtocol.java:55)
at org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory.<init>(EasySSLProtocolSocketFactory.java:94)
at org.jaggeryjs.hostobjects.xhr.XMLHttpRequestHostObject.<init>(XMLHttpRequestHostObject.java:84)
... 113 more
Caused by: java.lang.NullPointerException
at org.apache.commons.ssl.TrustMaterial.<init>(TrustMaterial.java:127)
at org.apache.commons.ssl.TrustMaterial.<init>(TrustMaterial.java:118)
at org.apache.commons.ssl.TrustMaterial.<clinit>(TrustMaterial.java:108)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.commons.ssl.KeyMaterial
at org.apache.commons.ssl.SSL.<init>(SSL.java:154)
at org.apache.commons.ssl.SSLClient.<init>(SSLClient.java:60)
It is a vanilla version of the server and I haven't made any kind of configuration changes. I am running on JDK 1.8. Can someone tell me what the resolution will be. I tried including "not-yet-commons-ssl-0.3.10.jar" and that didnt help.
Regards
Ranjith Madhavan
I recently got this exception, it was due to the fact that i donot have /lib/security/cacerts and /lib/security/jssecacerts in my jre.

error when deploying Java WS in Jboss 6.3.0 EAP

I am migrating an application with Java WS from Jboss 5.1.0 to Jboss 6.3.0 EAP. It works fine with Jboss 5.1.0 but I am getting error while deploying the same in Jboss 6.3.0 EAP.
14:42:10,887 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deploy
ment.unit."my-app.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."dtm-banking.
war".INSTALL: JBAS018733: Failed to process phase INSTALL of deployment "dtm-banking.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [jboss-a
s-server-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1980) [jboss-ms
c-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1913) [jboss-msc-1.1.5.F
inal-redhat-1.jar:1.1.5.Final-redhat-1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_60]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_60]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_60]
Caused by: javax.xml.ws.WebServiceException: java.lang.reflect.UndeclaredThrowableException
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:371)
at org.jboss.wsf.stack.cxf.deployment.EndpointImpl.doPublish(EndpointImpl.java:66)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:251)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:539)
at org.jboss.wsf.stack.cxf.configuration.NonSpringBusHolder.configure(NonSpringBusHolder.java:118)
at org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.startDeploymentBus(BusDeploymentAspect.java:137
)
at org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.start(BusDeploymentAspect.java:69)
at org.jboss.as.webservices.deployers.AspectDeploymentProcessor.deploy(AspectDeploymentProcessor.java:74)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [jboss-a
s-server-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
... 5 more
Caused by: java.lang.reflect.UndeclaredThrowableException
at com.sun.proxy.$Proxy371.visitLabel(Unknown Source)
at org.apache.cxf.jaxws.WrapperClassGenerator.createWrapperClass(WrapperClassGenerator.java:213)
at org.apache.cxf.jaxws.WrapperClassGenerator.generate(WrapperClassGenerator.java:122)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.generatedWrapperBeanClass(JaxWsServiceFactoryBean.java:6
83)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.getExtraClass(JaxWsServiceFactoryBean.java:653)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBea
n.java:484)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:704)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBe
an.java:550)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:265)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:215)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java
:102)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:159)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:456)
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:334)
... 13 more
Caused by: java.lang.NoSuchMethodException: org.objectweb.asm.MethodWriter.visitLabel(org.objectweb.asm.Label)
at java.lang.Class.getMethod(Class.java:1665) [rt.jar:1.7.0_60]
at org.apache.cxf.common.util.ReflectionInvokationHandler.invoke(ReflectionInvokationHandler.java:85)
... 28 more
I understand Jboss 6.3.0 EAP uses CXF implementation for webservice, but I am looking for simple Java WS to use the standard Java EE environment.
tried the following in jboss-deployment-structure.xml
<exclude-subsystems>
<subsystem name="webservices" />
</exclude-subsystems>
this got rid of the exception at deployment time but I get a Classcast exception when invoking the wsdl for the service
http://localhost:8080/myapp/myservice?wsdl
JBWEB000235: Allocate exception for servlet MyWebService: java.lang.ClassCastException: com.example.webservice.endpoint.DataService cannot be cast to javax.servlet.Servlet
any idea?
The problem is bundling asm.jar in your deployment.
Try remove it and add this to your jboss-deployment-structure.xml:
<jboss-deployment-structure>
<deployment>
<dependencies>
...
<module name="asm.asm" />
...
</dependencies>
</deployment>
</jboss-deployment-structure>
See more: https://developer.jboss.org/message/823745
The answer that fixed things for me was:
I had the same problem. Adding jboss-deployment-structure.xml only
work for WAR files. If I depolyed the WAR inside an EAR I got the
error back. So I added
<global-modules>
<module name="asm.asm" slot="main"/>
</global-modules>
to the current jboss configuration, ie standalone-full.xml The it
work fine for me.
So if anyone stumbles upon this question, give it a try.
Rifer this page too.
https://access.redhat.com/solutions/690353
The above Error is thrown when for given class particular method not
found. Hence user is packaging asm jar in their application and class
"org.objectweb.asm.MethodWriter" which contains in a jar does not have
method "public void visitLabel(org.objectweb.asm.Label);" hence
getting "java.lang.NoSuchMethodException".

WSO2 ESB: JAR file with callback handler not loading

I am trying to setup a proxy service that hides the security of a back end service, following the tutorial found here.
For the password callback handler I follow the instructions found here.
All pretty basic and straightforward.
I compiled the PWCBHandler class into a JAR file and put it in the esbhome\repository\components\lib folder together with all the JAR files from wss4j-1.6.15\lib.
I see no warnings or errors during startup of the ESB. However when I test the proxy service, I get the following error in the log:
org.apache.axis2.AxisFault: Error in obtaining a token
at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:76)
at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:340)
...
Caused by: org.apache.rampart.RampartException: Error in obtaining a token
at org.apache.rampart.util.RampartUtil.getToken(RampartUtil.java:779)
at org.apache.rampart.util.RampartUtil.getIssuedToken(RampartUtil.java:675)
...
Caused by: org.apache.rampart.RampartException: Cannot load password callback class: PWCBHandler
at org.apache.rampart.util.RampartUtil.getPasswordCB(RampartUtil.java:144)
at org.apache.rampart.util.RampartUtil.getPasswordCB(RampartUtil.java:118)
at org.apache.rampart.util.RampartUtil.getToken(RampartUtil.java:723)
...
... 26 more
Caused by: java.lang.ClassNotFoundException: PWCBHandler
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
... 26 more
Caused by: java.lang.ClassNotFoundException: PWCBHandler
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at org.apache.ws.security.util.Loader.loadClass(Loader.java:200)
at org.apache.ws.security.util.Loader.loadClass(Loader.java:163)
at org.apache.rampart.util.RampartUtil.getPasswordCB(RampartUtil.java:142)
... 28 more
[2014-06-16 15:56:23,103] WARN - FaultHandler ERROR_CODE : 0
[2014-06-16 15:56:23,103] WARN - FaultHandler ERROR_MESSAGE : Unexpected error during sending message out
[2014-06-16 15:56:23,103] WARN - FaultHandler ERROR_DETAIL : org.apache.synapse.SynapseException: Unexpected error during sending message out
at org.apache.synapse.core.axis2.Axis2Sender.handleException(Axis2Sender.java:170)
at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:69)
...
In other words, the ESB and Rampart know about the PWCBHandler class but it cannot load / access it.
At this point I have no ideas where to look further. Is there a way where I can check which JAR files were loaded during startup? What might prohibit the loading of the PWCBHandler JAR?
Thanks for your feedback,
Olivier
Thanks to the answer from Rajeev I got confirmation the class was not loading.
I recreated the JAR file with the class added to a package and after restarting the server a bundle for the JAR was created.
It looks like custom classes need to be added to a package for Carbon to create a bundle from it.
I know, I know, classes should always be added to a package, but I am not a Java hero and did not want to bother with the dirs and such.
Lessons learned! :)

Embedded Tomcat 7 does not found ServletContainerInitializer from servlet-api 3.x

I'm using the embedded Tomcat 7.0.40 for my unit tests. My webapp uses Servlet 3.x (with x>0).
I managed to deploy my webapp on the Tomcat.
// create the embedded Tomcat
Tomcat tomcat = new Tomcat();
// (...)
// deploy the WAR in the webApp folder
// (...)
// add the WebApp in Tomcat
Context context = tomcat.addWebapp(tomcat.getHost(), "/myapp", webApp.getAbsolutePath());
// (...)
// start the embedded Tomcat
tomcat.start()
However, when I start Tomcat an exception is thrown:
(...)
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContainerInitializer
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2895)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.catalina.startup.ContextConfig.getServletContainerInitializer(ContextConfig.java:1659)
at org.apache.catalina.startup.ContextConfig.processServletContainerInitializers(ContextConfig.java:1569)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1277)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5269)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 7 more
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContainerInitializer
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
... 25 more
The javax.servlet.ServletContainerInitializer is localized in the javax.servlet-api JAR starting from version 3.1.
Do you know how to solve this issue?
How can I add programatically this library in the classpath of the embedded Tomcat?
I try several methods by none work...
Thanks for help.

NoClassDefFoundError: com.ibm.ws.wstx.handler.WSATGenerator

I'm using the web client for web service. Client stub is generated with Axis 2. Everything is deployed on WebSphere 7.0.
When deployed on my developer machine (websphere instance run inside IBM RAD Eclipse) I'm connected with remote web service. However, on test machine, the error is thrown:
java.lang.NoClassDefFoundError: com.ibm.ws.wstx.handler.WSATGenerator (initialization failure)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:140)
at com.ibm.ws.wstx.WSTXClientTCMImpl.handleInbound(WSTXClientTCMImpl.java:100)
at com.ibm.ws.wstx.WSTXClientTCMImpl.cleanupContext(WSTXClientTCMImpl.java:81)
at org.apache.axis2.util.ThreadContextMigratorUtil.performContextCleanup(ThreadContextMigratorUtil.java:192)
at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.postExecute(AxisInvocationController.java:657)
at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.execute(AxisInvocationController.java:589)
at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.doInvoke(AxisInvocationController.java:130)
at org.apache.axis2.jaxws.core.controller.impl.InvocationControllerImpl.invoke(InvocationControllerImpl.java:93)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:364)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:185)
at $Proxy94.getList(Unknown Source)
The ear that is deployed there is made by me on my development machine, so it's exactly the same code. So I suppose that it's some configuration issue. However, I have no idea, what part of configuration can be responsible for that.
So, I have the question, what is this WSATGenerator, and in which jar it should be available? Is it a standard library on WebSphere, or must it be manually configured? What configuration differences could cause that error thrown on test server and no by me?
I'm running Windows 7, the test machine is on Unix. Both machines are 64bit.
--edit--
Before NoClassDefFoundError, there is throws ExceptionInInitializerError:
java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.initialize(J9VMInternals.java:222)
at com.ibm.ws.wstx.handler.WSATGenerator.<clinit>(WSATGenerator.java:127)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
at com.ibm.ws.wstx.WSTXClientTCMImpl.migrateThreadToContext(WSTXClientTCMImpl.java:61)
at org.apache.axis2.util.ThreadContextMigratorUtil.performMigrationToContext(ThreadContextMigratorUtil.java:163)
at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.preExecute(AxisInvocationController.java:608)
at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.execute(AxisInvocationController.java:570)
... 82 more
Caused by:
java.lang.ClassCastException: com.systinet.jaxrpc.rpc.ServiceFactoryImpl incompatible with com.ibm.wsspi.webservices.rpc.ServiceFactory
at com.ibm.ws.Transaction.wstx.WSATServices$1.run(WSATServices.java:83)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:63)
at com.ibm.ws.Transaction.wstx.WSATServices.<clinit>(WSATServices.java:74)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
... 89 more