Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Connecting to POJOs trough TomEE plus server

 
Lubo Kanev
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've created a Dynamic Web Project in Eclipse Kepler EE, connected it to a Tomee plus 1.7.1 server and created a servlet and a POJO. So after opening the browser and trying to do something with the classes, the servlet worked as expected, but the POJO returns error 404.

The actual code is something like this:

// The servlet



// the web.xml




So when I type "localhost:8080/<project_name>/MyServlet" I get the expected "I'm a servlet." message. The problem is with the POJO:

//The POJO



I have nothing about that class in the web.xml file. I have this class, that I don't really know what it does:



Application is a class from M2_REPO\javax\ws\rs\javax.ws.rs-api\2.0.1\javax.ws.rs-api-2.0.1.jar

So when I enter "localhost:8080/<project_name>/sth/MyPOJO", I get error 404, no exceptions no logs. I've tried to debug but it doesn't hit any breakpoints.

Maybe it has something to do with the exception I get when I start the server:

Nov 19, 2014 6:44:50 PM org.apache.myfaces.ee6.MyFacesContainerInitializer onStartup
INFO: Added FacesServlet with mappings=[/faces/*, *.jsf, *.faces]
Nov 19, 2014 6:44:51 PM org.apache.myfaces.config.DefaultFacesConfigurationProvider getStandardFacesConfig
INFO: Reading standard config META-INF/standard-faces-config.xml
Nov 19, 2014 6:44:51 PM org.apache.myfaces.webapp.AbstractFacesInitializer initFaces
SEVERE: An error occured while initializing MyFaces: WebAppBuilder not found in SystemInstance. Ensure the following entry exists in the Tomcat server.xml file: <Listener className="org.apache.tomee.catalina.ServerListener"/>
java.lang.IllegalStateException: WebAppBuilder not found in SystemInstance. Ensure the following entry exists in the Tomcat server.xml file: <Listener className="org.apache.tomee.catalina.ServerListener"/>
at org.apache.tomee.myfaces.TomEEAnnotationProvider.getAnnotatedClasses(TomEEAnnotationProvider.java:43)
at org.apache.myfaces.config.annotation.AnnotationConfigurator.createFacesConfig(AnnotationConfigurator.java:90)
at org.apache.myfaces.config.DefaultFacesConfigurationProvider.getAnnotationsFacesConfig(DefaultFacesConfigurationProvider.java:152)
at org.apache.myfaces.config.DefaultFacesConfigurationMerger.getFacesConfigData(DefaultFacesConfigurationMerger.java:91)
at org.apache.myfaces.config.FacesConfigurator.configure(FacesConfigurator.java:416)
at org.apache.myfaces.webapp.AbstractFacesInitializer.buildConfiguration(AbstractFacesInitializer.java:370)
at org.apache.myfaces.webapp.Jsp21FacesInitializer.initContainerIntegration(Jsp21FacesInitializer.java:73)
at org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(AbstractFacesInitializer.java:143)
at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:119)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4937)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Nov 19, 2014 6:44:51 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [162] milliseconds.
Nov 19, 2014 6:44:59 PM org.apache.myfaces.ee6.MyFacesContainerInitializer onStartup
INFO: Added FacesServlet with mappings=[/faces/*, *.jsf, *.faces]
Nov 19, 2014 6:44:59 PM org.apache.myfaces.config.DefaultFacesConfigurationProvider getStandardFacesConfig
INFO: Reading standard config META-INF/standard-faces-config.xml
Nov 19, 2014 6:44:59 PM org.apache.myfaces.webapp.AbstractFacesInitializer initFaces
SEVERE: An error occured while initializing MyFaces: WebAppBuilder not found in SystemInstance. Ensure the following entry exists in the Tomcat server.xml file: <Listener className="org.apache.tomee.catalina.ServerListener"/>
java.lang.IllegalStateException: WebAppBuilder not found in SystemInstance. Ensure the following entry exists in the Tomcat server.xml file: <Listener className="org.apache.tomee.catalina.ServerListener"/>
at org.apache.tomee.myfaces.TomEEAnnotationProvider.getAnnotatedClasses(TomEEAnnotationProvider.java:43)
at org.apache.myfaces.config.annotation.AnnotationConfigurator.createFacesConfig(AnnotationConfigurator.java:90)
at org.apache.myfaces.config.DefaultFacesConfigurationProvider.getAnnotationsFacesConfig(DefaultFacesConfigurationProvider.java:152)
at org.apache.myfaces.config.DefaultFacesConfigurationMerger.getFacesConfigData(DefaultFacesConfigurationMerger.java:91)
at org.apache.myfaces.config.FacesConfigurator.configure(FacesConfigurator.java:416)
at org.apache.myfaces.webapp.AbstractFacesInitializer.buildConfiguration(AbstractFacesInitializer.java:370)
at org.apache.myfaces.webapp.Jsp21FacesInitializer.initContainerIntegration(Jsp21FacesInitializer.java:73)
at org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(AbstractFacesInitializer.java:143)
at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:119)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4937)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

I've tried to add the line that is missing in the server.xml file but then the server doesn't start at all.

When my college tries to run it on his PC, it work with both the POJO and the Servlet. We can't find any reason why it's not running on my PC.

 
Dave Tolls
Ranch Hand
Posts: 2285
25
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know MyFaces, but this error seems fairly descriptive:

"
An error occured while initializing MyFaces: WebAppBuilder not found in SystemInstance. Ensure the following entry exists in the Tomcat server.xml file: <Listener className="org.apache.tomee.catalina.ServerListener"/>
"
 
Lubo Kanev
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:I don't know MyFaces, but this error seems fairly descriptive:

"
An error occured while initializing MyFaces: WebAppBuilder not found in SystemInstance. Ensure the following entry exists in the Tomcat server.xml file: <Listener className="org.apache.tomee.catalina.ServerListener"/>
"


Yes, I've tried to fix that but I couldn't find a solution. Adding the line in server.xml prevents the server from starting.
 
Tim Holloway
Bartender
Posts: 18419
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no idea what you are trying to do, and I suspect neither does the server, which is why you're getting that error. Although if Tomcat won't start when you add the Listener element, you probably aren't adding it to the right place.

You don't "connect to a POJO" using JSF. JSF is a Model/View/Controller platform where the Views are defined in a View Template Language/View Definition Language (.xhtml), the Models are JSF backing beans (Managed Beans), and the Controllers are pre-written parts of JSF itself.

Backing beans are POJOs, it's true, but you don't access them directly, you reference their properties and actions from a View. To do that you have to create a View Template, ensure that your web.xml defines an URL-to-resource mapping (typically URL "/..xyz.jsf" to resource "/..xyz.xhtml"), then request the View from your client/browser. For example, "http://mytomcat.com:8080/xyz.jsf".
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!