Resolve non-networked unable to start struts2 problem

Source: Internet
Author: User
Tags addchild socket

A few days before the interview, the interviewer asked to see my work, I opened a project I do, can always report 404 errors, I am puzzled, usually run a good how to a critical moment off the chain, helpless, had to put the old version of the previous hastily let the interviewer see a bit ... After home, ready to change this bug, open but can run normally, I go to ... This is not the heavens to tease me to play ... How could this be?

Complaining about your bad luck ... I thought a little more carefully ... Does this system also recognize the environment ... Is it shy to be in a strange environment? The only difference is that there is a network at home, and in the interview there is no network, with this doubt, I pulled the cable ... Restart ... What I expected ... That's the wrong one. Ha ha... Finally found the reason ... But my system is running locally ... Why do I have to be networked to run it?

So I copied the question. Google a bit ...

Severity: Exception Starting filter Struts2
Unable to load configuration. -Class:java.net.PlainSocketImpl

The Declarations section in the Struts.xml
<! DOCTYPE Struts Public
"-//apache software foundation//dtd Struts

Configuration 2.1//en "
"Http://struts.apache.org/dtds/struts-2.1.dtd" >

Replace with Struts-default.xml in Struts2-core-2.xxx.jar

Statement of the item
<! DOCTYPE Struts Public
"-//apache software foundation//dtd Struts

Configuration 2.0//en "
"Http://struts.apache.org/dtds/struts-2.0.dtd" >

That means keeping it consistent. O (∩_∩) o~

So I opened the Struts2-core-2.xxx.jar Struts-default.xml and replaced the declaration part of my struts.xml file with the declaration part

But the problem still exists ....

Take a closer look at the reported errors, and finally found the clue ...

Severity: Exception Starting filter Struts2
Unable to load configuration. -Class:java.net.PlainSocketImpl
File:PlainSocketImpl.java
Method:connect
Line:177-java/net/plainsocketimpl.java:177:-1
At Org.apache.struts2.dispatcher.Dispatcher.init (dispatcher.java:431)
At Org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher (initoperations.java:69)
At Org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init ( STRUTSPREPAREANDEXECUTEFILTER.JAVA:51)
At Org.apache.catalina.core.ApplicationFilterConfig.initFilter (applicationfilterconfig.java:278)
At Org.apache.catalina.core.ApplicationFilterConfig.getFilter (applicationfilterconfig.java:259)
At Org.apache.catalina.core.ApplicationFilterConfig.setFilterDef (applicationfilterconfig.java:383)
At Org.apache.catalina.core.applicationfilterconfig.<init> (applicationfilterconfig.java:104)
At Org.apache.catalina.core.StandardContext.filterStart (standardcontext.java:4650)
At Org.apache.catalina.core.StandardContext.startInternal (standardcontext.java:5306)
At Org.apache.catalina.util.LifecycleBase.start (lifecyclebase.java:150)
At Org.apache.catalina.core.ContainerBase.addChildInternal (containerbase.java:901)
At Org.apache.catalina.core.ContainerBase.addChild (containerbase.java:877)
At Org.apache.catalina.core.StandardHost.addChild (standardhost.java:633)
At Org.apache.catalina.startup.HostConfig.deployDirectory (hostconfig.java:1114)
At Org.apache.catalina.startup.hostconfig$deploydirectory.run (hostconfig.java:1673)
At Java.util.concurrent.executors$runnableadapter.call (executors.java:441)
At Java.util.concurrent.futuretask$sync.innerrun (futuretask.java:303)
At Java.util.concurrent.FutureTask.run (futuretask.java:138)
At Java.util.concurrent.threadpoolexecutor$worker.runtask (threadpoolexecutor.java:886)
At Java.util.concurrent.threadpoolexecutor$worker.run (threadpoolexecutor.java:908)
At Java.lang.Thread.run (thread.java:619)
caused By:unable to load configuration. -Class:java.net.PlainSocketImpl
File:PlainSocketImpl.java
Method:connect
Line:177-java/net/plainsocketimpl.java:177:-1
At Com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration (configurationmanager.java:58)
At Org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration (dispatcher.java:374)
At Org.apache.struts2.dispatcher.Dispatcher.init (dispatcher.java:418)
... More
caused By:unable to load jar:file:/c:/program%20files%20 (x86)/apache%20software%20foundation/tomcat%207.0/webapps/ Secondmarketsystem2/web-inf/lib/struts2-config-browser-plugin-2.3.15.1.jar!/struts-plugin.xml-class: Java.net.PlainSocketImpl
File:PlainSocketImpl.java
Method:connect
Line:177-java/net/plainsocketimpl.java:177:-1
At Com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles ( xmlconfigurationprovider.java:898)
At Com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments ( xmlconfigurationprovider.java:143)
At Com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init (xmlconfigurationprovider.java:110)
At Com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer (defaultconfiguration.java:168)
At Com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration (configurationmanager.java:55)
... More
caused By:struts.apache.org-class:java.net.plainsocketimpl
File:PlainSocketImpl.java
Method:connect
Line:177-java/net/plainsocketimpl.java:177:-1
At Com.opensymphony.xwork2.util.DomHelper.parse (domhelper.java:115)
At Com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles ( xmlconfigurationprovider.java:893)
... More
caused by:java.net.UnknownHostException:struts.apache.org
At Java.net.PlainSocketImpl.connect (plainsocketimpl.java:177)
At Java.net.SocksSocketImpl.connect (sockssocketimpl.java:366)
At Java.net.Socket.connect (socket.java:525)
At Java.net.Socket.connect (socket.java:475)
At Sun.net.NetworkClient.doConnect (networkclient.java:163)
At Sun.net.www.http.HttpClient.openServer (httpclient.java:394)
At Sun.net.www.http.HttpClient.openServer (httpclient.java:529)
At Sun.net.www.http.httpclient.<init> (httpclient.java:233)
At Sun.net.www.http.HttpClient.New (httpclient.java:306)
At Sun.net.www.http.HttpClient.New (httpclient.java:323)
At Sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient (httpurlconnection.java:860)
At Sun.net.www.protocol.http.HttpURLConnection.plainConnect (httpurlconnection.java:801)
At Sun.net.www.protocol.http.HttpURLConnection.connect (httpurlconnection.java:726)
At Sun.net.www.protocol.http.HttpURLConnection.getInputStream (httpurlconnection.java:1049)
At Com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity (xmlentitymanager.java:677)
At Com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity (xmlentitymanager.java:1315)
At Com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity (xmlentitymanager.java:1282)
At Com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource (xmldtdscannerimpl.java:283)
At Com.sun.org.apache.xerces.internal.impl.xmldocumentscannerimpl$dtddriver.dispatch ( xmldocumentscannerimpl.java:1193)
At Com.sun.org.apache.xerces.internal.impl.xmldocumentscannerimpl$dtddriver.next (XMLDocumentScannerImpl.java : 1090)
At Com.sun.org.apache.xerces.internal.impl.xmldocumentscannerimpl$prologdriver.next (XMLDocumentScannerImpl.java : 1003)
At Com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next (xmldocumentscannerimpl.java:648)
At Com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next (xmlnsdocumentscannerimpl.java:140)
At Com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument ( xmldocumentfragmentscannerimpl.java:510)
At Com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse (xml11configuration.java:807)
At Com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse (xml11configuration.java:737)
At Com.sun.org.apache.xerces.internal.parsers.XMLParser.parse (xmlparser.java:107)
At Com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse (abstractsaxparser.java:1205)
At Com.sun.org.apache.xerces.internal.jaxp.saxparserimpl$jaxpsaxparser.parse (saxparserimpl.java:522)
At Javax.xml.parsers.SAXParser.parse (saxparser.java:395)
At Com.opensymphony.xwork2.util.DomHelper.parse (domhelper.java:113)
... More
2013-9-21 21:51:48 Org.apache.catalina.core.StandardContext startinternal
Severity: Error filterstart
2013-9-21 21:51:48 Org.apache.catalina.core.StandardContext startinternal
Severity: Context [/secondmarketsystem2] startup failed due to previous errors
2013-9-21 21:51:48 Org.apache.catalina.core.ApplicationContext Log

The red part of the above caught my attention ...

The Config browser plugin I just saw in the book a while ago, so I took it to do the test.

The main role is to develop debugging, using the plug-in can clearly see what action is deployed under the STRUTS2 application, and detailed mapping information for each action

So I don't think I've ever had a problem like this before ... May be I added this plugin after the lock caused by ...

So I removed this plugin and restarted it.

Sure enough, the problem is gone ....

But why does this plug-in two appear such a problem?

So I opened the plugin in the Struts-plugin.xml file found his statement division divided into

<! DOCTYPE Struts Public
"-//apache software foundation//dtd Struts Configuration 2.3//en"
"Http://struts.apache.org/dtds/struts-2.3.dtd" >

and the declaration in my struts.xml file is:

<! DOCTYPE Struts Public
"-//apache software foundation//dtd Struts Configuration 2.1.7//en"
"Http://struts.apache.org/dtds/struts-2.1.7.dtd" >

The declaration portion of the struts-default.xml in Struts2-core-2.1.8.1.jar is the same as the

Open the Struts2-core-2.1.8.1.jar file as shown below:


We can see that there are only 2.0, 2.1.7 and 2.1 DTD files, and there is no 2.3 DTD file, because the DTD file is not found 2.3, so when loading struts, the system will go through the network to find the 2.3 DTD file, in the absence of the network, because the file cannot be found, So the error will be ...

So far... Finally found the root of the problem ...

As long as there is no corresponding DTD file in the Struts2-core-2.xxx.jar, struts will automatically find the required DTD file over the network

So the solution is there, or you can change the Struts2-core-2.xxx.jar file to a higher version of the 2.3dtd file.

Either remove the Config browser plugin or change the Config browser plugin to a lower version, and the DTD file in the Declaration section already exists in Struts2-core-2.xxx.jar











Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.