Hot questions for Using GlassFish in apache

Question:

I want to use Apache Camel in a war project that is deployed to a Payara server, but once I add the camel-cdi jar to the project, deploying the application fails with

Exception while deploying the app [TheProject-1.0-SNAPSHOT] : JNDI lookup failed for the resource: Name: [java:module/env/org.apache.camel.cdi.transaction.JtaTransactionPolicy/transactionManager], Lookup: [java:/TransactionManager], Type: [java.lang.String] javax.naming.NamingException: Lookup failed for 'java:/TransactionManager'

What are my options here? Is there a way to fix this JNDI issue or is it feasible to use Camel without CDI? I'm not doing anything that would actually need a TransactionManager.

I don't want to add Spring dependencies.

I'm using Payara 5.191 and tried Camel 2.23.1 and 3.0.0-M1.

Full stacktrace

  Exception while deploying the app [RegistrationInterfaceProxy-1.0-SNAPSHOT] : JNDI lookup failed for the resource: Name: [java:module/env/org.apache.camel.cdi.transaction.JtaTransactionPolicy/transactionManager], Lookup: [java:/TransactionManager], Type: [java.lang.String]
javax.naming.NamingException: Lookup failed for 'java:/TransactionManager' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: No object bound to name java:/TransactionManager]
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:496)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:442)
        at javax.naming.InitialContext.lookup(InitialContext.java:417)
        at javax.naming.InitialContext.lookup(InitialContext.java:417)
        at com.sun.enterprise.deployment.util.ResourceValidator.validateJNDIRefs(ResourceValidator.java:891)
        at com.sun.enterprise.deployment.util.ResourceValidator.validateResources(ResourceValidator.java:742)
        at com.sun.enterprise.deployment.util.ResourceValidator.event(ResourceValidator.java:146)
        at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.prepare(ApplicationLifecycle.java:416)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:558)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:552)
        at org.glassfish.deployment.admin.InstanceDeployCommand.execute(InstanceDeployCommand.java:223)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:557)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:553)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:360)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:552)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:583)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:575)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:360)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:574)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1483)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:119)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1865)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1741)
        at org.glassfish.admin.rest.resources.admin.CommandResource.executeCommand(CommandResource.java:409)
        at org.glassfish.admin.rest.resources.admin.CommandResource.execCommandMultInMultOut(CommandResource.java:258)
        at sun.reflect.GeneratedMethodAccessor210.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:76)
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:148)
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:191)
        at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:200)
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:103)
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:493)
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:415)
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:104)
        at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:277)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:272)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:268)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:268)
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:289)
        at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:256)
        at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:704)
        at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:377)
        at org.glassfish.admin.rest.adapter.JerseyContainerCommandService$3.service(JerseyContainerCommandService.java:179)
        at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:192)
        at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:520)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:217)
        at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182)
        at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156)
        at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218)
        at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
        at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
        at org.glassfish.grizzly.portunif.PUFilter.handleRead(PUFilter.java:208)
        at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
        at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
        at org.glassfish.grizzly.portunif.PUFilter.handleRead(PUFilter.java:208)
        at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
        at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
        at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:524)
        at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$0(WorkerThreadIOStrategy.java:90)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114)
        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
        at java.lang.Thread.run(Thread.java:748)
Caused by: javax.naming.NameNotFoundException: No object bound to name java:/TransactionManager
        at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:761)
        at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:735)
        at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:167)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:476)
        ... 83 more

Answer:

To make the TransactionManager available under the expected name, the following code needs to be added to the web.xml

<ejb-ref>
    <ejb-ref-name>java:/TransactionManager</ejb-ref-name>
    <mapped-name>java:appserver/TransactionManager</mapped-name>
</ejb-ref>

Question:

I've got some troubles probably with adding correctly java libs into my Java EE project. I'm using intellij idea IDE.

I want to use an external library in my project (apache jena) and I've added that library using this procedure: Project Structure > Modules > Dependencies > Add JARs or dirs > Select apache jena lib dir (there are some .jar files inside, like core ..).

In the project, everything seems to be ok - import, object definitions .. But after deploy on the local glassfish server and after visiting index page, I got NoClassDefFoundError (exactly java.lang.NoClassDefFoundError: org/apache/jena/rdf/model/ModelFactory).

package controller;


import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import org.apache.jena.rdf.model.*;


@WebServlet( name = "TestController", urlPatterns = {"/"})
public class TestController extends HttpServlet {

    /**
     * Processes requests for both HTTP <code>GET and POST methods.
     * @param request servlet request
     * @param response servlet response
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        /* ERROR >> */
        Model model = ModelFactory.createDefaultModel();
        /* << ERROR */

        request.setAttribute("test", "test");
        request.getRequestDispatcher("test.jsp").forward(request,response);
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

}

So can anyone advise me how to solve it, please? Thanks!


Answer:

Problem solved: I had to add the library into the artifact (war exploded).

Procedure: Project structure > Artifacts > and there was a notice about missing library in that artifact so I clicked "Fix(add that library into the artifact)" > apply and Done :)

Intellij IDEA v14.1.5

Question:

I have been busy building a REST application with angularjs frontend, using a MAVEN jersey-quickstart-webapp, developed on Eclipse using the GLASSFISH webserver. Today when I started to do some development on the project, when I tried to start the server in eclipse and deploy the webapp, I got the following error message displayed in the eclipse error window:

cannot Deploy pododdle
deploy is failing=Error occurred during deployment: Exception while loading the app :
    java.lang.IllegalStateException: ContainerBase.addChild: start: 
    org.apache.catalina.LifecycleException:
    org.apache.catalina.LifecycleException:
    java.lang.ClassNotFoundException: com.pododdle.dao.CategoryListService.
Please see server.log for more details.

It should be noted that I have not knowingly changed the JRE/JDK of Eclipse or Glassfish. The server.log shows this error (it is repeated 3/4 times for each launch):

ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.ClassNotFoundException: com.pododdle.dao.CategoryListService
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5985)
at com.sun.enterprise.web.WebModule.start(WebModule.java:691)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2286)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1932)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:500)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
at org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:131)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: java.lang.ClassNotFoundException: com.pododdle.dao.CategoryListService
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5740)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5977)
... 64 more
Caused by: java.lang.ClassNotFoundException: com.pododdle.dao.CategoryListService
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1783)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1633)
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at org.glassfish.jersey.internal.util.ReflectionHelper$4.run(ReflectionHelper.java:311)
at org.glassfish.jersey.internal.util.ReflectionHelper$4.run(ReflectionHelper.java:308)
at java.security.AccessController.doPrivileged(Native Method)
at org.glassfish.jersey.server.model.IntrospectionModeller.checkResourceClassFields(IntrospectionModeller.java:223)
at org.glassfish.jersey.server.model.IntrospectionModeller.doCreateResourceBuilder(IntrospectionModeller.java:139)
at org.glassfish.jersey.server.model.IntrospectionModeller.access$000(IntrospectionModeller.java:80)
at org.glassfish.jersey.server.model.IntrospectionModeller$1.call(IntrospectionModeller.java:112)
at org.glassfish.jersey.server.model.IntrospectionModeller$1.call(IntrospectionModeller.java:109)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255)
at org.glassfish.jersey.server.model.IntrospectionModeller.createResourceBuilder(IntrospectionModeller.java:109)
at org.glassfish.jersey.server.model.Resource.from(Resource.java:792)
at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:463)
at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:182)
at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:348)
at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:345)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:345)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:390)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:362)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1382)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5732)
... 65 more

I have seen a similar question about this error on Tomcat here: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/CollegeWebsite]]

As per this question, it says this can be caused by Eclipse and Tomcat using different JRE's. I have the following JRE running in Eclipse:

jdk1.8.0_73

The question is about Tomcat, so I tried to set JAVA_HOME on my Glassfish server by adding the following line to the ansev.bat for my glassfish server:

set AS_JAVA=C:\Program Files\Java\jdk1.8.0_73

This was suggested by this answer: How do I specify the jdk for a glassfish domain?

However I am not sure if this is what I am looking for

This has not fixed the problem - it still gives the same error. Does anybody know what might be going wrong? Why would it suddenly stop working, and have I set the JRE for GLASSFISH correctly? How do I check what version of the JRE the GLASSFISH installation is using?

All help much appreciated....

EDIT 1: As per Mike in the comments section reckons I am barking up the wrong tree - because it is a ClassNotFoundException that is being thrown, it looks like it is building incorrectly. Here is the server startup logging that appears in the console prior to the error:

2016-10-17T09:13:50.769+0100|Info: Running GlassFish Version: GlassFish Server Open Source Edition  4.1.1  (build 1)
2016-10-17T09:13:50.770+0100|Info: Server log file is using Formatter class: com.sun.enterprise.server.logging.ODLLogFormatter
2016-10-17T09:13:50.861+0100|Info: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
2016-10-17T09:13:50.863+0100|Info: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
2016-10-17T09:13:50.865+0100|Info: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.
2016-10-17T09:13:50.964+0100|Info: Authorization Service has successfully initialized.
2016-10-17T09:13:51.008+0100|Info: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry
2016-10-17T09:13:51.155+0100|Warning: Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=http-listener-1, realClassName=org.glassfish.grizzly.http2.Http2AddOn
2016-10-17T09:13:51.230+0100|Info: Grizzly Framework 2.3.23 started in: 54ms - bound to [/0.0.0.0:8080]
2016-10-17T09:13:51.242+0100|Warning: Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=http-listener-2, realClassName=org.glassfish.grizzly.http2.Http2AddOn
2016-10-17T09:13:51.245+0100|Info: Grizzly Framework 2.3.23 started in: 1ms - bound to [/0.0.0.0:8181]
2016-10-17T09:13:51.247+0100|Warning: Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=admin-listener, realClassName=org.glassfish.grizzly.http2.Http2AddOn
2016-10-17T09:13:51.251+0100|Info: Grizzly Framework 2.3.23 started in: 1ms - bound to [/0.0.0.0:4848]
2016-10-17T09:13:51.279+0100|Info: Grizzly Framework 2.3.23 started in: 1ms - bound to [/0.0.0.0:3700]
2016-10-17T09:13:51.280+0100|Info: GlassFish Server Open Source Edition  4.1.1  (1) startup time : Felix (1,326ms), startup services(616ms), total(1,942ms)
2016-10-17T09:13:51.343+0100|Info: JTS5014: Recoverable JTS instance, serverId = [100]
2016-10-17T09:13:51.403+0100|Info: Grizzly Framework 2.3.23 started in: 2ms - bound to [/0.0.0.0:7676]
2016-10-17T09:13:51.404+0100|Info: Registered com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishImpl@27d57a2c as OSGi service registration: org.apache.felix.framework.ServiceRegistrationImpl@597f48df.
2016-10-17T09:13:51.418+0100|Info: JMXStartupService has started JMXConnector on JMXService URL service:jmx:rmi://PododdlePC:8686/jndi/rmi://PododdlePC:8686/jmxrmi
2016-10-17T09:13:53.709+0100|Info: HV000001: Hibernate Validator 5.1.2.Final
2016-10-17T09:13:55.620+0100|Info: visiting unvisited references
2016-10-17T09:13:57.095+0100|Info: Java security manager is disabled.
2016-10-17T09:13:57.096+0100|Info: Entering Security Startup Service.
2016-10-17T09:13:57.101+0100|Info: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.
2016-10-17T09:13:57.187+0100|Info: Security Service(s) started successfully.
2016-10-17T09:13:57.632+0100|Info: Created HTTP listener http-listener-1 on host/port 0.0.0.0:8080
2016-10-17T09:13:57.637+0100|Info: Created HTTP listener http-listener-2 on host/port 0.0.0.0:8181
2016-10-17T09:13:57.638+0100|Info: Created HTTP listener admin-listener on host/port 0.0.0.0:4848
2016-10-17T09:13:57.665+0100|Info: Created virtual server server
2016-10-17T09:13:57.667+0100|Info: Created virtual server __asadmin
2016-10-17T09:13:57.937+0100|Info: Setting JAAS app name glassfish-web
2016-10-17T09:13:57.938+0100|Info: Virtual server server loaded default web module 
2016-10-17T09:13:59.082+0100|Info: visiting unvisited references
2016-10-17T09:13:59.180+0100|Info: visiting unvisited references
2016-10-17T09:13:59.181+0100|Info: visiting unvisited references
2016-10-17T09:13:59.182+0100|Info: visiting unvisited references
2016-10-17T09:13:59.182+0100|Info: visiting unvisited references
2016-10-17T09:13:59.183+0100|Info: visiting unvisited references
2016-10-17T09:13:59.184+0100|Info: visiting unvisited references
2016-10-17T09:13:59.184+0100|Info: visiting unvisited references
2016-10-17T09:13:59.185+0100|Info: visiting unvisited references
2016-10-17T09:13:59.185+0100|Info: visiting unvisited references
2016-10-17T09:13:59.186+0100|Info: visiting unvisited references
2016-10-17T09:13:59.217+0100|Info: visiting unvisited references
2016-10-17T09:13:59.218+0100|Info: visiting unvisited references
2016-10-17T09:13:59.218+0100|Info: visiting unvisited references
2016-10-17T09:13:59.219+0100|Info: visiting unvisited references
2016-10-17T09:13:59.219+0100|Info: visiting unvisited references
2016-10-17T09:13:59.220+0100|Info: visiting unvisited references
2016-10-17T09:13:59.221+0100|Info: visiting unvisited references
2016-10-17T09:13:59.221+0100|Info: visiting unvisited references
2016-10-17T09:13:59.222+0100|Info: visiting unvisited references
2016-10-17T09:13:59.584+0100|Info: WELD-000900: 2.2.13 (Final)
2016-10-17T09:14:00.712+0100|WARN: WELD-001700: Interceptor annotation class javax.ejb.PostActivate not found, interception based on it is not enabled
2016-10-17T09:14:00.712+0100|WARN: WELD-001700: Interceptor annotation class javax.ejb.PrePassivate not found, interception based on it is not enabled
2016-10-17T09:14:00.986+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:00.994+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:00.999+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.004+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.007+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.008+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.009+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.011+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.015+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.017+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.017+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.044+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.044+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.046+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.048+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.050+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.052+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.054+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.054+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.055+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.057+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.058+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.059+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:01.060+0100|WARN: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2016-10-17T09:14:03.606+0100|Severe: WebModule[/pododdle]StandardWrapper.Throwable

Do this log point to anything obvious?


Answer:

As per Mike in the comments suggested, it was likely there was something wrong with how the project was being built, due to this:

Caused by: java.lang.ClassNotFoundException: com.pododdle.dao.CategoryListService

I looked into this, and he was right! Two jar files that I had on my builpath were mysteriously missing! They were:

jersey-media-multipart-2.21.1.jar
mimepull-1.9.3.jar

I have no idea how the jar files were deleted from the /lib directory of the glassfish server, maybe I shouldn't have drunk that extra bottle of whiskey. Once they were added back in, everything suddenly worked hunky dory. A little baffled by the error - i would have thought it would give a compile error if the jar wasn't available. Anyhow, 5 days lost due to another annoying error.

Question:

this may be two questions in one, so...Sorry, please correct me if I'm wrong.

I have to deploy a web service developed with JPA, JSP and Glassfish 3.1.2, in a machine which only has apache Tomcat 7 as server installed on Windows 7.

I don't really know how apache can connect to the database externally, or if that is really possible if you don't use TomEE.

I know in Glassfish you can have a connection pool and a jdbc resource, and if you're using JPA, that's how the connection to database works(kindof), so you can deploy the .war file. But, if you only have a Tomcat and the app is using JPA, so it does not connect itself to the database(It does not have a class with a connection credentials), How can I achieve this?

Or, Can I deploy the .war of the web service on Glassfish and then be consumed by an application that only works with apache Tomcat on client side? Am I mixing concepts which should not be mixed?

Any enlightenment is highly appreciated.


Answer:

You can use Tomcat with JPA, you can even use it in a standalone java application. Define a persistence unit name in persistence.xml, make sure the transaction type is RESOURCE_LOCAL (you can't use JTA in Tomcat, make sure to check this), and get a reference to the EM using the following

EntityManagerFactory emf = Persistence.createEntityManagerFactory("persistenceUnitName");
em = emf.createEntityManager();

Finally, add the jpa provider jars to Tomcat, there are examples for that (I've never done it, but I'm sure some Tomcat expert could lend a hand)

The other option could also work, that is consume your webservice using a client deployed on another server

Good luck!

Question:

I tried to upload an image to tomcat and glassfish servers, Path I tried to set is as bellow System.getProperty("user.dir")+ File.separator+"images"+File.separator;

It takes System.getProperty("user.dir") as tomcat C:\Apache\Tomcat\bin and glassfish 'C:\Apache\glassfish4\glassfish\domains\domain1\config` directory. I am using Intellij to develop the system.

I want to upload an image to out/artifacts/CopywriteProtector_war)exploded/Resources/images folder so that I can access the images using http://localhost/Resources/images/msg.jpg, how to do this? I have spent days of time googling but couldn't able to find useful thing


Answer:

You can get the root of your deployed application with

String root = getServletContext().getRealPath("/");

This will be the equivalent of the resources directory of your source code. Add the filepath of where you want your image to be. i.e.

String filePath = root + "images/msg.jpg";

Then you can created your writer from that path

BufferedWriter writer = new BufferedWriter(new FileWriter(filepath);
writer.write(objectToWrite);//or similar

You can then access the resulting file with

getServletContext().getResource(filePath); // as URL or
getServletContext().getResourceAsStream(filePath); // as InputStream

-- Tested and worked on Payara (an application server derived from Glassfish)

Question:

According to the defintions I have read a web server is something which can serve http requests (e.g Apache).

A web container is something which can serve servlets and JSPs etc. Since Tomcat can both serve http requests and also serve servlets and JSPs it is considered as both a web server and a web container.

Application servers like Jboss, Glassfish are fully fledged java EE servers which also include other containers apart from the web container.

Now in order for an application server like Glassfish to work on its own, it also needs a web server(an http server) built into it. Therefore it should contain a webserver to work on its won, and if it doesn't contain a webserver built into it, there should be a way to plug existing web servers like apache to this application server.

What is the actual implementation? does it include a webserver or we should plug webservers into these java EE application servers?


Answer:

Yes, it includes a full web tier. The Java Servlet spec covers much of this.

Question:

Apcahe Tomcat Log
17-Oct-2014 14:06:48.319 SEVERE [http-nio-8084-exec-1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class listeners.Initializer
 java.lang.NoClassDefFoundError: org/apache/http/params/HttpParams
    at mon.MainMon.openConnection(MainMon.java:72)
    at mon.MainMon.<init>(MainMon.java:38)
    at mon.MainMon.setJndiName(MainMon.java:221)
    at listeners.Initializer.contextInitialized(Initializer.java:38)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4760)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5184)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:581)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:455)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1496)
    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:483)
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1437)
    at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:884)
    at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:335)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:615)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:655)
    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.apache.http.params.HttpParams
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1324)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1177)
    ... 53 more

17-Oct-2014 14:06:48.319 SEVERE [http-nio-8084-exec-1] org.apache.catalina.core.StandardContext.listenerStop Exception sending context destroyed event to listener instance of class ShutdownInitializer
 java.lang.NullPointerException
    at ShutdownInitializer.contextDestroyed(ShutdownInitializer.java:61)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4801)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5401)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:581)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:455)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1496)
    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:483)
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1437)
    at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:884)
    at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:335)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:615)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:655)
    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
Apache Tomcat
Using CATALINA_BASE:   "C:\Users\serega\AppData\Roaming\NetBeans\8.0.1\apache-tomcat-8.0.9.0_base"
Using CATALINA_HOME:   "C:\Program Files\Apache Software Foundation\Apache Tomcat 8.0.9"
Using CATALINA_TMPDIR: "C:\Users\serega\AppData\Roaming\NetBeans\8.0.1\apache-tomcat-8.0.9.0_base\temp"
Using JRE_HOME:        "C:\Program Files\Java\jdk1.8.0_20"
Using CLASSPATH:       "C:\Program Files\Apache Software Foundation\Apache Tomcat 8.0.9\bin\bootstrap.jar;C:\Program Files\Apache Software Foundation\Apache Tomcat 8.0.9\bin\tomcat-juli.jar"
17-Oct-2014 17:50:32.348 INFO [main] org.apache.catalina.core.AprLifecycleListener.init The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.8.0_20\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;.
17-Oct-2014 17:50:32.788 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8084"]
17-Oct-2014 17:50:32.866 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
17-Oct-2014 17:50:32.874 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
17-Oct-2014 17:50:32.874 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
17-Oct-2014 17:50:32.881 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1074 ms
17-Oct-2014 17:50:32.944 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
17-Oct-2014 17:50:32.944 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.9
17-Oct-2014 17:50:32.967 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying configuration descriptor C:\Users\serega\AppData\Roaming\NetBeans\8.0.1\apache-tomcat-8.0.9.0_base\conf\Catalina\localhost\manager.xml
17-Oct-2014 17:50:33.826 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
17-Oct-2014 17:50:34.045 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of configuration descriptor C:\Users\serega\AppData\Roaming\NetBeans\8.0.1\apache-tomcat-8.0.9.0_base\conf\Catalina\localhost\manager.xml has finished in 1,071 ms
17-Oct-2014 17:50:34.045 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying configuration descriptor C:\Users\serega\AppData\Roaming\NetBeans\8.0.1\apache-tomcat-8.0.9.0_base\conf\Catalina\localhost\MDCWebDispatcher.xml
17-Oct-2014 17:50:34.045 WARNING [localhost-startStop-1] org.apache.catalina.startup.SetContextPropertiesRule.begin [SetContextPropertiesRule]{Context} Setting property 'antiJARLocking' to 'true' did not find a matching property.
17-Oct-2014 17:50:35.672 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Error listenerStart
17-Oct-2014 17:50:35.680 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [/MDCWebDispatcher] startup failed due to previous errors
17-Oct-2014 17:50:35.688 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of configuration descriptor C:\Users\serega\AppData\Roaming\NetBeans\8.0.1\apache-tomcat-8.0.9.0_base\conf\Catalina\localhost\MDCWebDispatcher.xml has finished in 1,643 ms
17-Oct-2014 17:50:35.688 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying configuration descriptor C:\Users\serega\AppData\Roaming\NetBeans\8.0.1\apache-tomcat-8.0.9.0_base\conf\Catalina\localhost\ROOT.xml
17-Oct-2014 17:50:35.797 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
17-Oct-2014 17:50:35.797 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of configuration descriptor C:\Users\serega\AppData\Roaming\NetBeans\8.0.1\apache-tomcat-8.0.9.0_base\conf\Catalina\localhost\ROOT.xml has finished in 109 ms
17-Oct-2014 17:50:35.797 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8084"]
17-Oct-2014 17:50:35.813 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
17-Oct-2014 17:50:35.813 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 2839 ms
17-Oct-2014 17:50:37.637 INFO [http-nio-8084-exec-2] org.apache.catalina.util.LifecycleBase.stop The stop() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/MDCWebDispatcher]] after stop() had already been called. The second call will be ignored.
17-Oct-2014 17:50:38.198 INFO [http-nio-8084-exec-2] org.apache.catalina.startup.HostConfig.undeploy Undeploying context [/MDCWebDispatcher]
17-Oct-2014 17:50:38.307 INFO [http-nio-8084-exec-3] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying configuration descriptor C:\Users\serega\AppData\Roaming\NetBeans\8.0.1\apache-tomcat-8.0.9.0_base\conf\Catalina\localhost\MDCWebDispatcher.xml
17-Oct-2014 17:50:38.346 WARNING [http-nio-8084-exec-3] org.apache.catalina.startup.SetContextPropertiesRule.begin [SetContextPropertiesRule]{Context} Setting property 'antiJARLocking' to 'true' did not find a matching property.
17-Oct-2014 17:50:39.775 SEVERE [http-nio-8084-exec-3] org.apache.catalina.core.StandardContext.startInternal Error listenerStart
17-Oct-2014 17:50:39.783 SEVERE [http-nio-8084-exec-3] org.apache.catalina.core.StandardContext.startInternal Context [/MDCWebDispatcher] startup failed due to previous errors
17-Oct-2014 17:50:39.791 INFO [http-nio-8084-exec-3] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of configuration descriptor C:\Users\serega\AppData\Roaming\NetBeans\8.0.1\apache-tomcat-8.0.9.0_base\conf\Catalina\localhost\MDCWebDispatcher.xml has finished in 1,484 ms
My Program's run
ant -f "D:\\serg\\Projects2 - Copy\\MDCWebDispatcher" -Dnb.internal.action.name=run -Ddirectory.deployment.supported=true -DforceRedeploy=false "-Dbrowser.context=D:\\serg\\Projects2 - Copy\\MDCWebDispatcher" run
init:
deps-module-jar:
CommonForgeClassesLib.init:
Deleting: D:\serg\Projects2 - Copy\CommonForgeClassesLib\build\built-jar.properties
CommonForgeClassesLib.deps-jar:
Updating property file: D:\serg\Projects2 - Copy\CommonForgeClassesLib\build\built-jar.properties
CommonForgeClassesLib.wsimport-init:
CommonForgeClassesLib.wsimport-client-CpService:
files are up to date
CommonForgeClassesLib.wsimport-client-generate:
CommonForgeClassesLib.compile:
Copy libraries to D:\serg\Projects2 - Copy\CommonForgeClassesLib\dist\lib.
To run this application from the command line without Ant, try:
java -jar "D:\serg\Projects2 - Copy\CommonForgeClassesLib\dist\CommonForgeClassesLib.jar"
CommonForgeClassesLib.jar:
machMonitoring.init:
Deleting: D:\serg\Projects2 - Copy\machMonitoring\build\built-jar.properties
machMonitoring.deps-jar:
Updating property file: D:\serg\Projects2 - Copy\machMonitoring\build\built-jar.properties
CommonForgeClassesLib.init:
CommonForgeClassesLib.deps-jar:
Updating property file: D:\serg\Projects2 - Copy\machMonitoring\build\built-jar.properties
CommonForgeClassesLib.wsimport-init:
CommonForgeClassesLib.wsimport-client-CpService:
files are up to date
CommonForgeClassesLib.wsimport-client-generate:
CommonForgeClassesLib.compile:
Copy libraries to D:\serg\Projects2 - Copy\CommonForgeClassesLib\dist\lib.
To run this application from the command line without Ant, try:
java -jar "D:\serg\Projects2 - Copy\CommonForgeClassesLib\dist\CommonForgeClassesLib.jar"
CommonForgeClassesLib.jar:
machMonitoring.compile:
Copying 1 file to D:\serg\Projects2 - Copy\machMonitoring\build
Not copying library D:\serg\Projects2 - Copy\machMonitoring\<<<<<<< project.properties , it can't be read.
Copy libraries to D:\serg\Projects2 - Copy\machMonitoring\dist\lib.
To run this application from the command line without Ant, try:
java -jar "D:\serg\Projects2 - Copy\machMonitoring\dist\machMonitoring.jar"
machMonitoring.jar:
deps-ear-jar:
deps-jar:
Copying 1 file to D:\serg\Projects2 - Copy\MDCWebDispatcher\build\web
library-inclusion-in-archive:
library-inclusion-in-manifest:
compile:
compile-jsps:
Starting Tomcat process...
Waiting for Tomcat...
Tomcat server started.
Undeploying ...
undeploy?path=/MDCWebDispatcher
OK - Undeployed application at context path /MDCWebDispatcher
In-place deployment at D:\serg\Projects2 - Copy\MDCWebDispatcher\build\web
Deployment is in progress...
deploy?config=file%3A%2FC%3A%2FUsers%2Fserega%2FAppData%2FLocal%2FTemp%2F2%2Fcontext5124608604393553249.xml&path=/MDCWebDispatcher
FAIL - Deployed application at context path /MDCWebDispatcher but context failed to start
D:\serg\Projects2 - Copy\MDCWebDispatcher\nbproject\build-impl.xml:1112: The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 15 seconds)

I don't understand what I am doing wrong!


Answer:

I noticed that your code is saying it cannot find the HTTPParams class. java.lang.ClassNotFoundException: org.apache.http.params.HttpParams This tells me that the appropriate Jars are not included.

The jar file that contains HttpParams is called HttpCore and can be found here.

This may not be the version you need, and it may not be all you need to have in your project. You'll need to double check which jars you have included, and make sure they are the correct version you need.

I did notice that you're using Netbeans. If you're having trouble with Netbeans deploying to Tomcat, I suggest you look at this link for how to include jar files in Netbeans to make sure they're included properly.

Let us know if this solves the problem and be sure to mark the answer you feel is the "Best Answer".

Question:

Is it possible at all to do what I'm trying to do?

I have a domain - example.com - installed on a webserver Ubuntu 16.04/Apache.

Behind Apache I'm running a standard Glassfish (Payara actually) on standard port 8080.

On Payara I have a webapp - myWebapp - deployed on root context /

when i point my broser directly to port 8080 it shows my web app as i expect:

http://example.com:8080/ => webapp shown.

1) first i want to hide my Payara behind apache and make sure when people write

http://example.com/ the are redirected to

https://example.com => myWebapp is shown.

This part works using AJP and my certificates are all in place.

In my default.conf in the

<VirtualHost *:80>

have inserted the following line:

Redirect permanent / https://example.com

it takes care of the redirection to HTTPS. But i'm in doubt if this is the right way to do it.

Everything else in the conf file is standard.

in my ssl.conf file in the

<virtualHost *.443>

I have inserted

ServerName example.com 

and paths to SSL certificates. It's working as expected.

further more i have added

ProxyPass / ajp://127.0.0.1:8009
ProxyPassReverse / ajp://127.0.0.1:8009

Again, this works well. If i write

http://example.com

I'm redirected to

https://example.com/ => myWebapp is shown.

This is perfect.

but if i write

http://example.com/phpmyadmin

for instance I'm not shown the phpmyadmin page.

How can i accomplish this and is it possible at all?

thanks for any help.

Kim


Answer:

You have a conflict in the following configuration:

ProxyPass / ajp://127.0.0.1:8009
ProxyPassReverse / ajp://127.0.0.1:8009

This sends all http requests, also http://example.com/phpmyadmin to your Payara server

What you need instead is something like

ProxyPass /myWebapp ajp://127.0.0.1:8009
ProxyPassReverse /myWebapp ajp://127.0.0.1:8009

so that only relative URLs that start with /myWebapp are redirected to your Payara server and /phpmyadmin is still hosted by Apache.

The Apache documentation mentions:

Only specific URIs can be proxied, as shown in this example:

ProxyPass "/images"  "http://www.example.com/"
ProxyPassReverse "/images"  "http://www.example.com/"

In the above, any requests which start with the /images path with be proxied to the specified backend, otherwise it will be handled locally.